README update to modify config.mk when installing submodules
[wmiirc-lua.git] / src / wmiirc.lua.in
blobec14a036ae6fd72ebd53620fa7e4dfa2f3accd67
1 #!/usr/bin/env lua
2 --
3 -- Copyrigh (c) 2007, Bart Trojanowski <bart@jukie.net>
4 --
5 -- Some stuff below will eventually go to a separate file, and configuration
6 -- will remain here similar to the split between the wmii+ruby wmiirc and
7 -- wmiirc-config. For now I just want to get the feel of how things will
8 -- work in lua.
9 --
10 -- http://www.jukie.net/~bart/blog/tag/wmiirc-lua
11 -- git://www.jukie.net/wmiirc-lua.git/
14 io.stderr:write ("----------------------------------------------\n")
16 -- load wmii.lua
17 local wmiidir = ("%HOME_WMII%"):gsub("^~", os.getenv("HOME"))
18 package.path = wmiidir .. "/core/?.lua;" ..
19 wmiidir .. "/plugins/?.lua;" ..
20 package.path
21 require "wmii"
22 require "os"
24 -- Setup my environment (completely optional)
26 local hostname = os.getenv("HOSTNAME")
27 local homedir = os.getenv("HOME") or "~"
29 --[[
30 -- conditionally load up my xmodmaprc
31 if type(hostname) == 'string' and hostname:match("^oxygen") then
32 os.execute ("xmodmap ~/.xmodmaprc")
33 end
35 -- add ssh keys if they are not in the agent already
36 os.execute ("if ( ! ssh-add -l >/dev/null ) || test $(ssh-add -l | wc -l) = 0 ; then "
37 .. "ssh-add </dev/null ; fi")
39 -- this lets me have progyfonts in ~/.fonts
40 os.execute ("~/.fonts/rebuild")
42 -- restore the mixer settings
43 os.execute ("aumix -L")
45 -- this hids the mouse cursor after a timeout
46 os.execute ("unclutter &")
48 -- configure X
49 os.execute ("xset r on")
50 os.execute ("xset r rate 200 25")
51 os.execute ("xset b off")
52 os.execute ("xrandr --dpi 96")
54 -- clear the background
55 os.execute ("xsetroot -solid black")
57 -- this will prime the alt-p menu's cache
58 os.execute ("dmenu_path>/dev/null&")
59 --]]
61 -- This is the base configuration of wmii, it writes to the /ctl file.
62 wmii.set_ctl ({
63 border = 1,
64 font = '-windows-proggytiny-medium-r-normal--10-80-96-96-c-60-iso8859-1',
65 focuscolors = '#FFFFaa #007700 #88ff88',
66 normcolors = '#FFFFFF #222222 #333333',
67 grabmod = 'Mod1'
70 -- Set slightly different colors on each screen.
71 wmii.set_screen_ctl(0, {
72 focuscolors = '#FFFFaa #007700 #88ff88'
74 wmii.set_screen_ctl(1, {
75 focuscolors = '#FFFFaa #770000 #ff8888'
77 wmii.set_screen_ctl(2, {
78 focuscolors = '#FFFFaa #000077 #8888ff'
81 -- This overrides some variables that are used by event and key handlers.
82 -- TODO: need to have a list of the standard ones somewhere.
83 -- For now look in the wmii.lua for the key_handlers table, it
84 -- will reference the variables as getconf("varname").
85 -- If you add your own actions, or key handlers you are encouraged to
86 -- use configuration values as appropriate with wmii.setconf("var", "val"), or
87 -- as a table like the example below.
88 wmii.set_conf ({
89 xterm = 'x-terminal-emulator',
90 -- xlock = '/usr/bin/xtrlock',
91 -- debug = true,
94 -- colrules file contains a list of rules which affect the width of newly
95 -- created columns. Rules have a form of
96 -- /regexp/ -> width[+width[+width...]]
97 -- When a new column, n, is created on a view whose name matches regex, the
98 -- n'th given width percentage of the screen is given to it. If there is
99 -- no nth width, 1/ncolth of the screen is given to it.
101 wmii.write ("/colrules", "/.*/ -> 50+50\n"
102 .. "/gaim/ -> 80+20\n")
104 -- tagrules file contains a list of riles which affect which tags are
105 -- applied to a new client. Rules has a form of
106 -- /regexp/ -> tag[+tag[+tag...]]
107 -- When client's name:class:title matches regex, it is given the
108 -- tagstring tag(s). There are two special tags:
109 -- sel (or the deprecated form: !) represents the current tag, and
110 -- ~ which represents the floating layer
111 wmii.write ("/tagrules", "/XMMS.*/ -> ~\n"
112 .. "/Firefox.*/ -> www\n"
113 .. "/Iceweasel.*/ -> www\n"
114 .. "/vimperator/ -> www\n"
115 .. "/a[Kk]regator/ -> www\n"
116 .. "/Gimp.*/ -> ~\n"
117 .. "/Gimp.*/ -> gimp\n"
118 .. "/Gaim.*/ -> gaim\n"
119 .. "/gitk/ -> ~\n"
120 .. "/MPlayer.*/ -> ~\n"
121 .. "/x?vnc[^ ]*viewer.*/ -> ~\n"
122 .. "/VNC.*:VNC.*/ -> ~\n"
123 .. "/.*/ -> sel\n"
124 .. "/.*/ -> 1\n")
126 -- load some plugins
127 wmii.load_plugin ("messages")
128 wmii.load_plugin ("clock")
129 wmii.load_plugin ("loadavg")
130 wmii.load_plugin ("volume")
131 wmii.load_plugin ("browser")
132 wmii.load_plugin ("view_workdir")
133 wmii.load_plugin ("cpu")
135 wmii.load_plugin ("battery")
136 wmii.set_conf("battery.names", "BAT0")
138 wmii.load_plugin ("ssh")
139 wmii.add_key_handler ("Mod1-z", ssh.show_menu)
141 -- other handlers
143 wmii.add_key_handler ('XF86KbdBrightnessUp', function (key) os.execute("xbacklight -steps 1 -time 0 -inc 10") end)
144 wmii.add_key_handler ('XF86KbdBrightnessDown', function (key) os.execute("xbacklight -steps 1 -time 0 -dec 10") end)
146 wmii.add_action_handler ("hibernate-disk",
147 function(act,args)
148 os.execute ('gksudo hibernate-disk')
149 end)
153 -- here are some other examples...
154 --[[
156 -- use Mod1-tab to flip to the previous view
157 wmii.remap_key_handler ("Mod1-r", "Mod1-tab")
159 --]]
161 -- ------------------------------------------------------------------------
162 -- configuration is finished, run the event loop
163 wmii.run_event_loop()