wmiirc (8551B)
1 #!/bin/dash -f 2 # Configure wmii 3 wmiiscript=wmiirc # For wmii.sh 4 . ~/config/wmii/wmii.sh 5 6 7 # Configuration Variables 8 MODKEY=Mod4 9 UP=k 10 DOWN=j 11 LEFT=h 12 RIGHT=l 13 14 # Bars 15 noticetimeout=5 16 noticebar=/rbar/!notice 17 18 # . ~/.zshrc.path 19 20 # Colors tuples: "<text> <background> <border>" 21 #export WMII_NORMCOLORS='#ffffff #000000 #888888' 22 #export WMII_FOCUSCOLORS='#000000 #00ff00 #ffffff' 23 #export WMII_BACKGROUND='#000000' 24 export WMII_NORMCOLORS='#888888 #222222 #333333' 25 #export WMII_FOCUSCOLORS='#000000 #28cc55 #4cee78' 26 export WMII_FOCUSCOLORS='#ffffff #285577 #4c7899' 27 export WMII_BACKGROUND='#333333' 28 export WMII_FONT='fixed' 29 30 set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS) 31 export WMII_TERM="urxvtcd" 32 33 if ! test -d "${WMII_CONFPATH%%:*}"; then 34 mkdir "${WMII_CONFPATH%%:*}" 35 res=$(wihack -type DIALOG xmessage -nearmouse -buttons Windows,Alt -print -fn $WMII_FONT \ 36 "Welcome to wmii,$wi_newline$wi_newline" \ 37 "Most of wmii's default key bindings make use of the$wi_newline" \ 38 "Windows key, or equivalent. For keyboards lacking such$wi_newline" \ 39 "a key, many users change this to the Alt key.$wi_newline$wi_newline" \ 40 "Which would you prefer?") 41 [ "$res" = "Alt" ] && MODKEY=Mod1 42 echo "MODKEY=$MODKEY" >"${WMII_CONFPATH%%:*}/wmiirc_local" 43 chmod +x "${WMII_CONFPATH%%:*}/wmiirc_local" 44 fi 45 46 # Menu history 47 hist="${WMII_CONFPATH%%:*}/history" 48 histnum=5000 49 50 # Column Rules 51 wmiir write /colrules <<! 52 /gimp/ -> 17+83+41 53 /.*/ -> 62+38 # Golden Ratio 54 ! 55 56 # Tagging Rules 57 wmiir write /tagrules <<! 58 /MPlayer|VLC/ -> ~ 59 ! 60 61 # Status Bar Info 62 status() { 63 echo -n $(acpi | cut -d ' ' -f 4) $(uptime | sed 's/.*://; s/,//g') '|' $(date) 64 } 65 66 status2() { 67 echo -n $( acpi -tb | cut -d ',' -f 2 | cut -d ' ' -f 2 | tr '\n' '-') 68 } 69 70 local_events() { true;} 71 wi_runconf -s wmiirc_local 72 73 echo $WMII_NORMCOLORS | wmiir create $noticebar 74 75 # Event processing 76 events() { 77 cat <<'!' 78 # Events 79 Event CreateTag 80 echo "$WMII_NORMCOLORS" "$@" | wmiir create "/lbar/$@" 81 Event DestroyTag 82 wmiir remove "/lbar/$@" 83 Event FocusTag 84 wmiir xwrite "/lbar/$@" "$WMII_FOCUSCOLORS" "$@" 85 Event UnfocusTag 86 wmiir xwrite "/lbar/$@" "$WMII_NORMCOLORS" "$@" 87 Event UrgentTag 88 shift 89 wmiir xwrite "/lbar/$@" "*$@" 90 Event NotUrgentTag 91 shift 92 wmiir xwrite "/lbar/$@" "$@" 93 Event LeftBarClick LeftBarDND 94 shift 95 wmiir xwrite /ctl view "$@" 96 Event Unresponsive 97 { 98 client=$1; shift 99 msg="The following client is not responding. What would you like to do?$wi_newline" 100 resp=$(wihack -transient $client \ 101 xmessage -nearmouse -buttons Kill,Wait -print 102 -fn "${WMII_FONT%%,*}" "$msg $(wmiir read /client/sel/label)") 103 if [ "$resp" = Kill ]; then 104 wmiir xwrite /client/$client/ctl slay & 105 fi 106 }& 107 Event Notice 108 wmiir xwrite $noticebar $wi_arg 109 110 kill $xpid 2>/dev/null # Let's hope this isn't reused... 111 { sleep $noticetimeout; wmiir xwrite $noticebar ' '; }& 112 xpid = $! 113 114 # Menus 115 Menu Client-3-Delete 116 wmiir xwrite /client/$1/ctl kill 117 Menu Client-3-Kill 118 wmiir xwrite /client/$1/ctl slay 119 Menu Client-3-Fullscreen 120 wmiir xwrite /client/$1/ctl Fullscreen on 121 Event ClientMouseDown 122 wi_fnmenu Client $2 $1 & 123 124 Menu LBar-3-Delete 125 tag=$1; clients=$(wmiir read "/tag/$tag/index" | awk '/[^#]/{print $2}') 126 for c in $clients; do 127 if [ "$tag" = "$(wmiir read /client/$c/tags)" ]; then 128 wmiir xwrite /client/$c/ctl kill 129 else 130 wmiir xwrite /client/$c/tags -$tag 131 fi 132 if [ "$tag" = "$(wi_seltag)" ]; then 133 newtag=$(wi_tags | awk -v't='$tag ' 134 $1 == t { if(!l) getline l 135 print l 136 exit } 137 { l = $0 }') 138 wmiir xwrite /ctl view $newtag 139 fi 140 done 141 Event LeftBarMouseDown 142 wi_fnmenu LBar "$@" & 143 144 # Actions 145 Action showkeys 146 echo "$KeysHelp" | xmessage -file - -fn ${WMII_FONT%%,*} 147 Action quit 148 wmiir xwrite /ctl quit 149 Action exec 150 wmiir xwrite /ctl exec "$@" 151 Action rehash 152 wi_proglist $PATH >$progsfile 153 Action status 154 set +xv 155 if wmiir remove /rbar/status 2>/dev/null; then 156 sleep 2 157 fi 158 echo "$WMII_NORMCOLORS" | wmiir create /rbar/status 159 while status | wmiir write /rbar/status; do 160 sleep 1 161 done 162 Action a_none 163 echo 'nil' 164 Action status2 165 set +xv 166 if wmiir remove /rbar/statusd 2>/dev/null; then 167 sleep 2 168 fi 169 echo "$WMII_NORMCOLORS" | wmiir create /rbar/statusd 170 while status2 | wmiir write /rbar/statusd; do 171 sleep 1 172 done 173 174 175 Key $MODKEY-e 176 eval $WMII_TERM -e "zsh -c \"$(wimenu -h "${hist}.progs" -n $histnum <$progsfile)\"" & 177 Key $MODKEY-u 178 eval $WMII_TERM -e "zsh -c \"$(wimenu -h "${hist}.progs" -n $histnum <$progsfile); zsh -i\"" & 179 Key $MODKEY-o 180 eval $WMII_TERM -e "zsh -c alot" & 181 182 Key $MODKEY-w 183 eval "sensible-browser" & 184 Key $MODKEY-x 185 sh -c "xtrlock" & 186 Key $MODKEY-w 187 eval "xdotool click 2" & 188 Key $MODKEY-z 189 eval "xsel -x; xsel -b | xsel -i; xdotool click 2; xsel -x" & 190 191 Key $MODKEY-c 192 amixer -c 0 set Master 2dB- 193 Key $MODKEY-r 194 amixer -c 0 set Master 2dB+ 195 196 # Key Bindings 197 KeyGroup Moving around 198 Key $MODKEY-$LEFT # Select the client to the left 199 wmiir xwrite /tag/sel/ctl select left 200 Key $MODKEY-$RIGHT # Select the client to the right 201 wmiir xwrite /tag/sel/ctl select right 202 Key $MODKEY-$UP # Select the client above 203 wmiir xwrite /tag/sel/ctl select up 204 Key $MODKEY-$DOWN # Select the client below 205 wmiir xwrite /tag/sel/ctl select down 206 207 Key $MODKEY-space # Toggle between floating and managed layers 208 wmiir xwrite /tag/sel/ctl select toggle 209 210 KeyGroup Moving through stacks 211 Key $MODKEY-Control-$UP # Select the stack above 212 wmiir xwrite /tag/sel/ctl select up stack 213 Key $MODKEY-Control-$DOWN # Select the stack below 214 wmiir xwrite /tag/sel/ctl select down stack 215 216 KeyGroup Moving clients around 217 Key $MODKEY-Shift-$LEFT # Move selected client to the left 218 wmiir xwrite /tag/sel/ctl send sel left 219 Key $MODKEY-Shift-$RIGHT # Move selected client to the right 220 wmiir xwrite /tag/sel/ctl send sel right 221 Key $MODKEY-Shift-$UP # Move selected client up 222 wmiir xwrite /tag/sel/ctl send sel up 223 Key $MODKEY-Shift-$DOWN # Move selected client down 224 wmiir xwrite /tag/sel/ctl send sel down 225 226 Key $MODKEY-Shift-space # Toggle selected client between floating and managed layers 227 wmiir xwrite /tag/sel/ctl send sel toggle 228 229 KeyGroup Client actions 230 Key $MODKEY-f # Toggle selected client's fullsceen state 231 wmiir xwrite /client/sel/ctl Fullscreen toggle 232 Key $MODKEY-Shift-c # Close client 233 wmiir xwrite /client/sel/ctl kill 234 Key $MODKEY-Shift-x # Slay client 235 wmiir xwrite /client/sel/ctl slay 236 237 KeyGroup Changing column modes 238 Key $MODKEY-d # Set column to default mode 239 wmiir xwrite /tag/sel/ctl colmode sel default-max 240 Key $MODKEY-s # Set column to stack mode 241 wmiir xwrite /tag/sel/ctl colmode sel stack-max 242 Key $MODKEY-m # Set column to max mode 243 wmiir xwrite /tag/sel/ctl colmode sel stack+max 244 245 KeyGroup Running programs 246 Key $MODKEY-a # Open wmii actions menu 247 action $(wi_actions | wimenu -h "${hist}.actions" -n $histnum) & 248 Key $MODKEY-p # Open program menu 249 eval wmiir setsid "$(wimenu -h "${hist}.progs" -n $histnum <$progsfile)" & 250 251 Key $MODKEY-Return # Launch a terminal 252 eval wmiir setsid $WMII_TERM & 253 254 KeyGroup Other 255 Key $MODKEY-Control-t # Toggle all other key bindings 256 case $(wmiir read /keys | wc -l | tr -d ' \t\n') in 257 0|1) 258 echo -n "$Keys" | wmiir write /keys 259 wmiir xwrite /ctl grabmod $MODKEY;; 260 *) 261 wmiir xwrite /keys $MODKEY-Control-t 262 wmiir xwrite /ctl grabmod Mod3;; 263 esac 264 265 KeyGroup Tag actions 266 Key $MODKEY-t # Change to another tag 267 (tag=$(wi_tags | wimenu -h "${hist}.tags" -n 50) && wmiir xwrite /ctl view $tag) & 268 Key $MODKEY-Shift-t # Retag the selected client 269 c=$(wi_selclient) 270 (tag=$(wi_tags | wimenu -h "${hist}.tags" -n 50) && wmiir xwrite /client/$c/tags $tag) & 271 ! 272 for i in 0 1 2 3 4 5 6 7 8 9; do 273 cat <<! 274 Key $MODKEY-$i # Move to the numbered view 275 wmiir xwrite /ctl view "$i" 276 Key $MODKEY-Shift-$i # Retag selected client with the numbered tag 277 wmiir xwrite /client/sel/tags "$i" 278 ! 279 done 280 } 281 wi_events events local_events 282 283 # WM Configuration 284 wmiir write /ctl <<! 285 font $WMII_FONT 286 focuscolors $WMII_FOCUSCOLORS 287 normcolors $WMII_NORMCOLORS 288 grabmod $MODKEY 289 border 1 290 ! 291 xsetroot -solid "$WMII_BACKGROUND" & 292 293 # Misc 294 progsfile="$(wmiir namespace)/.proglist" 295 action status & 296 #action status2 & 297 wi_proglist $PATH >$progsfile & 298 299 # Setup Tag Bar 300 IFS="$wi_newline" 301 wmiir rm $(wmiir ls /lbar | sed 's,^,/lbar/,') >/dev/null 302 seltag=$(wmiir read /tag/sel/ctl | sed 1q) 303 unset IFS 304 wi_tags | while read tag 305 do 306 if [ "$tag" = "$seltag" ]; then 307 echo "$WMII_FOCUSCOLORS" "$tag" 308 else 309 echo "$WMII_NORMCOLORS" "$tag" 310 fi | wmiir create "/lbar/$tag" 311 done 312 313 wi_eventloop 314