From eb1cbb009dd8f98eb71db6ff00f741d5329465ee Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 10 Jan 2016 00:14:08 +0800 Subject: Add quake-like urxvt to openbox * `urxvtc.sh`, `urxvtq.sh`: quake-like urxvt terminal * fix error application launch in rc.xml and menu.xml * add suffix to scripts --- _config/openbox/menu.xml | 7 +- _config/openbox/rc.xml | 33 +++++++--- _config/openbox/scripts/pipemenu-places | 102 ----------------------------- _config/openbox/scripts/pipemenu-places.pl | 102 +++++++++++++++++++++++++++++ _config/openbox/scripts/urxvtc.sh | 21 ++++++ _config/openbox/scripts/urxvtq.sh | 32 +++++++++ _config/openbox/scripts/xcompmgr.sh | 25 ------- _config/openbox/scripts/xdg-menu | 49 -------------- _config/openbox/scripts/xdg-menu.py | 49 ++++++++++++++ 9 files changed, 231 insertions(+), 189 deletions(-) delete mode 100755 _config/openbox/scripts/pipemenu-places create mode 100755 _config/openbox/scripts/pipemenu-places.pl create mode 100755 _config/openbox/scripts/urxvtc.sh create mode 100755 _config/openbox/scripts/urxvtq.sh delete mode 100755 _config/openbox/scripts/xcompmgr.sh delete mode 100755 _config/openbox/scripts/xdg-menu create mode 100755 _config/openbox/scripts/xdg-menu.py (limited to '_config/openbox') diff --git a/_config/openbox/menu.xml b/_config/openbox/menu.xml index e13a5a3..c8472d5 100644 --- a/_config/openbox/menu.xml +++ b/_config/openbox/menu.xml @@ -22,7 +22,7 @@ - urxvtc || urxvt || x-terminal-emulator + sh -c 'urxvtc || urxvt || x-terminal-emulator' @@ -37,7 +37,7 @@ - gvim || mousepad + sh -c 'gvim || mousepad' @@ -64,7 +64,7 @@ - + @@ -78,7 +78,6 @@ - diff --git a/_config/openbox/rc.xml b/_config/openbox/rc.xml index d7398d7..d0de25b 100644 --- a/_config/openbox/rc.xml +++ b/_config/openbox/rc.xml @@ -383,25 +383,26 @@ scrot -s -e 'mv $f ~/pictures' - - + + - thunar + sh -c 'urxvtc || urxvt || x-terminal-emulator' - + + - xkill + ~/.config/openbox/scripts/urxvtq.sh - + - urxvtc || urxvt || x-terminal-emulator + thunar - + - urxvtc || urxvt || x-terminal-emulator + xkill @@ -956,6 +957,20 @@ # end of the example --> + + + + no + + center + 0 + + all + above + yes + yes + Horizontal + diff --git a/_config/openbox/scripts/pipemenu-places b/_config/openbox/scripts/pipemenu-places deleted file mode 100755 index 812eb27..0000000 --- a/_config/openbox/scripts/pipemenu-places +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env perl -# Recursively browse filesystem through openbox3 pipe menus -#### Usage: add -# -# to your .config/openbox/menu.xml -#### CAVEAT #### -# This script was hacked on exclusively in stints between the hours of -# 4 and 5 in the morning. Quality may have suffered. -#### -# Script by dircha from ob list on 05/17/04 -# suggested improvements by John Russell on 05/17/04 implemented -# a year later by Kacper Wysocki. -# 05/30/05 - Kacper Wysocki -# - opens files with 'rox', which launches appropriate file handler -# - hidden directories now stay hidden -# - spaces, ampersands in dir- and filenames are escaped -# - newlines at each entry to make output a little readable -# 06/04/05 - Kacper Wysocki -# - use $0 for scriptname -# - use $ENV{'HOME'} as default path -# - now follows symlinks - -use strict; - -# Command to lauch files with -my $cmd = "thunar"; - -my $path = $ARGV[0]; -$path = "$ENV{'HOME'}" if $path eq ""; -my @files = split /\n/, `ls -1p '$path'`; -mk_menu_element($path, @files); - -sub mk_menu_element { - my ($path, @files) = @_; - - print "\n"; - - # "Browse here..." lauches this dir - print "". - "\n\t". - "\n\t\t$cmd '$path'". - "\n\t". - "\n\n". - ""; - - foreach $_ (@files) { - my $length = length $_; - my $last_c = substr $_, $length - 1, 1; - - if ($last_c eq "/") { - print mk_dir_element($path, substr $_, 0, $length - 1); - } elsif ($last_c eq "@") { - print mk_sym_element($path, substr $_, 0, $length - 1); - } else { - print mk_file_element($path, $_); - } - } - print "\n"; -} - -sub mk_dir_element { - my ($path, $name) = @_; - # escape ampersand and space in pathnames - $path =~ s/&/&/g; - $name =~ s/&/&/g; - $path =~ s/ /\\ /g; - $name =~ s/ /\\ /g; - - return "\n"; -} - -sub mk_sym_element { - my ($path, $name) = @_; - # escape ampersand in pathnames - $path =~ s/&/&/g; - $name =~ s/&/&/g; - - # Follow symlinks instead of opening links in rox. - return "\n"; -=cut - return "". - "\n\t". - "\n\t\t$cmd '$path/$name'". - "\n\t" - . "\n\n"; -=cut -} - -sub mk_file_element { - my ($path, $name) = @_; - my $label = $name; - # escape ampersand in pathnames - $path =~ s/&/&/g; - $name =~ s/&/&/g; - - return "". - "\n\t". - "\n\t\t$cmd '$path/$name'". - "\n\t" - . "\n\n"; -} - diff --git a/_config/openbox/scripts/pipemenu-places.pl b/_config/openbox/scripts/pipemenu-places.pl new file mode 100755 index 0000000..812eb27 --- /dev/null +++ b/_config/openbox/scripts/pipemenu-places.pl @@ -0,0 +1,102 @@ +#!/usr/bin/env perl +# Recursively browse filesystem through openbox3 pipe menus +#### Usage: add +# +# to your .config/openbox/menu.xml +#### CAVEAT #### +# This script was hacked on exclusively in stints between the hours of +# 4 and 5 in the morning. Quality may have suffered. +#### +# Script by dircha from ob list on 05/17/04 +# suggested improvements by John Russell on 05/17/04 implemented +# a year later by Kacper Wysocki. +# 05/30/05 - Kacper Wysocki +# - opens files with 'rox', which launches appropriate file handler +# - hidden directories now stay hidden +# - spaces, ampersands in dir- and filenames are escaped +# - newlines at each entry to make output a little readable +# 06/04/05 - Kacper Wysocki +# - use $0 for scriptname +# - use $ENV{'HOME'} as default path +# - now follows symlinks + +use strict; + +# Command to lauch files with +my $cmd = "thunar"; + +my $path = $ARGV[0]; +$path = "$ENV{'HOME'}" if $path eq ""; +my @files = split /\n/, `ls -1p '$path'`; +mk_menu_element($path, @files); + +sub mk_menu_element { + my ($path, @files) = @_; + + print "\n"; + + # "Browse here..." lauches this dir + print "". + "\n\t". + "\n\t\t$cmd '$path'". + "\n\t". + "\n\n". + ""; + + foreach $_ (@files) { + my $length = length $_; + my $last_c = substr $_, $length - 1, 1; + + if ($last_c eq "/") { + print mk_dir_element($path, substr $_, 0, $length - 1); + } elsif ($last_c eq "@") { + print mk_sym_element($path, substr $_, 0, $length - 1); + } else { + print mk_file_element($path, $_); + } + } + print "\n"; +} + +sub mk_dir_element { + my ($path, $name) = @_; + # escape ampersand and space in pathnames + $path =~ s/&/&/g; + $name =~ s/&/&/g; + $path =~ s/ /\\ /g; + $name =~ s/ /\\ /g; + + return "\n"; +} + +sub mk_sym_element { + my ($path, $name) = @_; + # escape ampersand in pathnames + $path =~ s/&/&/g; + $name =~ s/&/&/g; + + # Follow symlinks instead of opening links in rox. + return "\n"; +=cut + return "". + "\n\t". + "\n\t\t$cmd '$path/$name'". + "\n\t" + . "\n\n"; +=cut +} + +sub mk_file_element { + my ($path, $name) = @_; + my $label = $name; + # escape ampersand in pathnames + $path =~ s/&/&/g; + $name =~ s/&/&/g; + + return "". + "\n\t". + "\n\t\t$cmd '$path/$name'". + "\n\t" + . "\n\n"; +} + diff --git a/_config/openbox/scripts/urxvtc.sh b/_config/openbox/scripts/urxvtc.sh new file mode 100755 index 0000000..087253f --- /dev/null +++ b/_config/openbox/scripts/urxvtc.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Start urxvt client, and start urxvt server first if necessary. +# +# Credits: +# [1] ArchWiki - rxvt-unicode - Improved Quake-like behavior in Openbox +# https://wiki.archlinux.org/index.php/rxvt-unicode#Improved_Kuake-like_behavior_in_Openbox +# [2] HOWTO: get a quake-like urxvt terminal in openbox +# https://bbs.archlinux.org/viewtopic.php?pid=550380 +# +# Aaron LI +# Created: 2015-01-09 +# Updated: 2015-01-09 +# + +urxvtc "$@" +if [ $? -eq 2 ]; then + urxvtd -q -o -f + urxvtc "$@" +fi + diff --git a/_config/openbox/scripts/urxvtq.sh b/_config/openbox/scripts/urxvtq.sh new file mode 100755 index 0000000..165daae --- /dev/null +++ b/_config/openbox/scripts/urxvtq.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Make a urxvt client behave like Quake with `xdotool`. +# +# Credits: +# [1] ArchWiki - rxvt-unicode - Improved Quake-like behavior in Openbox +# https://wiki.archlinux.org/index.php/rxvt-unicode#Improved_Kuake-like_behavior_in_Openbox +# [2] HOWTO: get a quake-like urxvt terminal in openbox +# https://bbs.archlinux.org/viewtopic.php?pid=550380 +# +# Aaron LI +# Created: 2015-01-09 +# Updated: 2015-01-09 +# + +this=$(realpath $0) +this_dir=$(dirname $this) + +wid=$(xdotool search --classname "^urxvtq$") + +if [ -z "$wid" ]; then + $this_dir/urxvtc.sh -name urxvtq -geometry 90x24 + wid=$(xdotool search --classname "^urxvtq$") + xdotool windowfocus "$wid" + xdotool key Control_L+l +elif [ -z "$(xdotool search --onlyvisible --classname '^urxvtq$' 2>/dev/null)" ]; then + xdotool windowmap "$wid" + xdotool windowfocus "$wid" +else + xdotool windowunmap "$wid" +fi + diff --git a/_config/openbox/scripts/xcompmgr.sh b/_config/openbox/scripts/xcompmgr.sh deleted file mode 100755 index e59eb6a..0000000 --- a/_config/openbox/scripts/xcompmgr.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -case "$1" in - set) - killall xcompmgr - sed -i 's/#xcompmgr.*$/xcompmgr \&/g' ~/.config/openbox/autostart.sh - xcompmgr & - ;; - unset) - sed -i 's/^xcompmgr.*$/#xcompmgr \&/g' ~/.config/openbox/autostart.sh - killall xcompmgr - ;; - setshaded) - killall xcompmgr - sed -i 's/#xcompmgr.*$/xcompmgr -CfF \&/g' ~/.config/openbox/autostart.sh - xcompmgr -CfF & - ;; - setshadowshade) - killall xcompmgr - sed -i 's/#xcompmgr.*$/xcompmgr -CcfF \&/g' ~/.config/openbox/autostart.sh - xcompmgr -CcfF & - ;; - *) - echo "This script accepts the following arguments : set, setshaded, setshadowshade, unset" -esac diff --git a/_config/openbox/scripts/xdg-menu b/_config/openbox/scripts/xdg-menu deleted file mode 100755 index 0a8c1bc..0000000 --- a/_config/openbox/scripts/xdg-menu +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2008 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Author(s): Luke Macken -# Miroslav Lichvar - - -import gmenu, re, sys -from xml.sax.saxutils import escape - -def walk_menu(entry): - if entry.get_type() == gmenu.TYPE_DIRECTORY: - print '' \ - % (escape(entry.menu_id), escape(entry.get_name())) - map(walk_menu, entry.get_contents()) - print '' - elif entry.get_type() == gmenu.TYPE_ENTRY and not entry.is_excluded: - print ' ' % escape(entry.get_name()) - command = re.sub(' [^ ]*%[fFuUdDnNickvm]', '', entry.get_exec()) - if entry.launch_in_terminal: - command = 'xterm -title "%s" -e %s' % \ - (entry.get_name(), command) - print ' ' + \ - '%s' % escape(command) - print ' ' - -if len(sys.argv) > 1: - menu = sys.argv[1] + '.menu' -else: - menu = 'applications.menu' - -print '' -print '' -map(walk_menu, gmenu.lookup_tree(menu).root.get_contents()) -print '' diff --git a/_config/openbox/scripts/xdg-menu.py b/_config/openbox/scripts/xdg-menu.py new file mode 100755 index 0000000..0a8c1bc --- /dev/null +++ b/_config/openbox/scripts/xdg-menu.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# +# Copyright (C) 2008 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Author(s): Luke Macken +# Miroslav Lichvar + + +import gmenu, re, sys +from xml.sax.saxutils import escape + +def walk_menu(entry): + if entry.get_type() == gmenu.TYPE_DIRECTORY: + print '' \ + % (escape(entry.menu_id), escape(entry.get_name())) + map(walk_menu, entry.get_contents()) + print '' + elif entry.get_type() == gmenu.TYPE_ENTRY and not entry.is_excluded: + print ' ' % escape(entry.get_name()) + command = re.sub(' [^ ]*%[fFuUdDnNickvm]', '', entry.get_exec()) + if entry.launch_in_terminal: + command = 'xterm -title "%s" -e %s' % \ + (entry.get_name(), command) + print ' ' + \ + '%s' % escape(command) + print ' ' + +if len(sys.argv) > 1: + menu = sys.argv[1] + '.menu' +else: + menu = 'applications.menu' + +print '' +print '' +map(walk_menu, gmenu.lookup_tree(menu).root.get_contents()) +print '' -- cgit v1.2.2