1 --- Standard awesome library
3 -- Theme handling library
5 -- Notification library
11 function volume (mode
, widget
)
12 if mode
== "update" then
13 local fd
= io
.popen("amixer -c " .. cardid
.. " -- sget " .. channel
)
14 local status
= fd
:read("*all")
17 local volume
= string.match(status
, "(%d?%d?%d)%%")
18 volume
= string.format("% 3d", volume
)
20 status
= string.match(status
, "%[(o[^%]]*)%]")
22 --if string.find(status, "on", 1, true) then
23 volume
= '<span color="white">\tVolume:</span>'.. " [" .. volume
.. " % ]"
25 -- volume = '<span color="white">\tVolume:</span>'.. " [" .. " 0" .. " % ]"
28 elseif mode
== "up" then
29 io
.popen("amixer -q -c " .. cardid
.. " sset " .. channel
.. " 2%+"):read("*all")
30 volume("update", widget
)
31 elseif mode
== "down" then
32 io
.popen("amixer -q -c " .. cardid
.. " sset " .. channel
.. " 2%-"):read("*all")
33 volume("update", widget
)
35 io
.popen("amixer -c " .. cardid
.. " sset " .. channel
.. " toggle"):read("*all")
36 volume("update", widget
)
42 -- {{{ Variable definitions
43 -- Themes define colours, icons, and wallpapers
44 -- The default is a dark theme
45 theme_path
= "/usr/share/awesome/themes/default/theme.lua"
46 -- Uncommment this for a lighter theme
47 -- theme_path = "/usr/share/awesome/themes/sky/theme"
49 -- Actually load theme
50 beautiful
.init(theme_path
)
52 -- This is used later as the default terminal and editor to run.
54 editor
= os
.getenv("EDITOR") or "vim"
55 editor_cmd
= terminal
.. " -e " .. editor
58 -- Usually, Mod4 is the key with a logo between Control and Alt.
59 -- If you do not like this or do not have such a key,
60 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
61 -- However, you can use another modifier like Mod1, but it may interact with others.
64 -- Table of layouts to cover with awful.layout.inc, order matters.
67 awful
.layout
.suit
.tile
, --1
68 --awful.layout.suit.tile.left, --
69 --awful.layout.suit.tile.bottom, --
70 --awful.layout.suit.tile.top, --
71 --awful.layout.suit.fair, --
72 awful
.layout
.suit
.fair
.horizontal
, --2
73 --awful.layout.suit.max, --
74 --awful.layout.suit.max.fullscreen, --
75 awful
.layout
.suit
.magnifier
, --3
76 awful
.layout
.suit
.floating
--4
79 -- Table of clients that should be set floating. The index may be either
80 -- the application class or instance. The instance is useful when running
81 -- a console app in a terminal like (Music on Console)
82 -- xterm -name mocp -e mocp
89 ["File-roller"] = true,
91 ["VirtualBox"] = true,
92 ["buddy_list"] = true,
93 ["conversation"] = true,
94 ["shutdown.rb"] = true,
96 --["Download"] = true, --FF download window
97 ["Extension"] = true, --FF ext. window
98 ["Browser"] = true, --FF settings window
99 ["Places"] = true, --FF bookmarks window
100 ["Toplevel"] = true, --FF other pop-up window
105 -- Applications to be moved to a pre-defined tag by class or instance.
106 -- Use the screen and tags indices.
109 ["Gran Paradiso"] = { screen
= 1, tag = 1 },
110 ["Firefox"] = { screen
= 1, tag = 1 },
111 ["Shiretoko"] = { screen
= 1, tag = 1 },
112 -- ["Terminal"] = { screen = 1, tag = 2 },
113 ["XTerm"] = { screen
= 1, tag = 1 },
114 ["Shredder"] = { screen
= 1, tag = 3 },
115 --["Krusader"] = { screen = 1, tag = 3 },
116 --["Dolphin"] = { screen = 1, tag = 3 },
117 ["Pidgin"] = { screen
= 1, tag = 4 },
118 -- ["Gajim.py"] = { screen = 1, tag = 4 },
119 -- ["mocp"] = { screen = 2, tag = 4 },
120 ["Terminator"] = {screen
= 1, tag = 3}
123 -- Define if we want to use titlebar on all applications.
128 -- Define tags table.
130 mytags
[1] = { name
= "www"}
131 mytags
[2] = { name
= "term"}
132 mytags
[3] = { name
= "mail"}
133 mytags
[4] = { name
= "chat"}
134 mytags
[5] = { name
= "code"}
135 mytags
[6] = { name
= "6"}
138 for s
= 1, screen
.count() do
139 -- Each screen has its own tag table.
141 -- Create 9 tags per screen.
142 for tagnumber
= 1, 6 do
143 -- tags[s][tagnumber] = tag(tagnumber)
144 tags
[s
][tagnumber
] = tag(mytags
[tagnumber
].name
)
145 -- Add tags to screen one by one
146 tags
[s
][tagnumber
].screen
= s
147 awful
.layout
.set(layouts
[1], tags
[s
][tagnumber
])
149 awful
.tag.setmwfact (0.70, tags
[s
][1])
150 awful
.tag.setmwfact (0.60, tags
[s
][3])
151 awful
.layout
.set(layouts
[1], tags
[s
][1])
152 awful
.layout
.set(layouts
[1], tags
[s
][2])
153 awful
.layout
.set(layouts
[1], tags
[s
][3])
154 -- I'm sure you want to see at least one tag.
155 tags
[s
][1].selected
= true
160 -- Create a textbox widget
161 mytextbox
= widget({ type = "textbox", align
= "right" })
162 -- Set the default text in textbox
163 --mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
165 -- Create a laucher widget and a main menu
167 { "manual", terminal
.. " -e man awesome" },
168 { "edit config", editor_cmd
.. " " .. awful
.util
.getdir("config") .. "/rc.lua" },
169 { "restart", awesome
.restart
},
170 { "quit", awesome
.quit
}
173 mymainmenu
= awful
.menu
.new({ items
= { --{ "awesome", myawesomemenu, beautiful.awesome_icon },
174 --{ "Smplayer", "smplayer" },
175 --{ "Gajim", "gajim" },
176 --{ "Pidgin", "pidgin" },
177 --{ "Dolphin", "dolphin" },
178 { "OpenOffice", "soffice" },
180 --{ "Xsane", "xsane" },
181 { "VirtualBox", "VirtualBox" },
182 --{ "Lxappearance", "lxappearance" },
185 mylauncher
= awful
.widget
.launcher({ image
= image(beautiful
.awesome_icon
),
189 -- mysystray = widget({ type = "systray", align = "right" })
191 -- Create a wibox for each screen and add it
196 mytaglist
.buttons
= awful
.util
.table.join(
197 awful
.button({ }, 1, awful
.tag.viewonly
),
198 awful
.button({ modkey
}, 1, awful
.client
.movetotag
),
199 awful
.button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
200 awful
.button({ modkey
}, 3, awful
.client
.toggletag
),
201 awful
.button({ }, 4, awful
.tag.viewnext
),
202 awful
.button({ }, 5, awful
.tag.viewprev
)
205 mytasklist
.buttons
= awful
.util
.table.join(
206 awful
.button({ }, 1, function (c
)
207 if not c
:isvisible() then
208 awful
.tag.viewonly(c
:tags()[1])
213 awful
.button({ }, 3, function ()
218 instance
= awful
.menu
.clients({ width
=250 })
221 awful
.button({ }, 4, function ()
222 awful
.client
.focus
.byidx(1)
223 if client
.focus
then client
.focus
:raise() end
225 awful
.button({ }, 5, function ()
226 awful
.client
.focus
.byidx(-1)
227 if client
.focus
then client
.focus
:raise() end
230 for s
= 1, screen
.count() do
231 -- Create a promptbox for each screen
232 mypromptbox
[s
] = widget({ type = "textbox", align
= "left" })
235 tb_volume
= widget({ type = "textbox", name
= "tb_volume", align
= "right" })
236 tb_volume
:buttons(awful
.util
.table.join(
237 --tb_volume:buttons({
238 awful
.button({ }, 4, function () volume("up", tb_volume
) end),
239 awful
.button({ }, 5, function () volume("down", tb_volume
) end),
240 awful
.button({ }, 1, function () volume("mute", tb_volume
) end)
241 --awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
243 volume("update", tb_volume
)
251 wicked
.register(memwidget
, wicked
.widgets
.mem
, ' <span color="white">\tMemory:</span> [ $2 MB / $3 MB ]', 2)
252 awful
.hooks
.timer
.register(2, mywidget_timer
)
260 wicked
.register(cpuwidget
, wicked
.widgets
.cpu
, ' <span color="white">\tCPU:</span> [ $2 % <span color="white">|</span> $3 % ]', 2)
269 wicked
.register(mpdwidget
, wicked
.widgets
.mpd
,
270 ' <span color="white">Now Playing:</span> [ $1 ]', 5)
280 wicked
.register(fswidget
, wicked
.widgets
.fs
,
281 ' <span color="white">\tFS:</span> [ ${/ avail} / ${/ size} <span color="white">|</span> ${/home avail} / ${/home size} <span color="white">|</span> ${/media/data avail} / ${/media/data size} <span color="white">|</span> ${/media/data2 avail} / ${/media/data2 size} ]'
291 wicked
.register(netwidget
, wicked
.widgets
.net
,
292 ' <span color="white">\tNET:</span> [ ${eth0 down_kb} KB/s / ${eth0 up_kb} KB/s ]', 3)
295 datewidget
= widget({
301 wicked
.register(datewidget
, wicked
.widgets
.date,
302 --' <span color="white">\tClock:</span> [ %H:%M ]', 10)
303 '\t[ <span color="white">%H:%M</span> %d.%m.%y]', 10)
308 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
309 -- We need one layoutbox per screen.
310 mylayoutbox
[s
] = widget({ type = "imagebox", align
= "right" })
311 mylayoutbox
[s
]:buttons(awful
.util
.table.join(
312 awful
.button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
313 awful
.button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
314 awful
.button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
315 awful
.button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end)))
316 -- Create a taglist widget
317 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
319 -- Create a tasklist widget
320 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
321 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
322 end, mytasklist
.buttons
)
325 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
326 -- Add widgets to the wibox - order matters
327 mywibox
[s
].widgets
= { -- mylauncher,
340 -- s == 1 and mysystray or nil
342 mywibox
[s
].screen
= s
346 -- {{{ Mouse bindings
347 root
.buttons(awful
.util
.table.join(
348 awful
.button({ }, 3, function () mymainmenu
:toggle() end),
349 awful
.button({ }, 2, function () awful
.menu
.clients(mymainmenu
) end),
350 awful
.button({ }, 4, awful
.tag.viewnext
),
351 awful
.button({ }, 5, awful
.tag.viewprev
)
356 globalkeys
= awful
.util
.table.join(
357 awful
.key({ modkey
, }, "Left", awful
.tag.viewprev
),
358 awful
.key({ modkey
, }, "Right", awful
.tag.viewnext
),
359 awful
.key({ modkey
, }, "Escape", awful
.tag.history
.restore
),
361 awful
.key({ modkey
, }, "j",
363 awful
.client
.focus
.byidx( 1)
364 if client
.focus
then client
.focus
:raise() end
366 awful
.key({ modkey
, }, "k",
368 awful
.client
.focus
.byidx(-1)
369 if client
.focus
then client
.focus
:raise() end
371 --awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
373 -- Layout manipulation
374 awful
.key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx( 1) end),
375 awful
.key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx( -1) end),
376 awful
.key({ modkey
, "Control" }, "j", function () awful
.screen
.focus( 1) end),
377 awful
.key({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end),
378 awful
.key({ modkey
, }, "u", awful
.client
.urgent
.jumpto
),
379 awful
.key({ modkey
, }, "Tab",
381 awful
.client
.focus
.history
.previous()
388 awful
.key({ modkey
, }, "Return", function () awful
.util
.spawn(terminal
) end),
389 awful
.key({ modkey
, "Control" }, "r", awesome
.restart
),
390 -- awful.key({ modkey, "Shift" }, "q", awesome.quit),
392 awful
.key({ modkey
, }, "l", function () awful
.tag.incmwfact( 0.05) end),
393 awful
.key({ modkey
, }, "h", function () awful
.tag.incmwfact(-0.05) end),
394 awful
.key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster( 1) end),
395 awful
.key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end),
396 awful
.key({ modkey
, "Control" }, "h", function () awful
.tag.incncol( 1) end),
397 awful
.key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end),
398 awful
.key({ modkey
, }, "space", function () awful
.layout
.inc(layouts
, 1) end),
399 awful
.key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end),
401 awful
.key({ modkey
, }, "F1", function () awful
.util
.spawn("firefox") end),
402 --awful.key({ modkey, }, "F2", function () awful.util.spawn("thunderbird") end),
403 awful
.key({ modkey
, }, "F3", function () awful
.util
.spawn("pidgin") end),
404 awful
.key({ modkey
, }, "F4", function () awful
.util
.spawn("smplayer") end),
405 -- awful.key({ modkey, }, "F5", function () awful.util.spawn("ruby /home/cinan/skripty/shutdown.rb") end),
406 awful
.key({ modkey
, }, "z", function () awful
.util
.spawn("mpc prev") end),
407 awful
.key({ modkey
, }, "x", function () awful
.util
.spawn("mpc play") end),
408 awful
.key({ modkey
, }, "c", function () awful
.util
.spawn("mpc toggle") end),
409 awful
.key({ modkey
, }, "v", function () awful
.util
.spawn("mpc stop") end),
410 awful
.key({ modkey
, }, "b", function () awful
.util
.spawn("mpc next") end),
411 awful
.key({ "Mod1", }, "j", function () awful
.util
.spawn("amixer -q sset Master 2%-") end, function () volume("update", tb_volume
) end),
412 awful
.key({ "Mod1", }, "k", function () awful
.util
.spawn("amixer -q sset Master 2%+") end, function () volume("update", tb_volume
) end),
413 awful
.key({ modkey
, "Shift" }, "q", function () awful
.util
.spawn("xkill") end),
414 awful
.key({ modkey
, }, "XF86PowerOff", function () awful
.util
.spawn("sudo halt") end),
415 awful
.key({ modkey
, }, "XF86Standby", function () awful
.util
.spawn("sudo pm-suspend") end),
418 awful
.key({ "Mod1" }, "F2",
420 awful
.prompt
.run({ prompt
= "Run: " },
421 mypromptbox
[mouse
.screen
],
422 awful
.util
.spawn
, awful
.completion
.shell
,
423 awful
.util
.getdir("cache") .. "/history")
425 awful
.key({ "Mod1", }, "F3", function () awful
.util
.spawn("gnome-terminal") end)
426 --awful.key({ modkey }, "x",
428 -- awful.prompt.run({ prompt = "Run Lua code: " },
429 -- mypromptbox[mouse.screen],
430 -- awful.util.eval, nil,
431 -- awful.util.getdir("cache") .. "/history_eval")
435 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
436 clientkeys
= awful
.util
.table.join(
437 awful
.key({ modkey
, }, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end),
438 awful
.key({ "Mod1" }, "F4", function (c
) c
:kill() end),
439 awful
.key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
),
440 awful
.key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end),
441 awful
.key({ modkey
, }, "o", awful
.client
.movetoscreen
),
442 awful
.key({ modkey
, "Shift" }, "r", function (c
) c
:redraw() end),
443 awful
.key({ modkey
}, "t", awful
.client
.togglemarked
),
444 awful
.key({ modkey
,}, "m",
446 c
.maximized_horizontal
= not c
.maximized_horizontal
447 c
.maximized_vertical
= not c
.maximized_vertical
451 -- Compute the maximum number of digit we need, limited to 9
453 for s
= 1, screen
.count() do
454 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
457 for i
= 1, keynumber
do
458 table.foreach(awful
.key({ modkey
}, i
,
460 local screen
= mouse
.screen
461 if tags
[screen
][i
] then
462 awful
.tag.viewonly(tags
[screen
][i
])
464 end), function(_
, k
) table.insert(globalkeys
, k
) end)
465 table.foreach(awful
.key({ modkey
, "Control" }, i
,
467 local screen
= mouse
.screen
468 if tags
[screen
][i
] then
469 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
471 end), function(_
, k
) table.insert(globalkeys
, k
) end)
472 table.foreach(awful
.key({ modkey
, "Shift" }, i
,
474 if client
.focus
and tags
[client
.focus
.screen
][i
] then
475 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
476 awful
.tag.viewonly(tags
[client
.focus
.screen
][i
])
478 end), function(_
, k
) table.insert(globalkeys
, k
) end)
479 table.foreach(awful
.key({ modkey
, "Control", "Shift" }, i
,
481 if client
.focus
and tags
[client
.focus
.screen
][i
] then
482 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
484 end), function(_
, k
) table.insert(globalkeys
, k
) end)
485 table.foreach(awful
.key({ modkey
, "Shift" }, "F" .. i
,
487 local screen
= mouse
.screen
488 if tags
[screen
][i
] then
489 for k
, c
in pairs(awful
.client
.getmarked()) do
490 awful
.client
.movetotag(tags
[screen
][i
], c
)
492 awful
.tag.viewonly(tags
[screen
][i
])
494 end), function(_
, k
) table.insert(globalkeys
, k
) end)
498 root
.keys(globalkeys
)
502 -- Hook function to execute when focusing a client.
503 awful
.hooks
.focus
.register(function (c
)
504 if not awful
.client
.ismarked(c
) then
505 c
.border_color
= beautiful
.border_focus
509 -- Hook function to execute when unfocusing a client.
510 awful
.hooks
.unfocus
.register(function (c
)
511 if not awful
.client
.ismarked(c
) then
512 c
.border_color
= beautiful
.border_normal
516 -- Hook function to execute when marking a client
517 awful
.hooks
.marked
.register(function (c
)
518 c
.border_color
= beautiful
.border_marked
521 -- Hook function to execute when unmarking a client.
522 awful
.hooks
.unmarked
.register(function (c
)
523 c
.border_color
= beautiful
.border_focus
526 -- Hook function to execute when the mouse enters a client.
527 awful
.hooks
.mouse_enter
.register(function (c
)
528 -- Sloppy focus, but disabled for magnifier layout
529 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
530 and awful
.client
.focus
.filter(c
) then
535 -- Hook function to execute when a new client appears.
536 awful
.hooks
.manage
.register(function (c
, startup
)
537 -- If we are not managing this application at startup,
538 -- move it to the screen where the mouse is.
539 -- We only do it for filtered windows (i.e. no dock, etc).
540 if not startup
and awful
.client
.focus
.filter(c
) then
541 c
.screen
= mouse
.screen
546 awful
.titlebar
.add(c
, { modkey
= modkey
})
548 -- Add mouse bindings
549 c
:buttons(awful
.util
.table.join(
550 awful
.button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
551 awful
.button({ modkey
}, 1, awful
.mouse
.client
.move
),
552 awful
.button({ modkey
}, 3, awful
.mouse
.client
.resize
)
554 -- New client may not receive focus
555 -- if they're not focusable, so set border anyway.
556 c
.border_width
= beautiful
.border_width
557 c
.border_color
= beautiful
.border_normal
559 -- Check if the application should be floating.
561 local inst
= c
.instance
563 if floatapps
[cls
] then
564 awful
.client
.floating
.set(c
, floatapps
[cls
])
565 elseif floatapps
[inst
] then
566 awful
.client
.floating
.set(c
, floatapps
[inst
])
567 elseif floatapps
[role
] then
568 awful
.client
.floating
.set(c
, floatapps
[role
])
571 -- Check application->screen/tag mappings.
574 target
= apptags
[cls
]
575 elseif apptags
[inst
] then
576 target
= apptags
[inst
]
579 c
.screen
= target
.screen
580 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
583 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
589 -- Set the windows at the slave,
590 -- i.e. put it at the end of others instead of setting it master.
591 --awful.client.setslave(c)
593 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
594 c
.size_hints_honor
= false
595 -- 'smart' placement for floating apps
596 -- open openoffice shit windows under mouse
597 if c
.class
== "OpenOffice.org 3.1" then
598 awful
.placement
.under_mouse(c
)
600 awful
.placement
.centered(c
)
602 --if c.class == "Gran Paradiso" or c.class == "Shredder" or c.class == "Firefox" then
603 --if c.class == "Firefox" and c.role == "browser" then --firefox main window
604 if c
.class
== "Shiretoko" and c
.role
== "browser" then --firefox main window
605 awful
.client
.setmaster(c
)
607 awful
.client
.setslave(c
)
609 if c
.role
== "buddy_list" then --pidgin buddy list
610 c
:geometry({ x
= 0, y
= 15, width
= 177, height
= 1035 })
612 --if c.class == "conversation" then --pidgin conversation
613 -- urgent.add (c, prop)
620 -- Hook function to execute when arranging the screen.
621 -- (tag switch, new client, etc)
622 awful
.hooks
.arrange
.register(function (screen
)
623 --local layout = awful.layout.getname(awful.layout.get(screen))
624 --if layout and beautiful["layout_" ..layout] then
625 -- mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
627 -- mylayoutbox[screen].image = nil
630 -- Give focus to the latest client in history if no window has focus
631 -- or if the current window is a desktop or a dock one.
632 if not client
.focus
then
633 local c
= awful
.client
.focus
.history
.get(screen
, 0)
634 if c
then client
.focus
= c
end
638 -- Hook called every minute
639 --awful.hooks.timer.register(60, function ()
640 -- mytextbox.text = os.date(" %a %b %d, %H:%M ")
644 os
.execute("/home/cinan/skripty/autostart.sh &")