Advertisement
Guest User

dtk wmii config

a guest
Apr 21st, 2011
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.88 KB | None | 0 0
  1. #
  2. # High-level wmii configuration.
  3. #
  4. # Ruby code in this file has access
  5. # to a CONFIG constant which contains
  6. # the data in this configuration file.
  7. #
  8. #--
  9. # Copyright protects this work.
  10. # See LICENSE file for details.
  11. #++
  12.  
  13.  
  14. ##
  15. # Program preferences.
  16. #
  17. program:
  18. #terminal: gnome-terminal
  19. terminal: urxvt
  20. browser: firefox
  21. editor: gvim
  22. filer: nautilus --no-desktop
  23. lock: gnome-screensaver-command --activate
  24.  
  25.  
  26. ##
  27. # Appearance settings.
  28. #
  29. display:
  30.  
  31. ##
  32. # Where to display the horizontal status bar?
  33. #
  34. # Possible choices are "top" and "bottom".
  35. #
  36. bar: bottom
  37.  
  38. ##
  39. # The font to use in all text drawn by wmii.
  40. #
  41. font: -*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*
  42.  
  43. ##
  44. # Thickness of client border (measured in pixels).
  45. #
  46. border: 1
  47.  
  48. ##
  49. # Number of seconds a notice should be displayed.
  50. #
  51. notice: 5
  52.  
  53. ##
  54. # Color schemes for everything drawn by wmii.
  55. #
  56. # <scheme>: "<text> <background> <border>"
  57. #
  58. # You can find more color schemes here:
  59. #
  60. # http://wmii.suckless.org/scripts_n_snips/themes
  61. #
  62. color:
  63. normal: "#000000 #eeeee6 #81654f"
  64. #focus: "#000000 #d1d1d1 #000000"
  65. #focus: "#ffffff #5e5e5e #000000"
  66. focus: "#a0ff00 #686363 #000000"
  67. error: "#000000 #81654f #000000"
  68. notice: "#000000 #a1956d #413328"
  69. success: "#000000 #c1c48b #81654f"
  70.  
  71. ##
  72. # Color of desktop background.
  73. #
  74. background: "#eeeee6"
  75.  
  76. ##
  77. # Settings for columns drawn by wmii.
  78. #
  79. # mode: <the wmii "colmode" setting>
  80. # rule: <the wmii "colrules" setting>
  81. #
  82. column:
  83. mode: stack
  84. rule: |
  85. /gimp/ -> 17+83+41
  86. /.*/ -> 62+38 # Golden Ratio
  87.  
  88. ##
  89. # Mapping of clients to views they must appear on.
  90. #
  91. # - <client props regular expression> : <tags to apply>
  92. #
  93. # These mappings are processed in top-to-bottom order.
  94. # Processing stops after the first matching mapping is applied.
  95. #
  96. client:
  97. - /MPlayer|VLC/ : ~
  98.  
  99. ##
  100. # Self-refreshing buttons on the status bar.
  101. #
  102. # - <button name>:
  103. # refresh: <number of seconds to wait before refreshing the content>
  104. # content: <Ruby code whose result is displayed as the content>
  105. # click: <Ruby code to handle mouse clicks on the status button.
  106. # This code has access to a "mouse_button" variable which is
  107. # an integer representing the mouse button that was clicked.>
  108. #
  109. # You can refresh a particular status button in Ruby using:
  110. #
  111. # status "your button name"
  112. #
  113. # The horizontal order in which these buttons appear on the status
  114. # bar reflects the vertical order in which they are defined below.
  115. #
  116. status:
  117. #- system_load:
  118. # refresh: 10
  119. # content: |
  120. # load_averages = File.read('/proc/loadavg').split.first(3)
  121. # current_load = load_averages.first.to_f
  122. #
  123. # # visually indicate the intensity of system load
  124. # color = case
  125. # when current_load > 3.0 then CONFIG['display']['color']['error']
  126. # when current_load > 1.5 then CONFIG['display']['color']['notice']
  127. # end
  128. #
  129. # [color, *load_averages]
  130.  
  131. - clock:
  132. refresh: 30
  133. content: Time.now.strftime '%d.%m.%Y|%H:%M'
  134.  
  135.  
  136. ##
  137. # Interaction settings.
  138. #
  139. control:
  140.  
  141. ##
  142. # The wmii "grabmod" setting.
  143. #
  144. grab: Mod4
  145.  
  146. ##
  147. # Key sequence prefixes.
  148. #
  149. mod: Mod4
  150. move: Mod4-Shift
  151. swap: Mod4-w
  152. view: Mod4-v
  153. group: Mod4-g
  154. prog: Mod1
  155.  
  156. ##
  157. # Direction keys.
  158. #
  159. up: k
  160. down: j
  161. left: h
  162. right: l
  163.  
  164. ##
  165. # Sequence keys.
  166. #
  167. prev: b
  168. next: n
  169.  
  170. ##
  171. # Key bindings.
  172. #
  173. # <key sequence>: <Ruby code to execute>
  174. #
  175. # A key sequence may contain ${...} expressions which
  176. # are replaced with the value corresponding to '...'
  177. # in the 'control' section of this configuration file.
  178. #
  179. # For example, if the 'control' section of
  180. # this configuration file appeared like this:
  181. #
  182. # control:
  183. # foo: Mod4
  184. # bar: y
  185. #
  186. # and the following key sequence was used:
  187. #
  188. # ${foo}-${bar},${bar}
  189. #
  190. # then after ${...} expression replacement,
  191. # that key sequence would appear like this:
  192. #
  193. # Mod4-y,y
  194. #
  195. key:
  196. #---------------------------------------------------------------------------
  197. # focus
  198. #---------------------------------------------------------------------------
  199.  
  200. ${mod}-${up}: | # focus above client
  201. curr_view.select(:up) rescue nil
  202.  
  203. ${mod}-${down}: | # focus below client
  204. curr_view.select(:down) rescue nil
  205.  
  206. ${mod}-${left}: | # focus left client
  207. curr_view.select(:left) rescue nil
  208.  
  209. ${mod}-${right}: | # focus right client
  210. curr_view.select(:right) rescue nil
  211.  
  212. ${mod}-space: | # focus floating area (toggle)
  213. curr_view.select(:toggle)
  214.  
  215. ${mod}-${prev}: | # focus previous view
  216. prev_view.focus
  217.  
  218. ${mod}-${next}: | # focus next view
  219. next_view.focus
  220.  
  221. ${mod}-Escape: | # focus most recently focused view
  222. $last_view.focus if $last_view
  223.  
  224. # focus the view whose index or name equals the pressed number
  225. #${mod}-1: focus_view tags[0] || 1
  226. ${mod}-1: switch_to_numeric_tag(1)
  227. ${mod}-2: switch_to_numeric_tag(2)
  228. ${mod}-3: switch_to_numeric_tag(3)
  229. ${mod}-4: switch_to_numeric_tag(4)
  230. ${mod}-5: switch_to_numeric_tag(5)
  231. ${mod}-6: switch_to_numeric_tag(6)
  232. ${mod}-7: switch_to_numeric_tag(7)
  233. ${mod}-8: switch_to_numeric_tag(8)
  234. ${mod}-9: switch_to_numeric_tag(9)
  235. ${mod}-0: switch_to_numeric_tag(0)
  236. #${mod}-8: focus_view '8:mail'
  237. #${mod}-9: focus_view '9:im'
  238. #${mod}-0: focus_view tags[9] || 10
  239.  
  240. # focus the view whose name begins with the pressed alphabet
  241. ${view},a: t = tags.grep(/^a/i).first and focus_view(t)
  242. ${view},b: t = tags.grep(/^b/i).first and focus_view(t)
  243. ${view},c: t = tags.grep(/^c/i).first and focus_view(t)
  244. ${view},d: t = tags.grep(/^d/i).first and focus_view(t)
  245. ${view},e: t = tags.grep(/^e/i).first and focus_view(t)
  246. ${view},f: t = tags.grep(/^f/i).first and focus_view(t)
  247. ${view},g: t = tags.grep(/^g/i).first and focus_view(t)
  248. ${view},h: t = tags.grep(/^h/i).first and focus_view(t)
  249. ${view},i: t = tags.grep(/^i/i).first and focus_view(t)
  250. ${view},j: t = tags.grep(/^j/i).first and focus_view(t)
  251. ${view},k: t = tags.grep(/^k/i).first and focus_view(t)
  252. ${view},l: t = tags.grep(/^l/i).first and focus_view(t)
  253. ${view},m: t = tags.grep(/^m/i).first and focus_view(t)
  254. ${view},n: t = tags.grep(/^n/i).first and focus_view(t)
  255. ${view},o: t = tags.grep(/^o/i).first and focus_view(t)
  256. ${view},p: t = tags.grep(/^p/i).first and focus_view(t)
  257. ${view},q: t = tags.grep(/^q/i).first and focus_view(t)
  258. ${view},r: t = tags.grep(/^r/i).first and focus_view(t)
  259. ${view},s: t = tags.grep(/^s/i).first and focus_view(t)
  260. ${view},t: t = tags.grep(/^t/i).first and focus_view(t)
  261. ${view},u: t = tags.grep(/^u/i).first and focus_view(t)
  262. ${view},v: t = tags.grep(/^v/i).first and focus_view(t)
  263. ${view},w: t = tags.grep(/^w/i).first and focus_view(t)
  264. ${view},x: t = tags.grep(/^x/i).first and focus_view(t)
  265. ${view},y: t = tags.grep(/^y/i).first and focus_view(t)
  266. ${view},z: t = tags.grep(/^z/i).first and focus_view(t)
  267.  
  268. #---------------------------------------------------------------------------
  269. # move
  270. #---------------------------------------------------------------------------
  271.  
  272. ${move}-${up}: | # move grouping toward the top
  273. grouping.each {|c| c.send(:up) rescue nil }
  274.  
  275. ${move}-${down}: | # move grouping toward the bottom
  276. grouping.each {|c| c.send(:down) rescue nil }
  277.  
  278. ${move}-${left}: | # move grouping toward the left
  279. grouping.each {|c| c.send(:left) rescue nil }
  280.  
  281. ${move}-${right}: | # move grouping toward the right
  282. grouping.each {|c| c.send(:right) rescue nil }
  283.  
  284. ${move}-space: | # move grouping to floating area (toggle)
  285. grouping.each {|c| c.send(:toggle) rescue nil }
  286.  
  287. ${move}-t: | # move grouping to chosen view
  288. #
  289. # Changes the tag (according to a menu choice) of
  290. # each grouped client and returns the chosen tag.
  291. #
  292. # The +tag -tag idea is from Jonas Pfenniger:
  293. #
  294. # http://zimbatm.oree.ch/articles/2006/06/15/wmii-3-and-ruby
  295. #
  296. #choices = tags.map {|t| [t, "+#{t}", "-#{t}"] }.flatten
  297. choices = default_tags.merge(resolve_namespaces(tags)).to_a.map {|t| [t, "+#{t}", "-#{t}"] }.flatten
  298.  
  299. if target = key_menu(choices, 'tag as:')
  300. grouping.each {|c| c.tags = target }
  301. end
  302.  
  303. # move grouping to the view whose index or name equals the pressed number
  304. ${move}-1: grouping.each {|c| c.tags = tags[0] || 1 }
  305. ${move}-2: grouping.each {|c| c.tags = tags[1] || 2 }
  306. ${move}-3: grouping.each {|c| c.tags = tags[2] || 3 }
  307. ${move}-4: grouping.each {|c| c.tags = tags[3] || 4 }
  308. ${move}-5: grouping.each {|c| c.tags = tags[4] || 5 }
  309. ${move}-6: grouping.each {|c| c.tags = tags[5] || 6 }
  310. ${move}-7: grouping.each {|c| c.tags = tags[6] || 7 }
  311. ${move}-8: grouping.each {|c| c.tags = tags[7] || 8 }
  312. ${move}-9: grouping.each {|c| c.tags = tags[8] || 9 }
  313. ${move}-0: grouping.each {|c| c.tags = tags[9] || 10 }
  314.  
  315. #---------------------------------------------------------------------------
  316. # group
  317. #---------------------------------------------------------------------------
  318.  
  319. ${group},g: | # toggle current client from grouping
  320. curr_client.group!
  321.  
  322. ${group},c: | # add clients in current area to grouping
  323. curr_area.group
  324.  
  325. ${group},Shift-c: | # remove clients in current area from grouping
  326. curr_area.ungroup
  327.  
  328. ${group},f: | # add clients in floating area to grouping
  329. Area.floating.group
  330.  
  331. ${group},Shift-f: | # remove clients in floating area from grouping
  332. Area.floating.ungroup
  333.  
  334. ${group},m: | # add clients in managed areas to grouping
  335. curr_view.managed_areas.each {|a| a.group }
  336.  
  337. ${group},Shift-m: | # remove clients in managed areas from grouping
  338. curr_view.managed_areas.each {|a| a.ungroup }
  339.  
  340. ${group},v: | # add clients in current view to grouping
  341. curr_view.group
  342.  
  343. ${group},Shift-v: | # remove clients in current view from grouping
  344. curr_view.ungroup
  345.  
  346. ${group},i: | # invert the grouping in the current view
  347. curr_view.group!
  348.  
  349. ${group},Shift-i: | # invert the grouping in all views
  350. Rumai.group!
  351.  
  352. ${group},n: | # remove all clients everywhere from grouping
  353. Rumai.ungroup
  354.  
  355. #---------------------------------------------------------------------------
  356. # swap
  357. #---------------------------------------------------------------------------
  358.  
  359. ${swap},${up}: | # swap with above client
  360. curr_client.swap(:up) rescue nil
  361.  
  362. ${swap},${down}: | # swap with below client
  363. curr_client.swap(:down) rescue nil
  364.  
  365. ${swap},${left}: | # swap with left client
  366. curr_client.swap(:left) rescue nil
  367.  
  368. ${swap},${right}: | # swap with right client
  369. curr_client.swap(:right) rescue nil
  370.  
  371. # swap current client with the column whose index equals the pressed number
  372. ${swap},1: curr_client.swap 1
  373. ${swap},2: curr_client.swap 2
  374. ${swap},3: curr_client.swap 3
  375. ${swap},4: curr_client.swap 4
  376. ${swap},5: curr_client.swap 5
  377. ${swap},6: curr_client.swap 6
  378. ${swap},7: curr_client.swap 7
  379. ${swap},8: curr_client.swap 8
  380. ${swap},9: curr_client.swap 9
  381. ${swap},0: curr_client.swap 10
  382.  
  383. #---------------------------------------------------------------------------
  384. # client
  385. #---------------------------------------------------------------------------
  386.  
  387. ${mod}-f: | # zoom client to fullscreen (toggle)
  388. curr_client.fullscreen!
  389.  
  390. ${mod}-q: | # kill the current client
  391. curr_client.kill
  392.  
  393. #---------------------------------------------------------------------------
  394. # column
  395. #---------------------------------------------------------------------------
  396.  
  397. ${mod}-d: | # apply equal-spacing layout to current column
  398. curr_area.layout = 'default-max'
  399.  
  400. ${mod}-s: | # apply stacked layout to current column
  401. curr_area.layout = 'stack-max'
  402.  
  403. ${mod}-m: | # apply maximized layout to current column
  404. curr_area.layout = 'stack+max'
  405.  
  406. #---------------------------------------------------------------------------
  407. # menu
  408. #---------------------------------------------------------------------------
  409.  
  410. ${mod}-a: | # run internal action chosen from a menu
  411. if choice = key_menu(actions, 'run action:')
  412. action choice
  413. end
  414.  
  415. ${mod}-p: | # run external program chosen from a menu
  416. if choice = key_menu(@programs, 'run program:')
  417. launch choice
  418. end
  419.  
  420. ${mod}-t: | # focus view chosen from a menu
  421. if choice = key_menu(default_tags.merge(existing_tags).to_a, 'show view:')
  422. focus_view choice
  423. end
  424.  
  425. #---------------------------------------------------------------------------
  426. # launcher
  427. #---------------------------------------------------------------------------
  428.  
  429. #${mod}-Return: | # launch a terminal
  430. ${prog}-s: | # launch a terminal
  431. #
  432. # Launch a new terminal and set its
  433. # working directory to be the same
  434. # as the currently focused terminal.
  435. #
  436. work = ENV['HOME']
  437.  
  438. label = curr_client.label.read rescue ''
  439.  
  440. # iterate in reverse order because
  441. # paths are usually at end of label
  442. label.split(' ').reverse_each do |s|
  443. path = File.expand_path(s)
  444.  
  445. if File.exist? path
  446. unless File.directory? path
  447. path = File.dirname(path)
  448. end
  449.  
  450. work = path
  451. break
  452. end
  453. end
  454.  
  455. require 'fileutils'
  456. FileUtils.cd work do
  457. launch CONFIG['program']['terminal']
  458. end
  459.  
  460. ${prog}-w: |
  461. launch CONFIG['program']['browser']
  462.  
  463. ${prog}-e: |
  464. launch CONFIG['program']['filer']
  465.  
  466. ${prog}-l: |
  467. launch CONFIG['program']['lock']
  468.  
  469. ##
  470. # Event handlers.
  471. #
  472. # <event name>: <Ruby code to execute>
  473. #
  474. # The Ruby code has access to an "argv" variable which
  475. # is a list of arguments that were passed to the event.
  476. #
  477. event:
  478. CreateTag: |
  479. tag = argv[0]
  480. but = fs.lbar[tag]
  481. but.create unless but.exist?
  482. but.write "#{CONFIG['display']['color']['normal']} #{tag}"
  483. existing_tags.merge(resolve_namespaces([tag]))
  484. LOG.debug "existing tags: #{existing_tags.to_a}"
  485.  
  486. DestroyTag: |
  487. tag = argv[0]
  488. but = fs.lbar[tag]
  489. but.remove if but.exist?
  490. existing_tags.replace(resolve_namespaces(tags))
  491. LOG.debug "existing tags: #{existing_tags.to_a}"
  492.  
  493. FocusTag: |
  494. tag = argv[0]
  495. but = fs.lbar[tag]
  496. but.write "#{CONFIG['display']['color']['focus']} #{tag}" if but.exist?
  497.  
  498. UnfocusTag: |
  499. tag = argv[0]
  500. but = fs.lbar[tag]
  501. but.write "#{CONFIG['display']['color']['normal']} #{tag}" if but.exist?
  502.  
  503. UrgentTag: |
  504. tag = argv[1]
  505. but = fs.lbar[tag]
  506. but.write "#{CONFIG['display']['color']['notice']} #{tag}" if but.exist?
  507.  
  508. NotUrgentTag: |
  509. tag = argv[1]
  510. but = fs.lbar[tag]
  511. color = curr_view.id == tag ? 'focus' : 'normal'
  512. but.write "#{CONFIG['display']['color'][color]} #{tag}" if but.exist?
  513.  
  514. LeftBarClick: &LeftBarClick |
  515. mouse_button, view_id = argv
  516.  
  517. if mouse_button == '1' # primary button
  518. focus_view view_id
  519. end
  520.  
  521. ##
  522. # allows the user to drag a file over a
  523. # view button and activate that view while
  524. # still holding on to their dragged file!
  525. #
  526. LeftBarDND: *LeftBarClick
  527.  
  528. RightBarClick: |
  529. status_click *argv.reverse
  530.  
  531. ClientMouseDown: |
  532. client_id, mouse_button = argv
  533.  
  534. if mouse_button == '3' # secondary button
  535. client = Client.new(client_id)
  536.  
  537. case click_menu %w[stick group fullscreen kill slay], 'client'
  538. when 'stick' then client.stick!
  539. when 'group' then client.group!
  540. when 'fullscreen' then client.fullscreen!
  541. when 'kill' then client.kill
  542. when 'slay' then client.slay
  543. end
  544. end
  545.  
  546. ##
  547. # Internal scripts.
  548. #
  549. # <action name>: <Ruby code to execute>
  550. #
  551. action:
  552.  
  553.  
  554. ##
  555. # Arbitrary logic.
  556. #
  557. # script:
  558. # before: <Ruby code to execute before processing this file>
  559. # after: <Ruby code to execute after processing this file>
  560. #
  561. script:
  562. before: |
  563. # handle namespaces
  564. require 'set'
  565.  
  566. default_tags = SortedSet.new(['comm:', 'comm:im', 'comm:mail', 'devel:', 'sys:', 'uni:', 'web'])
  567. existing_tags = SortedSet.new
  568.  
  569. def resolve_namespaces(tags)
  570. LOG.debug "resolving namespaces from #{tags}:"
  571. namespaces = Set.new
  572. tags.each do |tag_name|
  573. subtags = tag_name.split(':')
  574. last_subtag = 0
  575. #namespaces
  576. while last_subtag < (subtags.length - 1)
  577. namespaces.add(subtags[0..last_subtag].join(':') + ':')
  578. last_subtag += 1
  579. end
  580. ###FIXME: last splitted element does not have to be bare tag!
  581. ### may be namespace if tag_name ends on ':'!!
  582. #bare tag
  583. namespaces.add(subtags[0..last_subtag].join(':'))
  584. end
  585. LOG.debug "resolved namespaces: #{namespaces.to_a}"
  586. #return namespaces.to_a
  587. return namespaces
  588. end
  589.  
  590. def switch_to_numeric_tag(digit)
  591. if t = tags.grep(/^#{digit}/).first
  592. LOG.debug "tag #{digit} exists: #{t}"
  593. focus_view(t)
  594. elsif choice = key_menu(["#{digit}:"], 'show view:')
  595. focus_view choice
  596. end
  597. end
  598.  
  599. DETACHED_TAG = '|'
  600. ZOOMED_SUFFIX = /~(\d+)$/
  601.  
  602. # keep track of most recently focused view
  603. $last_view = nil
  604.  
  605. class Rumai::View
  606. alias __focus__ focus
  607.  
  608. def focus
  609. $last_view = View.curr
  610. __focus__
  611. end
  612. end
  613.  
  614. after: |
  615. # background image
  616. system 'wmsetbg --back-color gray --center /home/dtk/.wmii/background.png'
  617.  
  618. # clean up
  619. system 'pkill -u dtk -f /etc/X11/wmii/wmiirc'
  620. system 'pkill -u dtk trayer'
  621.  
  622. # autostart
  623. system 'trayer --edge bottom --align right --widthtype pixel --width 130 --height 17 --SetPartialStrut true &'
  624. system 'nm-applet &'
  625. system 'gnome-power-manager &'
  626. system 'gnome-volume-control-applet &'
  627. system 'bluetooth-applet &'
  628. system 'update-notifier &'
  629.  
  630. # make systray sticky
  631. sleep 0.5
  632. trayer_pattern = /panel:trayer:panel/
  633. curr_view.manifest.split("\n").each do |client_descriptor|
  634. if client_descriptor.match(trayer_pattern)
  635. trayer = Client.new(client_descriptor.split()[1])
  636. trayer.stick
  637. end
  638. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement