diff options
Diffstat (limited to 'ratpoison')
34 files changed, 1160 insertions, 0 deletions
diff --git a/ratpoison/.ratpoison b/ratpoison/.ratpoison new file mode 120000 index 0000000..6b7f260 --- /dev/null +++ b/ratpoison/.ratpoison @@ -0,0 +1 @@ +.ratpoison
\ No newline at end of file diff --git a/ratpoison/.ratpoisonrc.conf.un~ b/ratpoison/.ratpoisonrc.conf.un~ Binary files differnew file mode 100644 index 0000000..b43b148 --- /dev/null +++ b/ratpoison/.ratpoisonrc.conf.un~ diff --git a/ratpoison/borderscript b/ratpoison/borderscript new file mode 100755 index 0000000..1495bec --- /dev/null +++ b/ratpoison/borderscript @@ -0,0 +1,11 @@ +#!/bin/bash + +frames=`ratpoison -c fdump | tr -d -C '(' | wc -c` + +if [[ $frames == 1 ]];then +ratpoison -c "hideborder" +ratpoison -c "hidepadding" +else +ratpoison -c "showborder" +ratpoison -c "showpadding" +fi diff --git a/ratpoison/bordtoggle b/ratpoison/bordtoggle new file mode 100755 index 0000000..4b57c17 --- /dev/null +++ b/ratpoison/bordtoggle @@ -0,0 +1,12 @@ +#!/bin/sh +# This shell script is PUBLIC DOMAIN. You may do whatever you want with it. + +TOGGLE=$HOME/.toggle + +if [ ! -e $TOGGLE ]; then + touch $TOGGLE + ratpoison -c "hideborder" +else + rm $TOGGLE + ratpoison -c "showborder" +fi diff --git a/ratpoison/clipboard b/ratpoison/clipboard new file mode 100755 index 0000000..9033ac1 --- /dev/null +++ b/ratpoison/clipboard @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +# +# Clipboard menu +# +# usage: +# clipboard init - clear all buffers +# clipboard menu_paste - pop up a menu to select which buffer to paste +# clipboard menu_set - pop up a menu to select which buffer to save +# the current X selection to +# clipboard paste N - N is buffer 1-9 +# clipboard set N - N is buffer 1-9 +# clipboard push - stack/queue push (push to buffer 1) +# clipboard pop - stack pop (last in first out - pop from buffer 1) +# clipboard pop_queue - queue pop (first in first out - pop from top of stack) +# +# Current stack depth is held in slot 10, and slot 0 is used as temp space for +# stack rotation. +# +command=$1 +option=$2 + +function entries() { + # title entry + if [ $command = menu_paste ]; then + echo -n "\"Paste from slot:\" /bin/true " + else + echo -n "\"Yank from slot:\" /bin/true " + fi + + for i in $(seq 1 9); do + repr=$(xcb -p $i | tr '\n$*?"'\''' ' ' | cut --bytes 0-59) + if [ $command = menu_paste ]; then + cmd_item="$0 paste $i" + else + cmd_item="$0 set $i" + fi + #printf '%q %q ' $i "$repr" "$cmd_item" + echo -n "\"$i $repr\" \"$cmd_item\" " + done +} + +function menu() { + echo ratmenu -label "\"clipboard $command\"" \ + -style dreary -fg \'#657b83\' -bg \'#eee8d5\' -io 2 $(entries) | sh +} + +function get_stack_depth() { + stack_depth=$(xcb -p 10) + echo "stack_depth=$stack_depth" >/dev/stderr +} + +function set_stack_depth() { + echo "setting stack_depth=$1" >/dev/stderr + echo $1 | xcb -n 11 -s 10 +} + +function increment_stack_depth() { + get_stack_depth + set_stack_depth $[ $stack_depth + 1 ] +} + +function decrement_stack_depth() { + get_stack_depth + set_stack_depth $[ $stack_depth - 1 ] +} + +if [ $command = init ]; then + # Clear all buffers + xcb -n 10 -s 0-9 </dev/null + set_stack_depth 0 +elif [ $command = menu_paste -o $command = menu_set ]; then + menu +elif [ $command = paste ]; then + xcb -p $option | xclip + ratpoison -c "meta S-Insert" +elif [ $command = set ]; then + xcb -n 10 -S $option +elif [ $command = push ]; then + get_stack_depth + if [ $stack_depth -lt 9 ]; then + xcb -n 10 -r 1 + $0 set 1 + increment_stack_depth + fi +elif [ $command = pop ]; then + get_stack_depth + if [ $stack_depth -gt 0 ]; then + $0 paste 1 + # Clear buffer 0 so that rotation won't put its contents into spot 9 + xcb -n 10 -s 0 < /dev/null + xcb -n 10 -r -1 + decrement_stack_depth + fi +elif [ $command = pop_queue ]; then + get_stack_depth + if [ $stack_depth -gt 0 ]; then + $0 paste $stack_depth + # Clear buffer at top of stack + xcb -n 10 -s $stack_depth < /dev/null + decrement_stack_depth + fi +fi + diff --git a/ratpoison/cmusplaying b/ratpoison/cmusplaying new file mode 100755 index 0000000..133b6f9 --- /dev/null +++ b/ratpoison/cmusplaying @@ -0,0 +1 @@ +echo `cmus-remote -Q | awk '/ artist/ {$1=$2=""; print $0}'` - `cmus-remote -Q 2>/dev/null | grep title | awk '{$1=$2=""; print $0}'` diff --git a/ratpoison/cmusvolind b/ratpoison/cmusvolind new file mode 100755 index 0000000..0e95e1e --- /dev/null +++ b/ratpoison/cmusvolind @@ -0,0 +1,34 @@ +#!/bin/bash +volm=`cmus-remote -Q | awk '/vol_left/ {print $3}'` + +if [[ "$volm" -eq "100" ]]; then + let volm=99 +fi + +echo M$volm +bottom=`echo $volm | awk '{print int($1 * 0.2 + 0.5)}'` +top=$((20-$bottom)) + + + +echo -n -e "\xE2\x94\x8C" +echo -n -e "\xE2\x94\x80" +echo -e "\xE2\x94\x90" + +while [ $top -gt 0 ]; do + echo -n -e "\xE2\x94\x82" + echo -n \ + echo -e "\xE2\x94\x82" + let top=$(($top-1)) +done + +while [ $bottom -gt 0 ]; do + echo -n -e "\xE2\x94\x82" + echo -n -e "\xE2\x96\x88" + echo -e "\xE2\x94\x82" + + let bottom=$(($bottom-1)) +done +echo -n -e "\xE2\x94\x94" +echo -n -e "\xE2\x94\x80" +echo -e "\xE2\x94\x98" diff --git a/ratpoison/exec_to_workspace b/ratpoison/exec_to_workspace new file mode 100755 index 0000000..451bb07 --- /dev/null +++ b/ratpoison/exec_to_workspace @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +# Wrapper to executute a shell command in the background followed by a change to a +# workspace +# +# $1 - workspace to change to +# $2+ - shell command + +wg=$1; shift +cmd="$@" +eval $cmd & +rpws $wg + diff --git a/ratpoison/newtab b/ratpoison/newtab new file mode 100755 index 0000000..8bdaf52 --- /dev/null +++ b/ratpoison/newtab @@ -0,0 +1,2 @@ +#!/bin/sh +~/.ratpoison/exec_to_workspace 2 firefox -new-tab $1 diff --git a/ratpoison/numpad/ratnumpad.conf b/ratpoison/numpad/ratnumpad.conf new file mode 100644 index 0000000..f3cc280 --- /dev/null +++ b/ratpoison/numpad/ratnumpad.conf @@ -0,0 +1,12 @@ +# Use numpad to move the rat +definekey top KP_End ratrelwarp -10 10 +definekey top KP_Down ratrelwarp 0 10 +definekey top KP_Next ratrelwarp 10 10 +definekey top KP_Left ratrelwarp -10 0 +definekey top KP_Begin ratclick 1 +definekey top S-KP_Begin ratclick 1 +definekey top KP_Right ratrelwarp 10 0 +definekey top KP_Home ratrelwarp -10 -10 +definekey top KP_Up ratrelwarp 0 -10 +definekey top KP_Prior ratrelwarp 10 -10 +definekey top KP_Delete banish diff --git a/ratpoison/numpad/ratnumund.conf b/ratpoison/numpad/ratnumund.conf new file mode 100644 index 0000000..32d4919 --- /dev/null +++ b/ratpoison/numpad/ratnumund.conf @@ -0,0 +1,12 @@ +# Use numpad to move the rat +undefinekey top KP_End +undefinekey top KP_Down +undefinekey top KP_Next +undefinekey top KP_Left +undefinekey top KP_Begin +undefinekey top S-KP_Begin +undefinekey top KP_Right +undefinekey top KP_Home +undefinekey top KP_Up +undefinekey top KP_Prior +undefinekey top KP_Delete diff --git a/ratpoison/paneltoggle b/ratpoison/paneltoggle new file mode 100755 index 0000000..cb5f367 --- /dev/null +++ b/ratpoison/paneltoggle @@ -0,0 +1,10 @@ +#!/bin/sh +TOGGLE=$HOME/.toggle + +if [ ! -e $TOGGLE ]; then + touch $TOGGLE + ratpoison -c hidepanel +else + rm $TOGGLE + ratpoison -c showpanel +fi diff --git a/ratpoison/pentfocus b/ratpoison/pentfocus new file mode 100755 index 0000000..b0d40de --- /dev/null +++ b/ratpoison/pentfocus @@ -0,0 +1,4 @@ +#!/bin/sh +ratpoison -c 'ratwarp 1332 568' +ratpoison -c 'ratclick 1' +ratpoison -c banish diff --git a/ratpoison/ratpoisonrc.clipboard b/ratpoison/ratpoisonrc.clipboard new file mode 100644 index 0000000..673e969 --- /dev/null +++ b/ratpoison/ratpoisonrc.clipboard @@ -0,0 +1,57 @@ +# Use xcb to build a better cut and paste clipboard. +# +# C-t y # - paste selection buffer # (and sets the current X PRIMARY selection to it) +# C-t p # - set selection buffer # using current X PRIMARY selection + +# C-t y a - pop selection (treat buffers as a stack with 1 being the bottom) +# C-t y q - pop selection (queue pop) +# C-t p a - push selection (treat buffers as a stack with 1 being the bottom) + +# C-t y y - paste selection menu +# C-t p p - set selection menu + +# C-t p C - clear all buffers + +# change directory to $HOME +chdir + +newkmap clipboard_paste +newkmap clipboard_set +exec .ratpoison/clipboard init + +bind p readkey clipboard_paste +bind y readkey clipboard_set + +# Menu version of paste and set +definekey clipboard_paste p exec .ratpoison/clipboard menu_paste +definekey clipboard_set y exec .ratpoison/clipboard menu_set + +# Clear buffers +definekey clipboard_set C exec .ratpoison/clipboard init + +# Push/pop +definekey clipboard_paste a exec .ratpoison/clipboard pop +definekey clipboard_set a exec .ratpoison/clipboard push +# pop queue +definekey clipboard_paste q exec .ratpoison/clipboard pop_queue + +definekey clipboard_paste 1 exec .ratpoison/clipboard paste 1 +definekey clipboard_paste 2 exec .ratpoison/clipboard paste 2 +definekey clipboard_paste 3 exec .ratpoison/clipboard paste 3 +definekey clipboard_paste 4 exec .ratpoison/clipboard paste 4 +definekey clipboard_paste 5 exec .ratpoison/clipboard paste 5 +definekey clipboard_paste 6 exec .ratpoison/clipboard paste 6 +definekey clipboard_paste 7 exec .ratpoison/clipboard paste 7 +definekey clipboard_paste 8 exec .ratpoison/clipboard paste 8 +definekey clipboard_paste 9 exec .ratpoison/clipboard paste 9 + +definekey clipboard_set 1 exec .ratpoison/clipboard set 1 +definekey clipboard_set 2 exec .ratpoison/clipboard set 2 +definekey clipboard_set 3 exec .ratpoison/clipboard set 3 +definekey clipboard_set 4 exec .ratpoison/clipboard set 4 +definekey clipboard_set 5 exec .ratpoison/clipboard set 5 +definekey clipboard_set 6 exec .ratpoison/clipboard set 6 +definekey clipboard_set 7 exec .ratpoison/clipboard set 7 +definekey clipboard_set 8 exec .ratpoison/clipboard set 8 +definekey clipboard_set 9 exec .ratpoison/clipboard set 9 + diff --git a/ratpoison/ratpoisonrc.conf b/ratpoison/ratpoisonrc.conf new file mode 100644 index 0000000..ce18f56 --- /dev/null +++ b/ratpoison/ratpoisonrc.conf @@ -0,0 +1,312 @@ +# info: C=control, M=meta/alt, s=super, S=shift +escape grave +definekey top s-grave meta + +#Test windows +set framesels '0123456789' + +#Palaver voice +definekey top s-Home exec /home/vasko/downloads/Palaver-master/hotkey + + +#Style message box +set bgcolour #fdf6e3 +set fgcolor #657b83 + +# Enable xcb copy/paste +source .ratpoison/ratpoisonrc.clipboard + +# Make tab switch to the next screen +bind Tab nextscreen + +#have windows centered +set wingravity center + +# Use the name of the program rather than the title in the window list +set winname class + +#Pest control. +banish +#exec unclutter -idle 1 -jitter 2 -root +#warp on +#addhook switchwin banish + +#No more startup message +startup_message off + +#fix mouse +exec xsetroot -cursor_name left_ptr + +#Effects & Background +#exec xcompmgr -c -f & + +exec nitrogen --restore + +#Border & Padding +alias showpadding set border 3 +alias hidepadding set border 0 + +barinpadding 1 +alias showborder set barpadding 0 0 +alias hideborder set barpadding 0 0 + +set fwcolor #657b83 +set bwcolor #839496 + +# Use numpad to move the rat +#source .ratpoison/numpad/ratnumpad.conf +bind KP_Multiply source .ratpoison/numpad/ratnumpad.conf +bind KP_Subtract source .ratpoison/numpad/ratnumund.conf + +###################################### +# Panel +###################################### +alias rpbar exec sleep 20 && rpbar +alias rpbarsend exec rpbarsend + +# tell ratpoison to ignore rpbar +unmanage rpbar +# leave space for bars +# start rpbar +alias panel exec xfce4-panel --disable-wm-check +panel +rpbar + +# hooks +addhook switchwin rpbarsend +addhook switchframe rpbarsend +addhook switchgroup rpbarsend +addhook deletewindow rpbarsend +# RP versions >= 1.4.6 (from the git repo) have these hooks. +# Recommended! +addhook titlechanged rpbarsend +addhook newwindow rpbarsend + +unmanage conky +unmanage xfce4-panel +unmanage ratbar.pl +alias showpanel set padding 0 26 0 0 +alias hidepanel set padding 0 0 0 0 +showpanel +#------------------------------------------------------------- +# Workspaces +#------------------------------------------------------------- + + +# Switcher window +alias workspace_menu exec .ratpoison/workspace_menu +bind W workspace_menu + + +#Get F-keys to switch windows now in /usr/bin/rpws +definekey top F1 exec rpws 1 && ratpoison -c bordscript +definekey top F2 exec rpws 2 && ratpoison -c bordscript +definekey top F3 exec ratpoison -c "exec rpws 3 && ratpoison -c bordscript" & ratpoison -c "select 0" +definekey top F4 exec rpws 4 && ratpoison -c bordscript +definekey top F5 exec rpws 5 && ratpoison -c bordscript +definekey top F6 exec rpws 6 && ratpoison -c bordscript +definekey top F7 exec rpws 7 && ratpoison -c bordscript +definekey top F8 exec rpws 8 && ratpoison -c bordscript +definekey top F9 exec rpws 9 && ratpoison -c bordscript +definekey top F10 exec xset -led 3 & exec ratpoison -c "exec rpws 10 && ratpoison -c bordscript" +definekey top F11 exec rpws 11 && ratpoison -c bordscript +definekey top F12 exec rpws 12 && ratpoison -c bordscript + +definekey top M-F1 rpwsm1 +definekey top M-F2 rpwsm2 +definekey top M-F3 rpwsm3 +definekey top M-F4 rpwsm4 +definekey top M-F5 rpwsm5 +definekey top M-F6 rpwsm6 +definekey top M-F7 rpwsm7 +definekey top M-F8 rpwsm8 +definekey top M-F9 rpwsm9 +definekey top M-F10 rpwsm10 +definekey top M-F11 rpwsm11 +definekey top M-F12 rpwsm12 + +definekey top S-F1 exec rpws 13 +definekey top S-F2 exec rpws 14 +definekey top S-F3 exec rpws 15 +definekey top S-F4 exec rpws 16 +definekey top S-F5 exec rpws 17 +definekey top S-F6 exec rpws 18 +definekey top S-F7 exec rpws 19 +definekey top S-F8 exec rpws 20 +definekey top S-F9 exec rpws 21 +definekey top S-F10 exec rpws 22 +definekey top S-F11 exec rpws 23 +definekey top S-F12 exec rpws 24 + +definekey top S-F12 exec rpws 13 +definekey top M-S-F12 rpwsm13 + + +#------------------------------------------------------------- +#Bindings +#------------------------------------------------------------- + +alias window_menu exec .ratpoison/window_menu + +bind h focusleft +bind l focusright +bind j focusdown +bind k focusup +bind H exchangeleft +bind L exchangeright +bind J exchangedown +bind K exchangeup + +bind w window_menu +bind a title +bind t time +definekey top s-l exec xscreensaver-command -lock +definekey top s-L redisplay +bind c exec gksudo gnome-control-center +bind v hsplit +bind V hsplit 2/3 +bind s vsplit +bind S vsplit 2/3 +bind d remove +bind space exec urxvt +bind S-space exec gksu gnome-terminal +bind o only +bind semicolon colon +bind e exec +bind u undo +bind I info +bind x delete +bind X kill +bind Escape abort + +exec a=123 +definekey top s-B exec ratpoison -c "echo `echo $a`" + +alias bordtoggle exec ~/.ratpoison/bordtoggle +alias bordscript exec ~/.ratpoison/borderscript +alias paneltoggle exec ~/.ratpoison/paneltoggle + + + + +addhook key bordscript + +definekey top s-b bordtoggle +definekey top s-p paneltoggle + + + +# b : Open url +alias browse_cmd exec .ratpoison/exec_to_workspace 2 firefox -new-tab +alias browse colon browse_cmd +bind b browse +# B : open a new firefox tab and browse to the X clipboard selection +alias browse_selection exec .ratpoison/exec_to_workspace 2 firefox -new-tab `ratpoison -c getsel` +bind B browse_selection + +# Paste with X selection +alias insert_X_selection meta S-Insert +bind i insert_X_selection + + +#------------------------------------------------------------- +#Application Shortcuts +#------------------------------------------------------------- + +definekey top s-f exec firefox +definekey top s-m exec /home/vasko/.ratpoison/pentfocus +definekey top s-v exec vlc +definekey top s-g exec gvim +definekey top s-l exec libreoffice + +#------------------------------------------------------------- +# Volume Control +#------------------------------------------------------------- +# Up +alias volup exec amixer -q set Master 5+ && ratpoison -c "echo `$HOME/.ratpoison/volind`" + +definekey top XF86AudioRaiseVolume volup +definekey top s-Prior volup + +# Down +alias voldown exec amixer -q set Master 5- && ratpoison -c "echo `$HOME/.ratpoison/volind`" + +definekey top XF86AudioLowerVolume voldown +definekey top s-Next voldown + +# Mute +alias voltoggle exec amixer -D pulse set Master toggle && ratpoison -c "echo Sound: `amixer get Master|awk '/Mono:/ {print $6}'`" + +definekey top XF86AudioMute voltoggle +definekey top s-Pause voltoggle + + +#------------------------------------------------------------- +# Cmus (Music) Control +#------------------------------------------------------------- +# Aliases +alias songinfo exec ratpoison -c "echo Playing:`cmus-remote -Q | awk '/ artist/ {$1=$2=""; print $0}'` - `cmus-remote -Q 2>/dev/null | grep title | awk '{$1=$2=""; print $0}'`" +alias volinfo exec ratpoison -c "echo `$HOME/.ratpoison/cmusvolind`" +alias playinfo exec ratpoison -c "echo Music: `cmus-remote -Q | awk '/status/ {print $2}'`" + + +# Play/Pause and Volume +definekey top s-space exec cmus-remote -u && ratpoison -c "playinfo" +definekey top s-Right exec cmus-remote -n && ratpoison -c "songinfo" +definekey top s-Left exec cmus-remote -r && ratpoison -c "songinfo" +definekey top s-Up exec cmus-remote -v +5% && ratpoison -c "volinfo" +definekey top s-Down exec cmus-remote -v -5% && ratpoison -c "volinfo" + +# Show song that is playing +definekey top Print songinfo + +#------------------------------------------------------------- +# Unbindings +#------------------------------------------------------------- +unbind Q +unbind C-A +unbind C-a +unbind C-p +unbind C-apostrophe +unbind C-i +unbind C-Return +unbind C-n +unbind C-m +unbind C-c +unbind C-k +unbind C-l +unbind C-K +unbind C-exclam +unbind C-grave +unbind C-u +unbind C-g +unbind C-space +unbind C-v +unbind C-s +unbind C-Right +unbind C-Up +unbind C-Down +unbind C-x +unbind C-f +unbind C-V +unbind C-S +unbind C-w +unbind C-b +#------------------------------------------------------------- +# Layout saving +#------------------------------------------------------------- + +# bind M-! to store the current frame layout in slot #1 +bind M-exclam exec ratpoison -c "setenv fs1 `ratpoison -c 'fdump'`" + +#bind M-1 to restore the frame layout in slot #1 +bind M-1 exec ratpoison -c "frestore `ratpoison -c 'getenv fs1'`" + +# Do the same for slot #2 and bind it to M-@ and M-2, respectively. +bind M-at exec ratpoison -c "setenv fs2 `ratpoison -c 'fdump'`" +bind M-2 exec ratpoison -c "frestore `ratpoison -c 'getenv fs2'`" + +# Give ourselves another slot on M-# and M-3, respectively. +bind M-numbersign exec ratpoison -c "setenv fs3 `ratpoison -c 'fdump'`" +bind M-3 exec ratpoison -c "frestore `ratpoison -c 'getenv fs3'`" + diff --git a/ratpoison/rpbar b/ratpoison/rpbar Binary files differnew file mode 100755 index 0000000..407f142 --- /dev/null +++ b/ratpoison/rpbar diff --git a/ratpoison/rpbaro b/ratpoison/rpbaro Binary files differnew file mode 100755 index 0000000..cb4b1f0 --- /dev/null +++ b/ratpoison/rpbaro diff --git a/ratpoison/rpbarsend b/ratpoison/rpbarsend Binary files differnew file mode 100755 index 0000000..e1b7b05 --- /dev/null +++ b/ratpoison/rpbarsend diff --git a/ratpoison/screen_run b/ratpoison/screen_run new file mode 100755 index 0000000..07ba780 --- /dev/null +++ b/ratpoison/screen_run @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Connect to a named screen session if it exists, otherwise create it +# If creating a new screen session, use the file screenrc.$session +# in the .ratpoison directory. +# +screen_dir=$HOME/.ratpoison +session=$1 +function die() { + echo "$0 error: $*" + exit 1 +} +[ $# -ne 1 ] && die "$0 requires 1 argument (screen session name)" +if screen -ls | grep $session; then + # This session exists, connect to it + screen -r $session +else + session_config=$screen_dir/screenrc.$session + [ -f $session_config ] || die "config ($session_config) not found for $session" + screen -c $screen_dir/screenrc.$session -S $session +fi diff --git a/ratpoison/screenout b/ratpoison/screenout new file mode 100755 index 0000000..6687b44 --- /dev/null +++ b/ratpoison/screenout @@ -0,0 +1,2 @@ +#!/bin/sh +cat /tmp/screen-exchange | xclip diff --git a/ratpoison/screenrc b/ratpoison/screenrc new file mode 100644 index 0000000..cb29f66 --- /dev/null +++ b/ratpoison/screenrc @@ -0,0 +1,33 @@ +#escape \\m +defscrollback 5000 +vbell off +startup_message off +altscreen on + + +#multiuser +multiuser on +acladd vasko + +# look and feel +#caption always "%{= bb}%{+b w}%n %h %=%t %c" +caption always "%{= bb}%{+b w}%n %{+b y}%H %=%{+b w}%t %c" +hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<" + +activity "Activity in %t(%n)" + +# bind keys +bind 'l' lastmsg +bind 'q' meta +bind ' ' screen +bind 'a' title +bind 'h' split -h +bind 'v' split -v +bind 'x' remove +bind 'o' only +bind 'r' resize + +# bind buffer +bind b eval writebuf "exec !!! $HOME/.ratpoison/screenout" + + diff --git a/ratpoison/screenrc.admin b/ratpoison/screenrc.admin new file mode 100644 index 0000000..42516d7 --- /dev/null +++ b/ratpoison/screenrc.admin @@ -0,0 +1,20 @@ +# change to home directory and source screenrc from ratpoison directory +chdir +source .ratpoison/screenrc + +screen -t Admin0 0 +screen -t Admin1 1 +screen -t Admin2 2 +screen -t Admin3 3 +screen -t Admin4 4 +screen -t Root0 5 +select 5 +exec sudo su +screen -t Root1 6 +select 6 +exec sudo su +screen -t Root2 7 +select 7 +exec sudo su + +select 0 diff --git a/ratpoison/screenrc.irssi b/ratpoison/screenrc.irssi new file mode 100644 index 0000000..8775960 --- /dev/null +++ b/ratpoison/screenrc.irssi @@ -0,0 +1,7 @@ +# change to home directory and source screenrc from ratpoison directory +escape ^xX +chdir +source .ratpoison/screenrcnobar + +screen -t Irc 0 +exec irssi diff --git a/ratpoison/screenrc.mutt b/ratpoison/screenrc.mutt new file mode 100644 index 0000000..338dc05 --- /dev/null +++ b/ratpoison/screenrc.mutt @@ -0,0 +1,6 @@ +# change to home directory and source screenrc from ratpoison directory +chdir +source .ratpoison/screenrcnobar + +screen -t Mail 0 +exec mutt diff --git a/ratpoison/screenrc.projects b/ratpoison/screenrc.projects new file mode 100644 index 0000000..6850687 --- /dev/null +++ b/ratpoison/screenrc.projects @@ -0,0 +1,11 @@ +# change to home directory and source screenrc from ratpoison directory +chdir +source .ratpoison/screenrc + +screen -t Projects1 0 +screen -t Projects1 1 +screen -t Projects2 2 +screen -t Projects3 3 +screen -t Projects4 4 + +select 1 diff --git a/ratpoison/screenrc.school b/ratpoison/screenrc.school new file mode 100644 index 0000000..ef0df42 --- /dev/null +++ b/ratpoison/screenrc.school @@ -0,0 +1,19 @@ +# change to home directory and source screenrc from ratpoison directory +chdir +source .ratpoison/screenrc + +screen -t Calculator 0 +exec qalc +screen -t Math 1 +exec vim $HOME/Dropbox/Notes/math.txt +screen -t English 2 +exec vim $HOME/Dropbox/Notes/english.txt +screen -t Physics 3 +exec vim $HOME/Dropbox/Notes/physics.txt +screen -t Chemistry 4 +exec vim $HOME/Dropbox/Notes/chemistry.txt +screen -t Biology 4 +exec vim $HOME/Dropbox/Notes/biology.txt +screen -t Arbitrary 5 +exec vim $HOME/Dropbox/Notes/random.txt +select 0 diff --git a/ratpoison/screenrcnobar b/ratpoison/screenrcnobar new file mode 100644 index 0000000..64aedfd --- /dev/null +++ b/ratpoison/screenrcnobar @@ -0,0 +1,25 @@ +#escape \\m +defscrollback 5000 +vbell off +startup_message off +altscreen on + +# look and feel + +activity "Activity in %t(%n)" + +# bind keys +bind 'l' lastmsg +bind 'q' meta +bind ' ' screen +bind 'a' title +bind 'h' split -h +bind 'v' split -v +bind 'x' remove +bind 'o' only +bind 'r' resize + +# bind buffer +bind b eval writebuf "exec !!! $HOME/.ratpoison/screenout" + + diff --git a/ratpoison/taskbar b/ratpoison/taskbar new file mode 100755 index 0000000..46bb43f --- /dev/null +++ b/ratpoison/taskbar @@ -0,0 +1,2 @@ +#!/bin/sh +echo "`rpws current`} | `ratpoison -c "windows" | awk '{printf "%s | ",$0} END {print ""}'`" diff --git a/ratpoison/time b/ratpoison/time new file mode 100755 index 0000000..4e3cbfc --- /dev/null +++ b/ratpoison/time @@ -0,0 +1,7 @@ +#!/bin/bash +for i in {1..5} +do + ratpoison -c "echo `ratpoison -c "time"`" + sleep 1 +done +ratpoison -c "echo ` `" diff --git a/ratpoison/volind b/ratpoison/volind new file mode 100755 index 0000000..c562ef6 --- /dev/null +++ b/ratpoison/volind @@ -0,0 +1,32 @@ +#!/bin/bash +volm=`amixer get Master|awk '/Mono:/ {print $4}'| awk '{print substr($0, 2, length() - 3)}'` +bottom=`echo $volm | awk '{print int($1 * 0.2 + 0.5)}'` +top=$((20-$bottom)) + +if [[ "$volm" -eq "100" ]]; then + let volm=99 +fi + + +echo G$volm +echo -n -e "\xE2\x94\x8C" +echo -n -e "\xE2\x94\x80" +echo -e "\xE2\x94\x90" + +while [ $top -gt 0 ]; do + echo -n -e "\xE2\x94\x82" + echo -n \ + echo -e "\xE2\x94\x82" + let top=$(($top-1)) +done + +while [ $bottom -gt 0 ]; do + echo -n -e "\xE2\x94\x82" + echo -n -e "\xE2\x96\x88" + echo -e "\xE2\x94\x82" + + let bottom=$(($bottom-1)) +done +echo -n -e "\xE2\x94\x94" +echo -n -e "\xE2\x94\x80" +echo -e "\xE2\x94\x98" diff --git a/ratpoison/window_menu b/ratpoison/window_menu new file mode 100755 index 0000000..60f9af7 --- /dev/null +++ b/ratpoison/window_menu @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Lets you switch between all windows in a way that minimizes keystrokes. + +# Two ways to order: +# - If order=last, the windows are listed in the order that you last visited them in. +# - If order=sequential, the windows are listed in number order. +order=sequential + +# Yes, bash is really necessary, because it's version of printf makes this +# script possible. Regular bourne shell printf does NOT. + +window_index_str=$(ratpoison -c "info" | sed 's/^.*\([0-9]\)(.*$/\1/') +if [ "$window_index_str" = "No window." ]; then + group_index=$($HOME/.ratpoison/workspace current) + ratmenu -style dreary -fg "#657b83" -bg "#eee8d5" "No windows in group $group_index" +/bin/true +else + ratpoison -c "echo $window_index_str" + echo "$window_index_str">/tmp/log + window_index=$[ $window_index_str + 1 ] + if [ $order = sequential ]; then + ( printf "ratmenu -style dreary -fg '#657b83' -bg '#eee8d5' -io $window_index \ + \"Select a Window\" /bin/true"; + ratpoison -c "windows %n %n %t" | sort -n | while read w x z; do + a=$(printf "%3q" $x); b="ratpoison -c \"select $x\""; + printf " %q\\ %q %q" "$a" "$z" "$b"; + done; echo \;) | sh + elif [ $order = last ]; then + ( printf "ratmenu -style dreary -fg '#657b83' -bg '#eee8d5' -io $window_index \ + \"Select a Window\" /bin/true"; + ratpoison -c "windows %l %n %t" | sort -rn | while read w x z; do + a=$(printf "%3q" $x); b="ratpoison -c \"select $x\""; + printf " %q\\ %q %q" "$a" "$z" "$b"; + done; echo \;) | sh + fi +fi diff --git a/ratpoison/workspace b/ratpoison/workspace new file mode 100755 index 0000000..c314d0a --- /dev/null +++ b/ratpoison/workspace @@ -0,0 +1,298 @@ +#!/usr/bin/env perl +# +# Copyright (c) 2006 Daniel M. Webb +# Copyright (c) 2005 Mike O'Connor +# All rights reserved. +# Author Daniel M. Webb <public@danielwebb.us> +# Original Author Mike O'Connor <stew@vireo.org> +# +# Modified by Shawn Betts. +# +# code was adapeted from rpws that comes from ratpoison containing the follwing copyright: +# Copyright (C) 2003 Shawn Betts +# Author: Shawn Betts +# +use strict; +use Fcntl qw (:flock); +use Getopt::Std; + +my $ratpoison = $ENV{ "RATPOISON" } || "ratpoison"; +my $tmp=$ENV{ "TMP" } || "/tmp"; +my $lockfile = $ENV{ "WORKSPACE_LOCKFILE" } || "$tmp/workspace.$<.lock"; + +my $number_of_workspaces = 1; +my @ws_names; +my @ws_toggle_memory_trigger; +$ws_names[0] = "default"; # workspace 0 can't be renamed due to bug +for( my $i = 1; $i <= 13; $i++ ) +{ + $ws_names[$i] = "workspace$i"; + $ws_toggle_memory_trigger[$i] = "true"; +} + +# Load configuration now that defaults are set +require "$ENV{HOME}/.ratpoison/workspace.conf"; +set_workspaces(\$number_of_workspaces, \@ws_names, \@ws_toggle_memory_trigger); + +sub help +{ + system("pod2usage", $0); + print( "for more detailed documentation run \"perldoc $0\"\n" ); +} + +sub rp_call +{ + my $result = `$ratpoison -c "@_"`; + chomp( $result ); + chomp( $result ); + return $result; +} + +sub ws_init_ws +{ + my $num = shift; + + if ($num > 0) + { + rp_call( "gnew $ws_names[$num]" ); + } + my $fd = fdump(); + rp_call( "setenv fspl$num $fd" ); +} + +sub fdump +{ + return rp_call( "fdump" ); +} + +sub ws_init +{ + my $num = shift; + + # Backup the frames + my $fd = fdump(); + + rp_call( "select -" ); + rp_call( "only" ); + + my $i; + for( my $i = 0; $i < $number_of_workspaces; $i++ ) + { + ws_init_ws( $i ); + rp_call( "setenv toggle_memory$i 0" ); + } + # Rename group 0 now that there are other groups + # (it can't be deleted if it already exists) + #rp_call( "gdelete 0" ); + #rp_call( "gnew $ws_names[0]" ); + # NOTE: group 0 apparently can't be deleted even if empty, so can't be renamed. + + # Start in workspace 0. + $fd = fdump(); + rp_call( "gselect default" ); + rp_call( "setenv fspl0 $fd" ); + rp_call( "setenv cur_workspace 0" ); + + # restore the frames + rp_call( "frestore $fd" ); + + if( -e "$lockfile" ) + { + unlink ("$lockfile" ); + } +} + +sub ws_save_frames +{ + my $ws = rp_call( "getenv cur_workspace" ); + my $fd = fdump(); + rp_call( "setenv fspl$ws $fd" ); +} + +sub ws_restore +{ + my $new_ws = shift; + my $cur_ws = rp_call( "getenv cur_workspace" ); + # For togglers, give a warning if same ws is chosen. + # For non-togglers, selecting same ws toggles back + if ($new_ws == $cur_ws and $ws_toggle_memory_trigger[$cur_ws] eq "true") + { +# rp_call( "echo Already on workspace $new_ws" ); + } + else + { + if ($new_ws == $cur_ws) + { + # Special case of choosing non-toggler goes back to previous + $new_ws = rp_call( "getenv toggle_memory$cur_ws" ); + } + ws_save_frames(); + if ($ws_toggle_memory_trigger[$cur_ws] eq "true") + { + rp_call( "setenv toggle_memory$new_ws $cur_ws" ); + } + `killall xbindkeys`; + my $rc_dir = `dirname $0`; chomp($rc_dir); + my $rcfilename="$rc_dir/macro/xbindkeysrc/" . "xbindkeysrc.$ws_names[$new_ws]"; + if (-f $rcfilename) { + print "running xbindkeys -f $rcfilename\n"; + `xbindkeys -f $rcfilename`; + } + rp_call( "gselect $ws_names[$new_ws]"); + my $last = rp_call( "getenv fspl$new_ws" ); + rp_call( "frestore $last" ); + rp_call( "setenv cur_workspace $new_ws" ); + # Get window number/name too + my $window_info=rp_call("info"); + my $window_number = $window_info; + $window_number =~ s/^\(.*?\) (\d+).*$/$1/; + my $window_name = $window_info; + $window_name =~ s/^\(.*?\) \d+\((.*)\)$/$1/; +# rp_call( "echo Workspace: $ws_names[$new_ws]\nWindow : $window_number - $window_name" ); + } +} + +sub ws_toggle +{ + my $cur_ws = rp_call( "getenv cur_workspace" ); + my $new_ws = rp_call( "getenv toggle_memory$cur_ws" ); + ws_restore($new_ws); +} + +# unfinished: +sub list_all_windows +{ + my $cur_ws = rp_call( "getenv cur_workspace" ); + print("ratmenu -style dreary -fg '#657b83' -bg '#eee8d5'"); + # FIXME: 6 should be replaced with actual number of workspaces + foreach my $i (0..6) + { + rp_call( "gselect $ws_names[$i]"); + my $result = `$ratpoison -c "windows %n %t"`; + foreach my $line (split (/\n/, $result)) + { + my @window = split(/ /, $line); + print(" \"$ws_names[$i] : $line\" \"$0 $i; ratpoison -c \\\"select $window[0]\\\" \""); + } + } + ws_restore($cur_ws); +} + +sub add_aliases +{ + foreach my $i (0..$number_of_workspaces-1) { + rp_call ( "alias workspace$i exec $0 $i" ); + } + rp_call ( "alias workspace_toggle exec $0 toggle" ); + rp_call ( "alias rpwsn exec $0 next" ); + rp_call ( "alias rpwsp exec $0 prev" ); + rp_call ( "alias rpwsmn exec $0 movenext" ); + rp_call ( "alias rpwsmp exec $0 moveprev" ); + +} + +sub add_keys +{ + foreach my $i (0..$number_of_workspaces-1) { + rp_call ( "bind C-$i workspace$i" ); + } + rp_call ( "bind C-g workspace_toggle" ); +} + +my $arg = shift @ARGV; + +if( $arg eq "help" ) { + help(); +} elsif( $arg eq "init" ) { + my %opts; + ws_init(); + getopts('ka', \%opts); + add_aliases() if $opts{'a'} || $opts{'k'}; + add_keys() if $opts{'k'}; +} else { + open LOCK, ">>$lockfile" or die "Cannot open lockfile: $lockfile"; + flock(LOCK, LOCK_EX); + if ( $arg eq "toggle" ) { + ws_toggle(); + } elsif ( $arg eq "list_all" ) { + list_all_windows(); + } elsif ( $arg eq "current" ) { + my $cws = rp_call( "getenv cur_workspace" ); + print "$cws"; + } elsif ($arg >= 0 and $arg <= 13) { + ws_restore( $arg ); + } else { + help(); + } +} + +__END__ + +=head1 NAME + +workspace - Implements multiple workspaces in ratpoison + +=head1 SYNOPSIS + + workspace init [-k] [-a] - setup workspace with $number_of_workspaces workspaces + ($number_of_workspaces is set in the workspace.conf file). + -a sets up command aliases; + -k sets up key bindings and aliases. + workspace help - this documentation + workspace n - switch to this workspace + workspace toggle - switch to previous workspace (other than default) + workspace toggle_default - switch back and forth to between default workspace + workspace current - print the index of the current workspace + + +=head1 DESCRIPTION + + B<workspace> implements multiple workspaces in ratpoison by making calls + to fdump, freestore. It was adapted from rpws which comes with + ratpoison in the contrib directory. + +=head1 USAGE + +Add the following line in ~/.ratpoisonrc + + exec /path/to/workspace init -k + +This creates 6 aliases workspace1, workspace2, etc. It also binds the keys C-1, +C-2, etc to each workspaceN alias. Workspace names can be configured at the +top of this script. + +The toggle command is analogous to the ratpoison "other" command for windows, +except it is for workspaces and is implemented in this script instead of within +ratpoison. + +If $ws_toggle_memory_trigger is true for a workspace, that workspace sets +the toggle memory on return. If it's false, it will just toggle back to the +previous workspace but the memory will stay the same. + +If there is a file /path/to/workspace/macro/xbindkeysrc/xbindkeysrc.<workspace N name>, +then xbindkeys will be run with this file as configuration. + +=head1 FILES + + workspace requires use of a lockfile. It defaults to using +/tmp/workspace.<UID>.lock but this can be changed by setting the +environment variable WORKSPACE_LOCKFILE to your desired lockfile. + +=head1 AUTHOR + + Mike O'Connor <stew@vireo.org> + +=head1 COPYRIGHT + + Copyright (c) 2005 Mike O'Connor + All rights reserved. + + 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. diff --git a/ratpoison/workspace.conf b/ratpoison/workspace.conf new file mode 100644 index 0000000..6d610f8 --- /dev/null +++ b/ratpoison/workspace.conf @@ -0,0 +1,38 @@ +sub set_workspaces { + my $number_of_workspaces = shift; + my $ws_names = shift; + my $ws_toggle_memory_trigger = shift; + + $$number_of_workspaces = 13; + + # user-customized workspace names: + $$ws_names[1] = "ranger"; + $$ws_names[2] = "firefox"; + $$ws_names[3] = "feeds"; + $$ws_names[4] = "admin"; + $$ws_names[5] = "school"; + $$ws_names[6] = "projects"; + $$ws_names[7] = "notes"; + $$ws_names[8] = "random"; + $$ws_names[9] = "mail"; + $$ws_names[10] = "irc"; + $$ws_names[11] = "wifi"; + $$ws_names[12] = "music"; + + # Does changing to this workspace set the toggle memory of the workspace you came from? + $$ws_toggle_memory_trigger[0] = "true"; + $$ws_toggle_memory_trigger[1] = "true"; + $$ws_toggle_memory_trigger[2] = "true"; + $$ws_toggle_memory_trigger[3] = "true"; + $$ws_toggle_memory_trigger[4] = "true"; + $$ws_toggle_memory_trigger[5] = "true"; + $$ws_toggle_memory_trigger[6] = "true"; + $$ws_toggle_memory_trigger[7] = "true"; + $$ws_toggle_memory_trigger[8] = "true"; + $$ws_toggle_memory_trigger[9] = "true"; + $$ws_toggle_memory_trigger[10] = "true"; + $$ws_toggle_memory_trigger[11] = "true"; + $$ws_toggle_memory_trigger[12] = "true"; +} + +return 1; diff --git a/ratpoison/workspace_menu b/ratpoison/workspace_menu new file mode 100755 index 0000000..020f887 --- /dev/null +++ b/ratpoison/workspace_menu @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Lets you switch between all workspaces in a way that minimizes keystrokes. +# The current workspace is selected. + +# Yes, bash is really necessary, because it's version of printf makes this +# script possible. Regular bourne shell printf does NOT. + +workspace_command="/usr/bin/rpws" + +( printf "ratmenu -style dreary -fg '#657b83' -bg '#eee8d5' -io $[ $($workspace_command current) + 1 ]"; + ratpoison -c "groups" | while read s; do + n=$(echo $s | sed 's/\([0-9]\+\).*/\1/'); + w=$(echo $s | sed 's/[0-9]\+.\(.*\)/\1/'); + a=$(printf "%3q %q" $n $w); b="$workspace_command $n"; + printf " %q %q" "$a" "$b"; + done; echo \;) | sh + |