-- Standard awesome library require("awful") require("awful.autofocus") require("awful.rules") -- Theme handling library require("beautiful") -- Notification library require("naughty") -- cleanup os.execute("killall asyncfifo") os.execute("killall conky") -- pre autostart --os.execute("xmodmap /home/thorsten/.xmodmaprc &") os.execute("cd "..os.getenv("HOME").."/.conky/awesome-statbar/ && ./asyncfifo infifo outfifo &") os.execute("cd "..os.getenv("HOME").."/.conky/awesome-statbar/ && conky -c toawesome.conky &") -- {{{ Variable definitions -- Themes define colours, icons, and wallpapers --theme_path = "/home/thorsten/.config/awesome/themes/grey/theme.lua" --theme_path = "/home/thorsten/.config/awesome/themes/pink/theme.lua" theme_path = "/home/thorsten/.config/awesome/themes/greenterm/theme.lua" --beautiful.init("/usr/share/awesome/themes/default/theme.lua") beautiful.init(theme_path) config_path = "/home/thorsten/.config/awesome/" -- This is used later as the default terminal and editor to run. terminal = "roxterm" editor = os.getenv("EDITOR") or "vim" editor_cmd = terminal .. " -e " .. editor -- Default modkey. -- Usually, Mod4 is the key with a logo between Control and Alt. -- If you do not like this or do not have such a key, -- I suggest you to remap Mod4 to another key using xmodmap or other tools. -- However, you can use another modifier like Mod1, but it may interact with others. modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. layouts = { awful.layout.suit.tile, awful.layout.suit.tile.left, awful.layout.suit.tile.bottom, awful.layout.suit.tile.top, awful.layout.suit.fair, awful.layout.suit.fair.horizontal, awful.layout.suit.spiral, awful.layout.suit.spiral.dwindle, awful.layout.suit.max, awful.layout.suit.max.fullscreen, awful.layout.suit.magnifier, awful.layout.suit.floating } -- }}} g_szHome = os.getenv("HOME") g_szScriptDir = g_szHome .. "/scripts/" g_rgColorTheme = { fg = "#fefefe", -- fg bg = "#202020", -- bg highlight_fg = "#CF6171", -- highlighted fg highlight_bg = "#444444", -- highlighted bg pink = "#FF00A8", -- another type of pink cyan = "#0DD2E5", -- some type of cyan green = "#B1D631", -- green widget_label = "#0DD2E5", -- some type of cyan widget_value = "#B1D631", -- green widget_other = "#eeeeee", -- another type of pink } -- own functions g_fExecScript = function (cmd) -- awful.util.spawn(g_szScriptDir .. "/" .. cmd) os.execute(g_szScriptDir .. "/" .. cmd .. " &") end g_fExec = function (cmd) --awful.util.spawn(cmd) os.execute(cmd .. " &") end function evaluate_cmd(cmd) pipe = io.popen(cmd, "r") output = pipe:read("*all") pipe:close() return output end function g_fIncOpacity(c) if c.opacity < 0.9 then c.opacity = c.opacity + 0.1 else c.opacity = 1 end end function g_fDecOpacity(c) -- print ("Decreasing opacity .. it is currently " .. c.opacity .. "") if c.opacity < 0 then c.opacity = 1 end if c.opacity > 0.1 then c.opacity = c.opacity - 0.1 end if c.opacity == 1 then c.opacity = 0.9 end end -- {{{ Tags -- Define a tag table which hold all screen tags. tags = {} for s = 1, screen.count() do -- Each screen has its own tag table. --tags[s] = awful.tag({ 1, 2, "3:vid", "4:dev", "5:doc", "6:www", "7:im", "8:irc", "9:mail" }, s, awful.layout.suit.tile) tags[s] = awful.tag({ "α", "β", "γ", "δ", "ε", "ζ", "λ", "φ", "ξ" }, s, awful.layout.suit.tile) --tags[s] = awful.tag({ 1, 2, "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.suit.tile) -- fullscreen (with taskbar) for browser awful.layout.set(awful.layout.suit.max, tags[s][6]) -- set layout for pidgin tag (7) awful.layout.set(awful.layout.suit.tile.left, tags[s][7]) awful.tag.setmwfact(0.15, tags[s][7]) -- set buddy-list size to 15% awful.tag.setncol(2, tags[s][7]) -- show 2 columns with chats by default -- set vertical layout for irc client awful.layout.set(awful.layout.suit.tile.bottom, tags[s][8]) end -- }}} -- {{{ Menu -- Create a laucher widget and a main menu myawesomemenu = { { "manual", terminal .. " -e man awesome" }, { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" }, { "restart", awesome.restart }, { "quit", awesome.quit } } mysystemmenu = { { "suspend2ram", "sudo /usr/sbin/pm-suspend" }, { "suspend2disk", "sudo /usr/sbin/pm-hibernate" }, { "reboot", "echo reboot not implemented yet" }, { "shutdown", "echo shutdown not implemented yet" } } mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, nil }, { "system", mysystemmenu, nil }, { "open terminal", terminal } } }) mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), menu = mymainmenu }) -- Create a laucher widget and a main menu -- }}} -- {{{ Wibox -- Create a textclock widget mytextclock = awful.widget.textclock({align = "right" }, " %Y-%m-%d, %H:%M ", 10) -- Create a systray mysystray = widget({ type = "systray" }) -- Create a wibox for each screen and add it mywibox = {} mypromptbox = {} mylayoutbox = {} mytaglist = {} mytaglist.buttons = awful.util.table.join( awful.button({ }, 1, awful.tag.viewonly), awful.button({ modkey }, 1, awful.client.movetotag), awful.button({ }, 3, awful.tag.viewtoggle), awful.button({ modkey }, 3, awful.client.toggletag), awful.button({ }, 4, awful.tag.viewnext), awful.button({ }, 5, awful.tag.viewprev) ) mytasklist = {} mytasklist.buttons = awful.util.table.join( awful.button({ }, 1, function (c) if not c:isvisible() then awful.tag.viewonly(c:tags()[1]) end client.focus = c c:raise() end), awful.button({ }, 3, function () if instance then instance:hide() instance = nil else instance = awful.menu.clients({ width=250 }) end end), awful.button({ }, 4, function () awful.client.focus.byidx(1) if client.focus then client.focus:raise() end end), awful.button({ }, 5, function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end)) for s = 1, screen.count() do -- Create a promptbox for each screen mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }) -- Create an imagebox widget which will contains an icon indicating which layout we're using. -- We need one layoutbox per screen. mylayoutbox[s] = awful.widget.layoutbox(s) mylayoutbox[s]:buttons(awful.util.table.join( awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) -- Create a taglist widget mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons) -- Create a tasklist widget mytasklist[s] = awful.widget.tasklist(function(c) return awful.widget.tasklist.label.currenttags(c, s) end, mytasklist.buttons) -- Create the wibox mywibox[s] = awful.wibox({ height = 16, position = "top", screen = s }) -- tw --imageleftcorner = widget({ type = "imagebox" }) --imageleftcorner.image = image(config_path .. "leftcorner.png"); --imagerightcorner = widget({ type = "imagebox" }) --imagerightcorner.image = image(config_path .. "rightcorner.png"); -- Add widgets to the wibox - order matters mywibox[s].widgets = { { --imageleftcorner, mylauncher, mytaglist[s], mypromptbox[s], layout = awful.widget.layout.horizontal.leftright }, --imagerightcorner, mylayoutbox[s], s == 1 and mysystray or nil, --mytextclock, mytasklist[s], layout = awful.widget.layout.horizontal.rightleft } end -- }}} dofile( "/home/thorsten/.conky/awesome-statbar/table.save-0.94.lua" ) dofile("/home/thorsten/.config/awesome/okaywidgets.lua") -- {{{ Create a Wibox at the bottom bottomwibox = awful.wibox({ height = 16, position = "bottom", screen = 1}) --statbox = widget({ type = "textbox", align = "right", name = "statbox" }) --statbox.text = "foobar" ow_settings.data_table = { cpu = "23%", cpu_prog = 0.1, mem = "31 MB" } bottomwibox.widgets = { { -- align left ow_create_label((os.getenv("USER") or "?").."@"..evaluate_cmd("hostname")), ow_create_label(evaluate_cmd("uname -r")), ow_create_label("cpu:"), ow_create_progressbar("cpu_prog", 40), ow_create_text("cpu_text", 33), --ow_create_progressbar("cpu_prog2", 40), --ow_create_text("cpu_text2", 35), ow_create_label("mem:"), ow_create_progressbar("mem_prog", 40), ow_create_text("mem", 60), ow_create_label("uptime:"), ow_create_text("uptime", 80), ow_create_label("mmmmmm"), ow_create_label("[][][]"), layout = awful.widget.layout.horizontal.leftright }, -- align right mytextclock, layout = awful.widget.layout.horizontal.rightleft } --ow_start_timer() --os.execute("mkfifo /home/thorsten/.config/awesome/conkyfifo") function updateConkyTable() -- do something --if false then local file = assert(io.open("/home/thorsten/.conky/awesome-statbar/outfifo", "r")) file_content = file:read("*all") data_table = table.load(file_content) if not data_table then -- return if there is no table yet return end -- do some transformations data_table.cpu_text = data_table.cpu.."%" data_table.cpu_prog = data_table.cpu/100.0 --data_table.cpu_text1 = data_table.cpu1.."% " --data_table.cpu_prog1 = data_table.cpu1/100.0 --data_table.cpu_text2 = data_table.cpu2.."%" --data_table.cpu_prog2 = data_table.cpu2/100.0 data_table.mem_prog = data_table.memperc/100.0 ow_settings.data_table = data_table --print ("value: "..ow_settings.data_table["uptime"]) ow_redraw_all() --statbox.text = " uptime: "..conkytable.uptime.."; battery: "..conkytable.bat.."; cpu: "..conkytable.cpu file:close() --end end conkytimer = timer({timeout = 3}) conkytimer:add_signal("timeout", updateConkyTable) conkytimer:start() -- }}} -- {{{ Mouse bindings root.buttons(awful.util.table.join( awful.button({ }, 3, function () mymainmenu:toggle() end), awful.button({ }, 4, awful.tag.viewnext), awful.button({ }, 5, awful.tag.viewprev) )) -- }}} -- wegen Hrym in #awesome auf oftc.net ~ean@h152n2fls308o1036.telia.com function closeLastNaughtyMsg() screen = 1 -- destroy first notification, that is found for p,pos in pairs(naughty.notifications[screen]) do for i,n in pairs(naughty.notifications[screen][p]) do naughty.destroy(n) break end end end -- {{{ Key bindings globalkeys = awful.util.table.join( awful.key({ modkey, }, "u", awful.tag.viewprev ), -- tw awful.key({ modkey, }, "o", awful.tag.viewnext ), -- tw awful.key({ modkey, }, "Escape", awful.tag.history.restore), awful.key({ modkey, }, "j", function () awful.client.focus.byidx( 1) if client.focus then client.focus:raise() end end), awful.key({ modkey, }, "k", function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end), awful.key({ modkey, }, "F2", function () mymainmenu:show(true) end), -- tw -- Layout manipulation awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end), awful.key({ modkey, }, "i", awful.client.urgent.jumpto), awful.key({ modkey, }, "Tab", function () awful.client.focus.history.previous() if client.focus then client.focus:raise() end end), awful.key({ modkey, "Shift" }, "Tab", function () local allclients = awful.client.visible(client.focus.screen) for i,v in ipairs(allclients) do allclients[1]:swap(allclients[i]) end client.focus = awful.client.getmaster() awful.client.getmaster():raise() end), -- for mpd awful.key({ modkey, }, "q", function () g_fExecScript("mpd/dmenu.sh play") end), awful.key({ modkey, "Shift" }, "q", function () g_fExecScript("mpd/dmenu.sh enqueue") end), awful.key({ modkey, }, "w", function () g_fExecScript("mpd/dmenu.sh totem") end), awful.key({ modkey, }, "t", function () g_fExecScript("utils/iptv/watch-dmenu.sh") end), awful.key({ modkey, "Mod1" }, "z", function () g_fExecScript("mpd/mpc.sh -q random") end), awful.key({ modkey, "Mod1" }, "u", function () g_fExecScript("mpd/mpc.sh -q prev") end), awful.key({ modkey, "Mod1" }, "i", function () g_fExecScript("mpd/mpc.sh -q toggle") end), awful.key({ modkey, "Mod1" }, "o", function () g_fExecScript("mpd/mpc.sh -q next") end), awful.key({ modkey, }, "z", function () g_fExecScript("mpd/mpc.sh -q prev") end), awful.key({ modkey, }, "c", function () g_fExecScript("mpd/mpc.sh -q toggle") end), awful.key({ modkey, }, "b", function () g_fExecScript("mpd/mpc.sh -q next") end), -- some menus awful.key({ modkey, }, "x", function () g_fExecScript("menu/custommenu.sh apps") end), awful.key({ modkey, }, "e", function () g_fExec("thunar") end), awful.key({ modkey, "Shift" }, "e", function () g_fExecScript("browser/vimprobable.sh history") end), awful.key({ modkey, }, "F12", closeLastNaughtyMsg), awful.key({ modkey, }, "p", function () g_fExecScript("utils/setbrightness.sh up") end), awful.key({ modkey, }, "odiaeresis", function () g_fExecScript("utils/setbrightness.sh down") end), -- Standard program awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), awful.key({ modkey, "Control" }, "r", awesome.restart), awful.key({ modkey, "Control" }, "q", function () g_fExecScript("logout-dialog.sh") end), awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end), -- Prompt awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), awful.key({ modkey, "Shift" }, "x", function () awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen].widget, awful.util.eval, nil, awful.util.getdir("cache") .. "/history_eval") end) ) clientkeys = awful.util.table.join( awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), awful.key({ modkey, }, "udiaeresis", g_fIncOpacity), awful.key({ modkey, }, "adiaeresis", g_fDecOpacity), awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end), awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), awful.key({ modkey, "Control", "Shift" }, "space", function (c) awful.client.floating.set(c, not awful.client.floating.get(c)) end), -- tw: from wiki awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), awful.key({ modkey, "Shift" }, "p", awful.client.movetoscreen ), awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end), awful.key({ modkey, "Shift" }, "n", function (c) c.minimized = not c.minimized end), awful.key({ modkey, "Shift" }, "Right", function (c) local delta = 1 local selectedindex = 1 for i,t in ipairs(tags[client.focus.screen]) do if t == c:tags()[1] then selectedindex = i end end selectedindex = selectedindex + delta local newindex = awful.util.cycle(#(tags[client.focus.screen]), selectedindexdelta) awful.client.movetotag(tags[client.focus.screen][newindex], c) end), awful.key({ modkey, }, "m", function (c) c.maximized_horizontal = not c.maximized_horizontal c.maximized_vertical = not c.maximized_vertical end) ) -- Compute the maximum number of digit we need, limited to 9 keynumber = 0 for s = 1, screen.count() do keynumber = math.min(9, math.max(#tags[s], keynumber)); end -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it works on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, keynumber do globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey }, "#" .. i + 9, function () local screen = mouse.screen if tags[screen][i] then awful.tag.viewonly(tags[screen][i]) end end), awful.key({ modkey, "Control" }, "#" .. i + 9, function () local screen = mouse.screen if tags[screen][i] then awful.tag.viewtoggle(tags[screen][i]) end end), awful.key({ modkey, "Shift" }, "#" .. i + 9, function () if client.focus and tags[client.focus.screen][i] then awful.client.movetotag(tags[client.focus.screen][i]) end end), awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function () if client.focus and tags[client.focus.screen][i] then awful.client.toggletag(tags[client.focus.screen][i]) end end)) end -- clients clientbuttons = awful.util.table.join( awful.button({ }, 1, function (c) client.focus = c; c:raise() end), awful.button({ modkey }, 1, awful.mouse.client.move), awful.button({ modkey }, 3, awful.mouse.client.resize)) -- Set keys root.keys(globalkeys) -- }}} -- keychains for browser --keychain_browser = {} --function keychain_browser_add() -- for k, v in pairs(keychain_browser) do -- v:add() -- end --end -- --function keychain_browser_remove() -- for k, v in pairs(keychain_browser) do -- v:remove() -- end --end -- --table.insert(keychain_browser, keybinding({}, "h", function () -- g_fExecScript("browser/vimprobable.sh history") -- keychain_browser_remove() --end)) -- --table.insert(keybind_ctrl_f, keybinding({ "Mod4" }, "b", function () -- g_fExecScript("browser/vimprobable.sh bookmarks") -- keychain_browser_remove() --end)) -- --table.insert(keychain_browser, keybinding({}, "Escape", keychain_browser_remove)) -- --keybinding({ "Control" }, "f", keychain_browser_add):add() -- {{{ Rules awful.rules.rules = { -- All clients will match this rule. { rule = { }, properties = { border_width = beautiful.border_width, border_color = beautiful.border_normal, focus = false, keys = clientkeys, buttons = clientbuttons } }, --{ rule = { class = "MPlayer" }, -- properties = { floating = true } }, --{ rule = { class = "pinentry" }, -- properties = { floating = true } }, --{ rule = { class = "gimp" }, -- properties = { floating = true } }, -- Set Firefox to always map on tags number 2 of screen 1. -- { rule = { class = "Firefox" }, -- properties = { tag = tags[1][2] } }, { rule = { class = "Totem" }, properties = { tag = tags[1][3] } }, { rule = { class = "Vlc" }, properties = { tag = tags[1][3] } }, { rule = { class = "Firefox" }, properties = { tag = tags[1][6] } }, { rule = { class = "vimprobable" }, properties = { tag = tags[1][6] } }, { rule = { class = "Pidgin" }, properties = { tag = tags[1][7] } }, { rule = { class = "Sylpheed" }, properties = { tag = tags[1][9] } }, { rule = { class = "MPlayer" }, properties = { tag = tags[1][3] } }, { rule = { name = "Beenden bestätigen" }, properties = { floating = true, focus = true } }, --{ rule = { name = "NCMPC" }, --properties = { tag = tags[1][9] } }, ---- some sdl -games { rule = { class = "xmoto" }, properties = { fullscreen = true } }, } -- }}} -- {{{ Signals -- Signal function to execute when a new client appears. client.add_signal("manage", function (c, startup) -- Add a titlebar -- awful.titlebar.add(c, { modkey = modkey }) c.size_hints_honor = false -- tw: don't respect size hints -- Enable sloppy focus c:add_signal("mouse::enter", function(c) if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier and awful.client.focus.filter(c) then client.focus = c end end) --if not startup then -- Set the windows at the slave, -- i.e. put it at the end of others instead of setting it master. --if not c.client.name == "Buddy-Liste" then -- statbox.text = c.client.name --end --if not c.client.name == "Buddy-Liste" then awful.client.setslave(c) -- tw: set all windows slave --end -- Put windows in a smart way, only if they does not set an initial position. if not c.size_hints.user_position and not c.size_hints.program_position then awful.placement.no_overlap(c) awful.placement.no_offscreen(c) end --end c.skiptaskbar = true c.skiptaskbar = false -- tw: it was uncommented in tag.lua in capi.client.add_signal("manage".. : 377 --awful.tag.withcurrent(c, startup) -- tw: we unkommented it in tag.lua:377 -- tw if no window is focused... focus this one OR if layout is max(imized) if client.focus == nil or awful.layout.get(c.screen) == awful.layout.suit.max then client.focus = c end -- Add a titlebar to each floating client -- if awful.client.floating.get(c) -- or awful.layout.get(c.screen) == awful.layout.suit.floating then -- if not c.titlebar then -- awful.titlebar.add(c, {modkey = modkey}) -- end -- end end) client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) -- now do autostart --g_fExec("/home/thorsten/scripts/setxcompmgr.sh activate awesome") g_fExec("xset -b") -- update conkys table and statusbar- widgets the first time updateConkyTable() -- move mouse to bottom right corner mouse.coords({x = 1400, y = 1000}) -- }}}