Guest User

wmiirc

a guest
Jun 16th, 2010
173
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh -f
  2. # wmii configuration file.
  3.  
  4. # REQUIREMENTS: # # ##  # # #
  5. # [*] feh (for the wallpaper)#
  6. # [*] alsa-utils, and alsa   #
  7. # [*] firefox web browser    #
  8. # [*] rxvt-unicode terminal  #
  9. # [*] thunar  file browser   #
  10. # [*] gedit  text browser    #
  11. # [*] transset-df for transp.#
  12. # [*] xcompmgr for composite #
  13. # [&] laptops: acpi          #
  14. # # # # # # # # # # # # # #  #
  15.  
  16. # Configuration Variables
  17. MODKEY=Mod1
  18. UP=k
  19. DOWN=j
  20. LEFT=h
  21. RIGHT=l
  22.  
  23. #----------- THEMES AND TRANSPARENCY ------------ #
  24. WMII_TRANSPARENT_BAR="yes"
  25. WMII_BAR_OPACITY=".70"
  26.  
  27. #This is my favorite font, you can comment-it out if you'd like to.
  28. WMII_FONT='-*-mgopen canonica-medium-r-*-*-*-*-*-*-*-*-iso8859-1'
  29.  
  30. # Colors tuples: "<text> <background> <border>"
  31.  
  32. #WMII_NORMCOLORS='#4d7994 #162438 #162438'
  33. #WMII_FOCUSCOLORS='#ffffff #285577 #285577'
  34. #WMII_URGENTCOLORS='#000000 #FF4400 #FF4400'
  35.  
  36. #WMII_BACKGROUND='#333333'
  37. #WMII_FONT='-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*'
  38.  
  39.  
  40. #  GREEN THEME  #
  41. #WMII_FOCUSCOLORS='#66FF00 #101010 #66FF00'
  42. #WMII_BACKGROUND='#888888'
  43. #WMII_NORMCOLORS='#EEEEEE #000000 #111111'
  44. #WMII_FONT='-artwiz-snap-normal-*-*-*-*-*-*-*-*-*-*-*'
  45.  
  46. # Xterm Style Theme  #
  47. WMII_FOCUSCOLORS='#54FF54 #000000 #73A5FF'
  48. WMII_BACKGROUND='#000000'
  49. WMII_NORMCOLORS='#A8A8A8 #000000 #A07040'
  50. #WMII_FONT='-*-fixed-*-*-*-*-*-*-*-*-*-*-iso8859-7'
  51.  
  52. #BLUE AND SMOKE THEME --UNCOMMENT TO USE, COMMENT-OUT ANY OTHER THEMES #
  53. #WMII_FOCUSCOLORS='#FFFFFF #285577 #4C7899'
  54. #WMII_BACKGROUND='#333333'
  55. #WMII_NORMCOLORS='#888888 #222222 #333333'
  56.  
  57. # sleepless night Theme[MODIFIED]--UNCOMMENT TO USE, COMMENT-OUT ANY OTHER THEMES#
  58. #WMII_NORMCOLORS='#EE6600 #111111 #FF7700'
  59. #WMII_FOCUSCOLORS='#ffffff #330000 #000066'
  60. #WMII_BACKGROUND='#333333'
  61. #WMII_FOCUSCOLORS='#000000 #FFFFFF #666666'
  62. #WMII_FONT='-*-terminus-*-*-*-*-12-*-*-*-*-*-*-*'
  63.  
  64. set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
  65. WMII_MENU="dmenu -b -fn '$WMII_FONT' -nf '$1' -nb '$2' -sf '$4' -sb '$5'"
  66. WMII_9MENU="wmii9menu -font '$WMII_FONT' -nf '$1' -nb '$2' -sf '$4' -sb '$5' -br '$6'"
  67.  
  68.  
  69. ########################## PROGRAMS TO USE ##########################
  70. ###### Set what program should wmii open as a terminal ######
  71. WMII_TERM="urxvt"
  72. ###### Set what argument could you pass to the terminal so it runs a specific command ######
  73. WMII_TERM_EXECARGS="-e" # most terminals use -e command;
  74. ###### Set what program should wmii open as a web browser ######
  75. WMII_WBROWSER="firefox"
  76. ###### Set what program should wmii open as a file browser ######
  77. WMII_FBROWSER="thunar"
  78. ###### Set what program should wmii open as a text editor ######
  79. WMII_TXTEDITOR="gedit"
  80.  
  81. # Path to your favorite wallpaper.
  82. WMII_WALLPAPER="/home/thetrojan01/Pictures/Wallpapers/GoldenSun.jpg"
  83.  
  84. xsetroot -solid "$WMII_BACKGROUND" &
  85. feh --bg-scale $WMII_WALLPAPER &
  86. xcompmgr &
  87. #xcompmgr -cCfF -D7 -t -9 -l -9 -r7 -O 0.02 -I 0.040 &
  88. #xcompmgr -cC -t -9 -l -9 -r7 &
  89. #xcompmgr -fF -D7 -I 0.040 -O 0.1 &
  90.  
  91. # Column Rules
  92. wmiir write /colrules <<!
  93. /.*/ -> 100
  94. !
  95.  
  96.  
  97. # Tagging Rules
  98. wmiir write /tagrules <<!
  99. /.feh*/ -> ~
  100. /.Gimp*/ -> ~
  101. /.Eog*/ -> ~
  102. /.alsamixer*/ -> ~
  103. /.Calculator*/ -> ~
  104. /.Xfce4*/ -> ~
  105. /.xawtv*/ -> ~
  106. /.aMSN*/ -> ~
  107. /.tvtime*/-> ~
  108. /.*/ -> sel
  109. /.*/ -> 1
  110. !
  111.  
  112.  
  113. #BEGIN ArchGh0ul status
  114. #MAXVOLUME=`amixer -c0 get Master | awk '/^  Limits/ { print $5 }'`
  115. #GETVOLUME="`(amixer -c0 get Master | grep 'Mono: Playback') | awk '/^ / {print $3}'; echo " $MAXVOLUME"`"
  116.  
  117. #STATUSFILE="~/.wmii-3.5/status"
  118.  
  119. status(){
  120.  
  121. #------------- FOR LAPTOPS------------#
  122. #REM=`grep 'remaining capacity' /proc/acpi/battery/BAT0/state | awk '{print $3}'`
  123. #LAST=`grep 'last full' /proc/acpi/battery/BAT0/info |awk '{print $4}'`
  124.  
  125. #ADAPTERSTATUS=`cat /proc/acpi/ac_adapter/AC0/state | grep 'state' | awk '{ print $2 }'`
  126. #if [ $ADAPTERSTATUS = "on-line" ]
  127. #then
  128. #   BATCURRENT=$(echo $REM $LAST | awk '{printf "%d%%", ($1/$2)*100'})
  129. #   POWERLINE=$(echo "AC: $BATCURRENT")
  130. #else
  131. #   PRESENT=`grep 'present rate' /proc/acpi/battery/BAT0/state | awk '{print $3}'`
  132. #   BATCURRENT=$(echo $REM $LAST $PRESENT | awk '{printf "%d", ($1/$2)*100}')
  133. #   BATLEFT=$(echo $REM $LAST $PRESENT | awk '{printf "%d", ($1/$3)*60}')
  134. #   if [ $BATCURRENT -ge 40 ]
  135. #   then
  136. #       POWERLINE=$(echo "Battery: $BATCURRENT%")
  137. #   fi
  138. #   if [ $BATCURRENT -le 39 ]
  139. #   then
  140. #       if [ $BATCURRENT -ge 20 ]
  141. #       then
  142. #           POWERLINE=$(echo "Battery: $BATCURRENT%")
  143. #       fi 
  144. #   fi
  145. #   if [ $BATCURRENT -le 19 ]
  146. #   then
  147. #       POWERLINE=$(echo "Battery: $BATCURRENT%")
  148. #   fi
  149. #fi
  150. #-----------------------CPU TEMPERATURE--------------------#
  151. #TEMPERATURE=`cat /proc/acpi/thermal_zone/THRM/temperature | grep 'temperature' | awk '{ printf "%d", $2 }'`
  152. #if [ $TEMPERATURE -le 64 ]
  153. #then
  154. #   TEMPERATURELINE=$(echo "Cpu0 Temp: $TEMPERATURE C")
  155. #fi
  156. #
  157. #if [ $TEMPERATURE -ge 65 ]
  158. #then
  159. #   if [ $TEMPERATURE -le 74 ]
  160. #   then
  161. #       TEMPERATURELINE=$(echo "Cpu0 Temp: $TEMPERATURE C")
  162. #   fi
  163. #fi
  164. #
  165. #if [ $TEMPERATURE -ge 75 ]
  166. #then
  167. #   TEMPERATURELINE=$(echo "Cpu0 Temp: $TEMPERATURE C")
  168. #fi
  169.  
  170. #-------------------VOLUME-------------#
  171. #VOLUMELINE=$(echo "Volume: "`eval "$GETVOLUME" | awk '{ printf "%d", ($1 / $2) * 100 }'` "%"; )
  172.  
  173. MAXVOLUME=`amixer -c0 get Master | awk '/^  Limits/ { print $5 }'`
  174. GETVOLUME="`(amixer -c0 get Master | grep 'Mono: Playback') | awk '/^ / {print $3}'; echo " $MAXVOLUME"`"
  175.  
  176. VOLUMELINE=$(echo "Volume: " $GETVOLUME | awk '{ printf("%s %d %c"), $1, $2 / $3 * 100,"%" }')
  177.  
  178.  
  179. DATELINE=$(echo "`date +%d-%B-%Y` `date +%H:%M:%S` ")
  180.  
  181. #-------------WIFI LINE----------#
  182. # Change wlan0 to your wifi interface.
  183.  
  184. WIFILINE=`echo -n ' wlan0:' $(iwconfig wlan0 | sed 's/ /\n/g' | grep Quality)`
  185.  
  186. #--------------------STATUS----------------------#
  187. #STATUSLINE=`eval $STATUSFILE`
  188.  
  189. echo -n " $WIFILINE | $VOLUMELINE | $DATELINE "
  190.  
  191. }
  192. #END ArchGh0ul status
  193.  
  194. mytags=("nop" "main" "terminal" "web" "IM" "dev" "media" "7" "8" "9")
  195.  
  196.  
  197. # beginners: don't touch anything but keys press events.
  198. # Event processing
  199. #  Processed later by `wmiiloop' and evaled.
  200. #  Duplicate the eval line and replace 'eval' with 'echo' for details.
  201. eventstuff() {
  202.     cat <<'!'
  203.     # Events
  204.     Event Start
  205.         case "$1" in
  206.         wmiirc)
  207.             exit;
  208.         esac
  209.     Event Key
  210.         fn=$(echo "$@" | sed 's/[^a-zA-Z_0-9]/_/g')
  211.         Key_$fn "$@"
  212.     Event CreateTag
  213.         echo "$WMII_NORMCOLORS" ${mytags[$@]} | wmiir create "/lbar/$@"
  214.     #Event DestroyTag
  215.         #wmiir remove "/lbar/$@"
  216.     Event FocusTag
  217.         wmiir xwrite "/lbar/$@" "$WMII_FOCUSCOLORS" ${mytags[$@]}
  218.     Event UnfocusTag
  219.         wmiir xwrite "/lbar/$@" "$WMII_NORMCOLORS" ${mytags[$@]}
  220.     Event UrgentTag
  221.         shift
  222.         echo "$WMII_URGENTCOLORS" ${mytags[$@]} | wmiir create "/lbar/$@"
  223.         urgtag=$@
  224.     Event NotUrgentTag
  225.         shift
  226.         #wmiir xwrite "/lbar/$@" "$@"
  227.         wmiir xwrite "/lbar/$@" ${mytags[$@]}
  228.         echo "$WMII_NORMCOLORS" " " | wmiir create "/lbar/notification"
  229.         urgtag="0"
  230.     Event LeftBarClick
  231.         shift
  232.         wmiir xwrite /ctl view "$@"
  233.     # Actions
  234.     Action quit
  235.         wmiir xwrite /ctl quit
  236.     Action exec
  237.         wmiir xwrite /ctl exec "$@"
  238.     Action rehash
  239.         proglist $PATH >$progsfile
  240.     Action status
  241.         set +xv
  242.         if wmiir remove /rbar/status 2>/dev/null; then
  243.             sleep 2
  244.         fi
  245.         echo "$WMII_NORMCOLORS" | wmiir create /rbar/status
  246.         while status | wmiir write /rbar/status; do
  247.             sleep 1
  248.         done
  249.     Event ClientMouseDown
  250.         client=$1; button=$2
  251.         case "$button" in
  252.         3)
  253.             do=$(eval $WMII_9MENU -initial "${menulast:-SomeRandomName}" Nop Delete Fullscreen)
  254.             case "$do" in
  255.             Delete)
  256.                 wmiir xwrite /client/$client/ctl kill;;
  257.             Fullscreen)
  258.                 wmiir xwrite /client/$client/ctl Fullscreen on;;
  259.             esac
  260.             menulast=${do:-"$menulast"}
  261.         esac
  262. ################ Key Bindings ################
  263.     Key $MODKEY-Control-t
  264.         case $(wmiir read /keys | wc -l | tr -d ' \t\n') in
  265.         0|1)
  266.             echo -n $Keys | tr ' ' '\012' | wmiir write /keys
  267.             wmiir xwrite /ctl grabmod $MODKEY;;
  268.         *)
  269.             wmiir xwrite /keys $MODKEY-Control-t
  270.             wmiir xwrite /ctl grabmod Mod3;;
  271.         esac
  272.     Key $MODKEY-space
  273.         wmiir xwrite /tag/sel/ctl select toggle
  274.     Key $MODKEY-d
  275.         wmiir xwrite /tag/sel/ctl colmode sel default
  276.     Key $MODKEY-s
  277.         wmiir xwrite /tag/sel/ctl colmode sel stack
  278.     Key $MODKEY-m
  279.         wmiir xwrite /tag/sel/ctl colmode sel max
  280.     Key $MODKEY-a
  281.         Action $(actionlist | eval $WMII_MENU) &
  282.     Key $MODKEY-p
  283.         sh -c $(eval "dmenu_path | $WMII_MENU") &
  284.     #Key $MODKEY-t
  285.         #wmiir xwrite /ctl "view $(tagsmenu)" &
  286.     Key $MODKEY-Shift-Return
  287.         eval $WMII_TERM &
  288.     Key $MODKEY-Shift-space
  289.         wmiir xwrite /tag/sel/ctl send sel toggle
  290.     Key $MODKEY-f
  291.         wmiir xwrite /client/sel/ctl Fullscreen toggle
  292.     Key $MODKEY-Shift-c
  293.         wmiir xwrite /client/sel/ctl kill
  294.     Key $MODKEY-Shift-t
  295.         wmiir xwrite "/client/$(wmiir read /client/sel/ctl)/tags" "$(tagsmenu)" &
  296.     Key $MODKEY-$LEFT
  297.         wmiir xwrite /tag/sel/ctl select left
  298.     Key $MODKEY-$RIGHT
  299.         wmiir xwrite /tag/sel/ctl select right
  300.     Key $MODKEY-$DOWN
  301.         wmiir xwrite /tag/sel/ctl select down
  302.     Key $MODKEY-$UP
  303.         wmiir xwrite /tag/sel/ctl select up
  304.     Key $MODKEY-Shift-$LEFT
  305.         wmiir xwrite /tag/sel/ctl send sel left
  306.     Key $MODKEY-Shift-$RIGHT
  307.         wmiir xwrite /tag/sel/ctl send sel right
  308.     Key $MODKEY-Shift-$DOWN
  309.         wmiir xwrite /tag/sel/ctl send sel down
  310.     Key $MODKEY-Shift-$UP
  311.         wmiir xwrite /tag/sel/ctl send sel up
  312.     Key $MODKEY-Shift-v
  313.         eval "$WMII_TERM $WMII_TERM_EXECARGS alsamixer" &
  314.  
  315.     Key $MODKEY-Shift-e
  316.         eval "$WMII_FBROWSER ~/" &
  317.     Key $MODKEY-Shift-w
  318.         eval "$WMII_WBROWSER ~/" &
  319.     Key $MODKEY-Shift-Control-c
  320.         eval "$WMII_TXTEDITOR ~/.wmii-3.5/wmiirc" &
  321.  
  322. !
  323.     for i in 1 2 3 4 5 6 7 8 9; do
  324.         cat <<!
  325.     Key $MODKEY-$i
  326.         wmiir xwrite /ctl view "$i"
  327.     Key $MODKEY-Shift-$i
  328.         wmiir xwrite /client/sel/tags "$i"
  329. !
  330.     done
  331. }
  332.  
  333.  
  334. # WM Configuration
  335. wmiir write /ctl << EOF
  336. font $WMII_FONT
  337. focuscolors $WMII_FOCUSCOLORS
  338. normcolors $WMII_NORMCOLORS
  339. grabmod $MODKEY
  340. border 1
  341. EOF
  342.  
  343. export WMII_MENU WMII_9MENU WMII_FONT WMII_TERM
  344. export WMII_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS
  345.  
  346. # Feed events to `wmiiloop' for processing
  347. eval "$(eventstuff | sed 's/^[  ]//' | { . wmiiloop; })"
  348.  
  349. echo "$Keys" | tr ' ' '\n' | wmiir write /keys
  350.  
  351. # Functions
  352. Action() {
  353.     action=$1; shift
  354.     if [ -n "$action" ]; then
  355.         Action_$action "$@" \
  356.         || conf_which $action "$@"
  357.     fi
  358. }
  359.  
  360. proglist() {
  361.     paths=$(echo "$@" | sed 'y/:/ /')
  362.     ls -lL $paths 2>/dev/null \
  363.         | awk '$1 ~ /^[^d].*x/ && NF > 2 { print $NF }' \
  364.         | sort | uniq
  365. }
  366.  
  367. # Misc
  368. progsfile="$WMII_NS_DIR/.proglist"
  369. Action status &
  370. proglist $PATH >$progsfile &
  371.  
  372. # Setup Tag Bar
  373. #seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)"
  374. wmiir ls /lbar |
  375. while read bar; do
  376.     wmiir remove "/lbar/$bar"
  377. done
  378. for i in 1 2 3 4 5 6 7 8 9; do
  379.     echo "$WMII_NORMCOLORS" ${mytags[$i]} | wmiir create "/lbar/$i"
  380. done
  381. #Autoselect first tag
  382. echo "$WMII_FOCUSCOLORS ${mytags[1]}" | wmiir create "/lbar/1"
  383. seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)"
  384.  
  385. wmiir ls /tag | sed -e 's|/||; /^sel$/d' |
  386. while read tag; do
  387.  
  388.     if [ "X$tag" = "X$seltag" ]; then
  389.             echo "$WMII_FOCUSCOLORS ${mytags[$tag]} | wmiir create "/lbar/$tag"    
  390.     else
  391.             echo "$WMII_NORMCOLORS ${mytags[$tag]} | wmiir create "/lbar/$tag"
  392.     fi
  393. done
  394.  
  395.  
  396.  
  397. # More functions
  398. tagsmenu() {
  399.         wmiir ls /tag | sed 's|/||; /^sel$/d' | eval $WMII_MENU
  400. }
  401.  
  402. actionlist() {
  403.     {   proglist $WMII_CONFPATH
  404.         echo -n $Actions | tr ' ' '\012'
  405.     } | sort | uniq
  406. }
  407.  
  408. conf_which() {
  409.     which=$(which which)
  410.     prog=$(PATH="$WMII_CONFPATH" $which $1); shift
  411.     [ -n "$prog" ] && $prog "$@"
  412. }
  413.  
  414. # Stop any running instances of wmiirc
  415. echo Start wmiirc | wmiir write /event || exit 1
  416.  
  417. #ArchGh0ul transparent bar hack
  418. if [ $WMII_TRANSPARENT_BAR = "yes" ]
  419. then
  420. # What to put after grep? Just run xwininfo and click on the wmii bar. Then after the + character put the dimension of left (?) corner #
  421.     BARLINE=`xwininfo -root -all | grep 1360x15+0+753`
  422.     BARID=`echo $BARLINE | awk '{print $1}' `
  423.     transset-df --id $BARID $WMII_BAR_OPACITY
  424. else
  425.     BARLINE=`xwininfo -root -all | grep 1360x15+0+753`
  426.     BARID=`echo $BARLINE | awk '{print $1}' `
  427.     transset-df --id $BARID 1
  428. fi
  429.  
  430. #Hack done
  431.  
  432. wmiir read /event |
  433. while read event; do
  434.     set -- $event
  435.     event=$1; shift
  436.     Event_$event $@
  437. done 2>/dev/null
RAW Paste Data