wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

wmiirc.sh (7948B)


      1 #!@BINSH@ -f
      2 # Configure wmii
      3 wmiiscript=wmiirc # For wmii.sh
      4 . 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 # Colors tuples: "<text> <background> <border>"
     19 export WMII_NORMCOLORS='#000000 #c1c48b #81654f'
     20 export WMII_FOCUSCOLORS='#000000 #81654f #000000'
     21 
     22 export WMII_BACKGROUND='#333333'
     23 export WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
     24 
     25 set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
     26 export WMII_TERM="@TERMINAL@"
     27 
     28 # Ask about MODKEY on first run
     29     if ! test -d "${WMII_CONFPATH%%:*}"; then
     30         mkdir "${WMII_CONFPATH%%:*}"
     31         res=$(wihack -type DIALOG xmessage -nearmouse -buttons Windows,Alt -print -fn $WMII_FONT \
     32               "Welcome to wmii,$wi_newline$wi_newline" \
     33               "Most of wmii's default key bindings make use of the$wi_newline" \
     34               "Windows key, or equivalent. For keyboards lacking such$wi_newline" \
     35               "a key, many users change this to the Alt key.$wi_newline$wi_newline" \
     36               "Which would you prefer?")
     37         [ "$res" = "Alt" ] && MODKEY=Mod1
     38         echo "MODKEY=$MODKEY" >"${WMII_CONFPATH%%:*}/wmiirc_local"
     39         chmod +x "${WMII_CONFPATH%%:*}/wmiirc_local"
     40     fi
     41 
     42 # Menu history
     43 hist="${WMII_CONFPATH%%:*}/history"
     44 histnum=5000
     45 
     46 # Column Rules
     47 wmiir write /colrules <<!
     48     /gimp/ -> 17+83+41
     49     /.*/ -> 62+38 # Golden Ratio
     50 !
     51 
     52 # Tagging Rules
     53 wmiir write /rules <<!
     54     # Apps with system tray icons like to their main windows
     55     # Give them permission.
     56     /^Pidgin:/ allow=+activate
     57 
     58     # MPlayer and VLC don't float by default, but should.
     59     /MPlayer|VLC/ floating=on
     60 
     61     # ROX puts all of its windows in the same group, so they open
     62     # with the same tags.  Disable grouping for ROX Filer.
     63     /^ROX-Filer:/ group=0
     64 !
     65 
     66 # Status Bar Info
     67 status() {
     68 	echo -n label $(uptime | sed 's/.*://; s/, / /g') '|' $(date)
     69 }
     70 
     71 # Generic overridable startup details
     72 startup() { witray & }
     73 
     74 wi_runconf -s wmiirc_local
     75 startup
     76 
     77 echo colors $WMII_NORMCOLORS | wmiir create $noticebar
     78 
     79 # Event processing
     80 wi_events <<'!'
     81 # Events
     82 Event CreateTag
     83 	echo colors "$WMII_NORMCOLORS$wi_newline" label "$@" | wmiir create "/lbar/$@"
     84 Event DestroyTag
     85 	wmiir remove "/lbar/$@"
     86 Event FocusTag
     87 	wmiir xwrite "/lbar/$@" colors "$WMII_FOCUSCOLORS"
     88 Event UnfocusTag
     89 	wmiir xwrite "/lbar/$@" colors "$WMII_NORMCOLORS"
     90 Event UrgentTag
     91 	shift
     92 	wmiir xwrite "/lbar/$@" label "*$@"
     93 Event NotUrgentTag
     94 	shift
     95 	wmiir xwrite "/lbar/$@" label "$@"
     96 Event LeftBarClick LeftBarDND
     97 	shift
     98 	wmiir xwrite /ctl view "$@"
     99 Event Unresponsive
    100 	{
    101 		client=$1; shift
    102 		msg="The following client is not responding. What would you like to do?$wi_newline"
    103 		resp=$(wihack -transient $client \
    104 			      xmessage -nearmouse -buttons Kill,Wait -print \
    105 			      -fn "${WMII_FONT%%,*}" "$msg $(wmiir read /client/sel/label)")
    106 		if [ "$resp" = Kill ]; then
    107 			wmiir xwrite /client/$client/ctl slay &
    108 		fi
    109 	}&
    110 Event Notice
    111 	wmiir xwrite $noticebar $wi_arg
    112 
    113 	kill $xpid 2>/dev/null # Let's hope this isn't reused...
    114 	{ sleep $noticetimeout; wmiir xwrite $noticebar ' '; }&
    115 	xpid = $!
    116 
    117 # Menus
    118 Menu Client-3-Delete
    119 	wmiir xwrite /client/$1/ctl kill
    120 Menu Client-3-Kill
    121 	wmiir xwrite /client/$1/ctl slay
    122 Menu Client-3-Fullscreen
    123 	wmiir xwrite /client/$1/ctl Fullscreen on
    124 Event ClientMouseDown
    125 	wi_fnmenu Client $2 $1 &
    126 
    127 Menu LBar-3-Delete
    128 	tag=$1; clients=$(wmiir read "/tag/$tag/index" | awk '/[^#]/{print $2}')
    129 	for c in $clients; do
    130 		if [ "$tag" = "$(wmiir read /client/$c/tags)" ]
    131 		then wmiir xwrite /client/$c/ctl kill
    132 		else wmiir xwrite /client/$c/ctl tags -$tag
    133 		fi
    134 		[ "$tag" = "$(wi_seltag)" ] &&
    135 			wmiir xwrite /ctl view $(wi_tags | wi_nexttag)
    136 	done
    137 Event LeftBarMouseDown
    138 	wi_fnmenu LBar "$@" &
    139 
    140 # Actions
    141 Action showkeys
    142 	echo "$KeysHelp" | xmessage -file - -fn ${WMII_FONT%%,*}
    143 Action quit
    144 	wmiir xwrite /ctl quit
    145 Action exec
    146 	wmiir xwrite /ctl exec "$@"
    147 Action rehash
    148 	wi_proglist $PATH >$progsfile
    149 Action status
    150 	set +xv
    151 	if wmiir remove /rbar/status 2>/dev/null; then
    152 		sleep 2
    153 	fi
    154 	echo colors "$WMII_NORMCOLORS" | wmiir create /rbar/status
    155 	while status | wmiir write /rbar/status; do
    156 		sleep 1
    157 	done
    158 
    159 # Key Bindings
    160 KeyGroup Moving around
    161 Key $MODKEY-$LEFT   # Select the client to the left
    162 	wmiir xwrite /tag/sel/ctl select left
    163 Key $MODKEY-$RIGHT  # Select the client to the right
    164 	wmiir xwrite /tag/sel/ctl select right
    165 Key $MODKEY-$UP     # Select the client above
    166 	wmiir xwrite /tag/sel/ctl select up
    167 Key $MODKEY-$DOWN   # Select the client below
    168 	wmiir xwrite /tag/sel/ctl select down
    169 
    170 Key $MODKEY-space   # Toggle between floating and managed layers
    171 	wmiir xwrite /tag/sel/ctl select toggle
    172 
    173 KeyGroup Moving through stacks
    174 Key $MODKEY-Control-$UP    # Select the stack above
    175 	wmiir xwrite /tag/sel/ctl select up stack
    176 Key $MODKEY-Control-$DOWN  # Select the stack below
    177 	wmiir xwrite /tag/sel/ctl select down stack
    178 
    179 KeyGroup Moving clients around
    180 Key $MODKEY-Shift-$LEFT   # Move selected client to the left
    181 	wmiir xwrite /tag/sel/ctl send sel left
    182 Key $MODKEY-Shift-$RIGHT  # Move selected client to the right
    183 	wmiir xwrite /tag/sel/ctl send sel right
    184 Key $MODKEY-Shift-$UP     # Move selected client up
    185 	wmiir xwrite /tag/sel/ctl send sel up
    186 Key $MODKEY-Shift-$DOWN   # Move selected client down
    187 	wmiir xwrite /tag/sel/ctl send sel down
    188 
    189 Key $MODKEY-Shift-space   # Toggle selected client between floating and managed layers
    190 	wmiir xwrite /tag/sel/ctl send sel toggle
    191 
    192 KeyGroup Client actions
    193 Key $MODKEY-f # Toggle selected client's fullsceen state
    194 	wmiir xwrite /client/sel/ctl Fullscreen toggle
    195 Key $MODKEY-Shift-c # Close client
    196 	wmiir xwrite /client/sel/ctl kill
    197 
    198 KeyGroup Changing column modes
    199 Key $MODKEY-d # Set column to default mode
    200 	wmiir xwrite /tag/sel/ctl colmode sel default-max
    201 Key $MODKEY-s # Set column to stack mode
    202 	wmiir xwrite /tag/sel/ctl colmode sel stack-max
    203 Key $MODKEY-m # Set column to max mode
    204 	wmiir xwrite /tag/sel/ctl colmode sel stack+max
    205 
    206 KeyGroup Running programs
    207 Key $MODKEY-a      # Open wmii actions menu
    208 	action $(wi_actions | wimenu -h "${hist}.actions" -n $histnum) &
    209 Key $MODKEY-p      # Open program menu
    210 	eval wmiir setsid "$(wimenu -h "${hist}.progs" -n $histnum <$progsfile)" &
    211 
    212 Key $MODKEY-Return # Launch a terminal
    213 	eval wmiir setsid $WMII_TERM &
    214 
    215 KeyGroup Other
    216 Key $MODKEY-Control-t # Toggle all other key bindings
    217 	case $(wmiir read /keys | wc -l | tr -d ' \t\n') in
    218 	0|1)
    219 		echo -n "$Keys" | wmiir write /keys
    220 		wmiir xwrite /ctl grabmod $MODKEY;;
    221 	*)
    222 		wmiir xwrite /keys $MODKEY-Control-t
    223 		wmiir xwrite /ctl grabmod Mod3;;
    224 	esac
    225 
    226 KeyGroup Tag actions
    227 Key $MODKEY-t       # Change to another tag
    228 	wmiir xwrite /ctl view $(wi_tags | wimenu -h "${hist}.tags" -n 50) &
    229 Key $MODKEY-Shift-t # Retag the selected client
    230 	# Assumes left-to-right order of evaluation
    231 	wmiir xwrite /client/$(wi_selclient)/ctl tags $(wi_tags | wimenu -h "${hist}.tags" -n 50) &
    232 Key $MODKEY-n	    # Move to the next tag
    233 	wmiir xwrite /ctl view $(wi_tags | wi_nexttag)
    234 Key $MODKEY-b	    # Move to the previous tag
    235 	wmiir xwrite /ctl view $(wi_tags | sort -r | wi_nexttag)
    236 !
    237 	for i in 0 1 2 3 4 5 6 7 8 9; do
    238 		wi_events <<!
    239 Key $MODKEY-$i		 # Move to the numbered view
    240 	wmiir xwrite /ctl view "$i"
    241 Key $MODKEY-Shift-$i     # Retag selected client with the numbered tag
    242 	wmiir xwrite /client/sel/ctl tags "$i"
    243 !
    244 done
    245 wi_events -e
    246 
    247 # WM Configuration
    248 wmiir write /ctl <<!
    249 	font $WMII_FONT
    250 	focuscolors $WMII_FOCUSCOLORS
    251 	normcolors $WMII_NORMCOLORS
    252 	grabmod $MODKEY
    253 	border 1
    254 !
    255 xsetroot -solid "$WMII_BACKGROUND" &
    256 
    257 # Misc
    258 progsfile="$(wmiir namespace)/.proglist"
    259 action status &
    260 wi_proglist $PATH >$progsfile &
    261 
    262 # Setup Tag Bar
    263 IFS="$wi_newline"
    264 wmiir rm $(wmiir ls -p /lbar) >/dev/null
    265 seltag=$(wmiir read /tag/sel/ctl | sed 1q)
    266 unset IFS
    267 wi_tags | while read tag
    268 do
    269 	if [ "$tag" = "$seltag" ]; then
    270 		echo colors "$WMII_FOCUSCOLORS"
    271 		echo label $tag
    272 	else
    273 		echo colors "$WMII_NORMCOLORS"
    274 		echo label $tag
    275 	fi | wmiir create "/lbar/$tag"
    276 done
    277 
    278 wi_eventloop
    279