--{{{ Libs io.stderr:write("===== awesome reloaded\r\n") -- module to load require("awful") require("beautiful") require("invaders") require("revelation") require("naughty") require("tabulous") -- uncomment this to activate autotabbing tabulous.autotab_start() require("wicked") -- it's not part of awesome, compil it from git --}}} -- {{{ Variables --{{{ Paths home_dir = os.getenv("HOME") awesome_dir = home_dir .. "/.config/awesome/" scripts_dir = home_dir .. "/.config/awesome/scripts/" icons_dir = home_dir .. "/.config/awesome/icons/" theme_path = "/usr/share/awesome/themes/default/theme" --}}} ---{{{ Autostart -- some useful stuff running at startup os.execute("system-config-printer-applet&") os.execute("/usr/bin/pam-panel-icon&") os.execute("/usr/bin/gnome-volume-control-applet&") os.execute("/usr/bin/draksnapshot-applet&") os.execute("/usr/bin/mdkapplet -f&") os.execute("/usr/bin/net_applet&") os.execute("pactl load-module module-x11-xsmp&") -- os.execute("thunar --daemon&") -- os.execute("bluetooth-applet&") -- generate programs list for dmenu progslist_path = os.getenv("HOME") .. "/.cache/awesome/proglist" function proglist() local path = os.getenv("PATH") os.execute("paths=$(echo \"" .. path .. "\" | sed 'y/:/ /') ; ls -lL $paths 2>/dev/null | awk '$1 ~ /^[^d].*x/ && NF > 2 { print $NF }' | sort | uniq > " .. progslist_path) -- unregister this function awful.hooks.timer.unregister(proglist) end -- make proglist in background after awesome starts (prevent awesome freeze) awful.hooks.timer.register(5, proglist) proglist(os.getenv("PATH")) -- used with autostart function for reading .desktop --autostart_dir = os.getenv("HOME") .. "/.config/autostart" --autostart(autostart_dir) ---}}} --{{{ Various vars terminal = "urxvt" terminal_alt = "xterm" editor = os.getenv("EDITOR") or "vim" editor_cmd = terminal .. " -e " .. editor browser = "midori" file_manager = "thunar" file_manager_alt = "nautilus --no-desktop" --}}} -- Define if we want to use titlebar on all applications. use_titlebar = false -- }}} --{{{ Key combination modkey = "Mod4" shift = "Shift" modkey2 = "Mod3" control = "Control" alt = "Alt" shift = "Shift" k_n = {} k_m = {modkey} k_ms = {modkey, shift} k_ma = {modkey, alt} k_mc = {modkey, control} k_mcs = { modkey, "Control", "Shift" } k_a = {alt} k_ac = {alt, control} k_as = {alt, shift} k_c = {control} k_cs = {control, shift} k_s = {shift} --}}} --{{{ Layouts layouts = { "tile", "tileleft", "tilebottom", "tiletop", "fairh", "fairv", "magnifier", "max", "fullscreen", "spiral", "dwindle", "floating" } --}}} --{{{ Floatings clients floatapps = { ["MPlayer"] = true, ["Firefox Preferences"] = true, ["psi"] = true,i ["et-gtk.py"] = true, ["Wine"] = true, ["NdsCRC.exe"] = true, ["VirtualBox"] = true, ["Evolution" ] = true, ["Transmission"] = true, } --}}} --{{{ Apps to tags apptags = { ["Midori"] = { screen = 1, tag = 3 }, ["Pidgin"] = { screen = 1, tag = 5 }, ["Vmware-vmrc"] = { screen = 1, tag = 9 }, ["VirtualBox"] = { screen = 1, tag = 9 }, ["Evolution"] = { screen = 1, tag = 4 }, ["Transmission"] = { screen = 1, tag = 0 }, } --}}} --{{{ Colors, fonts... default_mwfact = 0.618033988769 beautiful.init(theme_path) --}}} --{{{ Tags screens specific -- Define tags table tags_name = {} tags_layout = {} tags_mwfact = {} tags_name[1] = { "main", "ssh", "www", "mail", "im", "irrsi", "dev1", "dev2", "dev3", "mpd", "ooo", "vm", "trash", "foo", "bar" } tags_layout[1] = { 1, 1, 1, 1, 12, 4, 1, 1, 12, 1, 1, 1, 1, 1, 1 } tags_mwfact[1] = { default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact, default_mwfact} tags = {} for s = 1, screen.count() do -- Each screen has its own tag table tags[s] = {} -- Create 9 tags per screen for tagnumber,tagname in ipairs(tags_name[s]) do tags[s][tagnumber] = tag({ name = tagname, layout = layouts[tags_layout[s][tagnumber]] }) -- Add tags to screen one by one tags[s][tagnumber].screen = s end -- I'm sure you want to see at least one tag. tags[s][1].selected = true end --} }} --{{{ Funtions definition --{{{ Utils -- Set background color function bg(color, text) return '' .. text end -- Set foreground color function fg(color, text) return '' .. text .. '' end -- Boldify text function bold(text) return '' .. text .. '' end -- Widget base function widget_base(content) if content and content ~= "" then return fg(beautiful.fg_focus, " [ ") .. content .. fg(beautiful.fg_focus, " ] ") end end -- Widget section function widget_section(label, content, next_section) local section if content and content ~= nil then if label and label ~= "" then section = bold(label .. ": ") .. content else section = content end if next_section and next_section ~= "" then section = section .. fg(beautiful.hilight, " | ") .. next_section end else section = next_section end return section end -- Widget value function widget_value(content, next_value) local value if content and content ~= nil then value = content if next_value and next_value ~= "" then value = value .. fg(beautiful.hilight, " / ") .. next_value end else value = next_value end return value end -- Read the first line of a file function readline(file) local f = io.open(file, "r") if f ~= nil then local c = f:read("*l") f:close() return c else return nil end end -- Return symbol for the given layout function layout_symbol(layout) return fg(beautiful.fg_focus," │" .. layouts_symbol[layout] .. "│ ") end function system(cmd) local f = io.popen(cmd) local l = f:read() f:close() return l end function execute(cmd) local f = io.popen(cmd) if f ~= nil then local c = f:read() f:close() return c else return nil end end -- Be Careful, function is so shitty ! function images(image) return "" end function image_un(image) return "" end function set_bg( color, text ) return '' .. text end function set_fg( color, text ) return '' .. text .. '' end function set_font( font, text ) return '' .. text .. '' end function set_align( alignment, text ) return '' .. text .. '' end function set_urgent( text ) return set_bg( bg_urgent, set_fg( fg_urgent, text ) ) end function set_normal( text ) return set_bg( bg_normal, set_fg( fg_normal, text ) ) end function set_focused( text ) return set_bg( bg_focus, set_fg( fg_focus, text ) ) end function warning( condition, text ) if condition then return set_urgent( text ) else return set_normal( text ) end end function splitbywhitespace(str) --stolen from wicked.lua values = {} start = 1 splitstart, splitend = string.find(str, ' ', start) while splitstart do m = string.sub(str, start, splitstart-1) if m:gsub(' ','') ~= '' then table.insert(values, m) end start = splitend+1 splitstart, splitend = string.find(str, ' ', start) end m = string.sub(str, start) if m:gsub(' ','') ~= '' then table.insert(values, m) end return values end function to_int( n ) return tonumber( string.format( '%i', n ) ) end function dbg(vars) local text = "" for i=1, #vars do text = text .. vars[i] .. " | " end naughty.notify({ text = text, timeout = 0 }) end --- Spawns cmd if no client can be found matching properties -- If such a client can be found, pop to first tag where it is visible, and give it focus -- @param cmd the command to execute -- @param properties a table of properties to match against clients. Possible entries: any properties of the client object function run_or_raise(cmd, properties) local clients = client.get() for i, c in pairs(clients) do if match(properties, c) then local ctags = c:tags() if table.getn(ctags) == 0 then -- ctags is empty, show client on current tag local curtag = awful.tag.selected() awful.client.movetotag(curtag, c) else -- Otherwise, pop to first tag client is visible on awful.tag.viewonly(ctags[1]) end -- And then focus the client client.focus = c c:raise() return end end awful.util.spawn(cmd) end -- Returns true if all pairs in table1 are present in table2 function match (table1, table2) for k, v in pairs(table1) do if table2[k] ~= v then return false end end return true end function autostart(dir) if not dir then do return nil end end local fd = io.popen("ls -1 -F " .. dir) if not fd then do return nil end end for file in fd:lines() do local c= string.sub(file,-1) -- last char if c=='*' then -- executables executable = string.sub( file, 1,-2 ) print("Awesome Autostart: Executing: " .. executable) os.execute(dir .. "/" .. executable .. " &") -- launch in bg elseif c=='@' then -- symbolic links print("Awesome Autostart: Not handling symbolic links: " .. file) else print ("Awesome Autostart: Skipping file " .. file .. " not executable.") end end io.close(fd) end --}}} --{{{ Widgets -- Just a clock, %d/%m/%Y %H:%M function widget_clock() return widget_base(os.date("%H:%M")) end function widget_date() return widget_base(os.date("%d/%m/%Y")) end --}}} --{{{ Statusbar --{{{ Clock widget -- clockbox clockbox = widget({ type = "textbox", name = "clockbox", align = "right" }) clockbox.text = widget_clock() --}}} --{{{ Date widget -- clockbox datebox = widget({ type = "textbox", name = "datebox", align = "right" }) datebox.text = widget_date() --}}} --{{{ Ram client box -- ramclientbox ramclientbox = widget({ type = "textbox", name = "ramclientbox", align = "left" }) --}}} --{{{ Systray widget -- mysystray mysystray = widget({ type = "systray", name = "mysystray", align = "right" }) --}}} --{{{ Awesome Launche -- 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 } } mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, { "open terminal", terminal } } }) mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu }) --}}} --{{{ Mpd buttons -- mpdbuttons mpdbuttonPrecedent = awful.widget.launcher({ name = "mpdbuttonPrecedent", image = icons_dir .. "precendent.png", command = music_prev, align="right", resize="true"}) mpdbuttonStop = awful.widget.launcher({ name = "mpdbuttonStop", image = icons_dir .. "stop.png", command = music_stop, align="right", resize="true"}) mpdbuttonPause = awful.widget.launcher({ name = "mpdbuttonPause", image = icons_dir .. "play.png", command = music_play, align="right", resize="true"}) mpdbuttonSuivant = awful.widget.launcher({ name = "mpdbuttonSuivant", image = icons_dir .. "suivant.png", command = music_next, align="right", resize="true"}) --}}} -- music player daemon info mpdwidget = widget({ type = 'textbox', name = 'mpdwidget', align = 'right' }) wicked.register(mpdwidget, wicked.widgets.mpd, function (widget, args) if args[1]:find("volume:") == nil then return ' MPD: ' .. args[1] else return '' end end) ---COMMAND { get_volume = 'aumix-text -q| grep \'vol \'| awk \'{print $2}\' | cut -d\',\' -f1' get_temp = 'acpi -tB | awk \'{print $4}\' | cut -d\'.\' -f1' get_music = 'mpc | grep -v %' ---} --VOLUME WIDGET { voliconbox = widget({ type = "textbox", name = "voliconbox", align = "right" }) voliconbox.text = image_un(icons_dir .. "sound.png") voliconbox:buttons( { button({ }, 4, function () awful.util.spawn("aumix-text -v +5") end ) } ) voliconbox:buttons( { button({ }, 5, function () awful.util.spawn("aumix-text -v -5") end ) } ) voliconbox:buttons( { button({ }, 1, function () awful.util.spawn("mute") end ) } ) volumew = widget({type = 'progressbar', name = 'volumew', align = 'right'}) volumew.width = 37 volumew.height = 0.50 volumew.border_padding = 0 volumew.border_width = 0 volumew.ticks_count = 10 volumew.vertical = false volumew:bar_properties_set('vol', {bg ='#000000',fg ='#ffffff',bordercolor = '#041F34',fg_off = '#484848',min_value = 0,max_value = 100}) wicked.register(volumew, 'function', function (widget, args) local f = io.popen(get_volume) local l = f:read() f:close() return l end, 4,'vol') volumew:buttons( { button({ }, 4, function () awful.util.spawn(terminal .. " -geometry \"-1-173\" -name ncmpc -e ncmpc") end ) } ) volumew:buttons( { button({ }, 5, function () awful.util.spawn(terminal .. " -geometry \"-1-173\" -name alsamixer -e alsamixer") end ) } ) volumew:buttons( { button({ }, 1, function () awful.util.spawn("aumix-text -v +5") end ) } ) volumew:buttons( { button({ }, 3, function () awful.util.spawn("aumix-text -v -5") end ) } ) --} ---TEMP WIDGET { tempiconbox = widget({ type = "textbox", name = "tempiconbox",align = "right" }) tempiconbox.text = image_un(icons_dir .. "cpuc.png") tempw = widget({type = 'textbox',name = 'tempw',align = "right"}) wicked.register(tempw, 'function', function (widget,args) local f = io.popen(get_temp) local t = f:read() f:close() return ' '..t..'°' end, 4) ---- -} ---MEM WIDGET { memiconbox = widget({ type = "textbox", name = "memiconbox", align = "right" }) memiconbox.text = image_un(icons_dir .."mem.png") membarw = widget({type = 'progressbar', name = 'membarw', align = 'right'}) membarw.width = 30 membarw.height = 0.50 membarw.gap = 0 membarw.border_padding = 0 membarw.border_width = 1 membarw.ticks_count = 0 membarw.ticks_gap = 0 membarw:bar_properties_set('mem', {border_color = '#dddddd',fg = '#ffffff',reverse = false,min_value = 0,max_value = 100}) wicked.register(membarw, 'mem', '$1',10,'mem') ---} ---CPU WIDGET { cpuiconbox = widget({ type = "textbox", name = "cpuiconbox", align = "right" }) cpuiconbox.text = image_un(icons_dir .."cpu2.png") cpugraphwidget = widget({type = 'graph',name = 'cpugraphwidget',align = 'right' }) cpugraphwidget.height = "0.8" cpugraphwidget.width = "30" cpugraphwidget.border_color = '#041f34' cpugraphwidget.grow = 'left' cpugraphwidget:plot_properties_set('cpu',{fg = '#ffffff'}) wicked.register(cpugraphwidget, 'cpu', '$1', 1, 'cpu') ---} ------------------- -------ICONE------- ------------------- --PLAY iplay = widget({ type = "textbox", name = "iplay", align = "right"}) iplay.text = image_un(icons_dir.."play.png") iplay:buttons( { button({ }, 1, function () awful.util.spawn("mpc toggle > /dev/null") end ) } ) --STOP istop = widget({ type = "textbox", name = "istop", align = "right"}) istop.text = image_un(icons_dir.."stop.png") istop:buttons( { button({ }, 1, function () awful.util.spawn("mpc stop > /dev/null") end ) } ) --PREVIOUS iprev = widget({ type = "textbox", name = "iprev", align = "right"}) iprev.text = image_un(icons_dir.."precendent.png") iprev:buttons( { button({ }, 1, function () awful.util.spawn("mpc prev > /dev/null") end ) } ) --NEXT inext = widget({ type = "textbox", name = "inext", align = "right"}) inext.text = image_un(icons_dir.."suivant.png") inext:buttons( { button({ }, 1, function () awful.util.spawn("mpc next > /dev/null") end ) } ) --PAUSE ipau = widget({ type = "textbox", name = "ipau", align = "right"}) ipau.text = image_un(icons_dir.."pause.png") ipau:buttons( { button({ }, 1, function () awful.util.spawn("mpc toggle > /dev/null") end ) } ) --- STATUSBAR { bar = widget({type="textbox",name="bar",align="right"}) bar.text = " - " space = widget({type="textbox",name="space",align="right"}) space.text = " " lspace = widget({type="textbox",name="lspace",align="left"}) lspace.text = " " mywiboxtop1 = {} mypromptbox = {} mylayoutbox = {} mytaglist1 = {} mytaglist1.buttons = { button({ }, 1, awful.tag.viewonly), button({ modkey }, 1, awful.client.movetotag), button({ }, 3, function (tag) tag.selected = not tag.selected end), button({ modkey }, 3, awful.client.toggletag), button({ }, 4, awful.tag.viewnext), button({ }, 5, awful.tag.viewprev) } mytasklist1 = {} mytasklist1.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end), button({ }, 3, function () awful.menu.clients({ width=250 }) end), button({ }, 4, function () awful.client.focus.byidx(1) end), button({ }, 5, function () awful.client.focus.byidx(-1) end) } mypromptbox[1] = widget({ type = "textbox", name = "mypromptbox" .. 1, align = "left" }) mylayoutbox[1] = widget({ type = "imagebox", name = "mylayoutbox", align = "left" }) mylayoutbox[1]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end), button({ }, 3, function () awful.layout.inc(layouts, -1) end) }) -- Create a tasklist widget mytasklist1[1] = awful.widget.tasklist.new(function(c) return awful.widget.tasklist.label.currenttags(c, 1) end, mytasklist1.buttons) -- Create a taglist widget mytaglist1 = awful.widget.taglist.new(1, awful.widget.taglist.label.all, mytaglist1.buttons) -- Create the wibox mywiboxtop1 = wibox({ position = "top", name = "mywiboxtop1" .. 1, fg = beautiful.fg_normal, bg = beautiful.bg_normal }) mywiboxbottom1 = wibox({ position = "bottom", name = "mywiboxbottom1" .. 1, fg = beautiful.fg_normal, bg = beautiful.bg_normal }) mywiboxtop1.widgets = { mylauncher, mytaglist1, mylayoutbox[1], mypromptbox[1], bar, cpuiconbox, space, cpugraphwidget, bar, memiconbox, space, membarw, bar, tempiconbox, tempw, bar, voliconbox, space, volumew, space, bar, space, iplay, ipau, istop, iprev, inext, space, bar, mpdwidget, bar, space, datebox, clockbox, mysystray } mywiboxbottom1.widgets = { mytasklist1[1] } mywiboxtop1.screen = 1 mywiboxbottom1.screen = 1 --}}} --{{{ Mouse bindings awesome.buttons({ button({ }, 3, function () awful.menu.new({ id="mymainmenu", items=mymainmenu }) end), button({ }, 4, awful.tag.viewnext), button({ }, 5, awful.tag.viewprev) }) --}}} --{{{ Key bindings --{{{ Tags -- Bind keyboard digits -- Compute the maximum number of digit we need, limited to 9 -- Fix for French Keyboard tagkeys = {'#10', '#11', '#12', '#13', '#14', '#15', '#16', '#17', '#18'} keynumber = 0 for s = 1, screen.count() do keynumber = math.min(9, math.max(#tags[s], keynumber)); end for i = 1, keynumber do keybinding(k_m, tagkeys[i], function () local screen = mouse.screen if tags[screen][i] then awful.tag.viewonly(tags[screen][i]) end end):add() keybinding(k_mc, tagkeys[i], function () local screen = mouse.screen if tags[screen][i] then tags[screen][i].selected = not tags[screen][i].selected end end):add() keybinding(k_ms, tagkeys[i], function () if client.focus then if tags[client.focus.screen][i] then awful.client.movetotag(tags[client.focus.screen][i]) end end end):add() keybinding(k_mcs, tagkeys[i], function () if client.focus then if tags[client.focus.screen][i] then awful.client.toggletag(tags[client.focus.screen][i]) end end end):add() end keybinding(k_m, "Left", awful.tag.viewprev):add() keybinding(k_m , "q", awful.tag.viewprev):add() keybinding(k_m, "Right", awful.tag.viewnext):add() keybinding(k_m , "w", awful.tag.viewnext):add() keybinding(k_m, "Escape", awful.tag.history.restore):add() for i = 1, keynumber do keybinding(k_ms, "F" .. i, function () local screen = mouse.screen if tags[screen][i] then for k, c in pairs(awful.client.getmarked()) do awful.client.movetotag(tags[screen][i], c) end end end):add() end keybinding({ modkey }, "b", function () if mywiboxbottom1.visible == false then mywiboxbottom1.visible = true else mywiboxbottom1.visible = false end --if mywiboxbottom2.visible == false then -- mywiboxbottom2.visible = true --else -- mywiboxbottom2.visible = false --end end):add() --}}} --{{{ Programs keybinding(k_m , "Return", function () awful.util.spawn(terminal) end):add() keybinding(k_ms, "e", function () awful.util.spawn(file_manager) end):add() keybinding(k_mc, "q", function () awful.spawn( terminal_alt ) end):add() keybinding(k_mc, "e", function () awful.spawn( file_manager_alt ) end):add() --}}} --{{{ Awesome quit/restart keybinding(k_mc , "r", function () mypromptbox.text = awful.util.escape(awful.util.restart()) end):add() keybinding({ modkey, "Shift" }, "q", awesome.quit):add() --}}} --{{{ Client manipulation keybinding({ modkey }, "m", awful.client.maximize):add() keybinding({ modkey }, "f", function () if client.focus then client.focus.fullscreen = not client.focus.fullscreen end end):add() keybinding({ modkey, "Shift" }, "c", function () if client.focus then client.focus:kill() end end):add() keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); if client.focus then client.focus:raise() end end):add() keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); if client.focus then client.focus:raise() end end):add() keybinding({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end):add() keybinding({ modkey, "Shift" }, "k", function () awful.client.swap.byidx(-1) end):add() keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add() keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add() keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add() keybinding({ modkey, "Control" }, "Return", function () if client.focus then client.focus:swap(awful.client.getmaster()) end end):add() keybinding({ modkey }, "o", awful.client.movetoscreen):add() keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add() keybinding({ modkey }, "u", awful.client.urgent.jumpto):add() keybinding({ modkey, "Shift" }, "r", function () if client.focus then client.focus:redraw() end end):add() keybinding({ modkey }, "t", function () if client.focus then awful.titlebar.add(client.focus, { modkey = modkey}) end end):add() keybinding({ modkey, "Shift" }, "t", function () if client.focus then awful.titlebar.remove(client.focus, { modkey = modkey, "Shift"}) end end):add() keybinding({ modkey, "Control" }, "t", function () if client.focus then awful.titlebar.update(client.focus, { modkey = modkey, "Control"}) end end):add() --}}} --{{{ Layout manipulation keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add() keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add() keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add() keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add() keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add() keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add() keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add() keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add() --}}} --{{{ Screen manipulation keybinding(k_m,"e", function () awful.screen.focus(1) end):add() -- Screen focus +1 keybinding(k_m,"d", function () awful.screen.focus(-1) end):add() -- Screen focus -1 --}}} --{{{ Prompts keybinding(k_m , "F1", function () awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash, awful.util.getdir("cache") .. "/history") end):add() -- bind dmenu on Mod4 + F2 dmenu = "dmenu -b -i -fn '" .. beautiful.font .. "' -nb '" .. beautiful.bg_normal .."' -nf '" .. beautiful.fg_normal .. "'" keybinding({ modkey }, "F2", function () local f = io.popen(dmenu .. " <" .. progslist_path) local l = f:lines() for line in l do if line ~= nil then os.execute(line .."&") break end end f:close() end):add() keybinding({ modkey }, "F3", function () awful.prompt.run({ prompt = "SSH: " }, mypromptbox[mouse.screen], function (s) awful.util.spawn("exec xterm -bg black -fg white -e ssh -v " .. s) end) end):add() keybinding(k_m , "F4", function () awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash, awful.util.getdir("cache") .. "/history_eval") end):add() -- Add mod + F5 key binding to start revelation keybinding({ modkey }, "F5", revelation.revelation):add() keybinding({ modkey, "Ctrl" }, "i", function () local s = mouse.screen if mypromptbox[s].text then mypromptbox[s].text = nil else mypromptbox[s].text = nil if client.focus.class then mypromptbox[s].text = "Class: " .. client.focus.class .. " " end if client.focus.instance then mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " " end if client.focus.role then mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role end end end):add() --}}} --{{{ Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them keybinding({ modkey }, "s", awful.client.togglemarked):add() for i = 1, keynumber do keybinding({ modkey, "Shift" }, "F" .. i, function () local screen = mouse.screen if tags[screen][i] then for k, c in pairs(awful.client.getmarked()) do awful.client.movetotag(tags[screen][i], c) end end end):add() end -- }}} --{{{ Tabulous, tab manipulation keybinding({ modkey, "Control" }, "y", function () local tabbedview = tabulous.tabindex_get() local nextclient = awful.client.next(1) if not tabbedview then tabbedview = tabulous.tabindex_get(nextclient) if not tabbedview then tabbedview = tabulous.tab_create() tabulous.tab(tabbedview, nextclient) else tabulous.tab(tabbedview, client.focus_get()) end else tabulous.tab(tabbedview, nextclient) end end):add() keybinding({ modkey, "Shift" }, "y", tabulous.untab):add() keybinding({ modkey }, "y", function () local tabbedview = tabulous.tabindex_get() if tabbedview then local n = tabulous.next(tabbedview) tabulous.display(tabbedview, n) end end):add() --}}} --}}} -- {{{ Hooks -- Hook function to execute when focusing a client. awful.hooks.focus.register(function (c) if not awful.client.ismarked(c) then c.border_color = beautiful.border_focus end end) -- Hook function to execute when unfocusing a client. awful.hooks.unfocus.register(function (c) if not awful.client.ismarked(c) then c.border_color = beautiful.border_normal end end) -- Hook function to execute when marking a client awful.hooks.marked.register(function (c) c.border_color = beautiful.border_marked end) -- Hook function to execute when unmarking a client awful.hooks.unmarked.register(function (c) c.border_color = beautiful.border_focus end) -- Hook function to execute when the mouse is over a client. awful.hooks.mouse_enter.register(function (c) -- Sloppy focus, but disabled for magnifier layout if awful.layout.get(c.screen) ~= "magnifier" then client.focus = c end end) -- Hook function to execute when a new client appears. awful.hooks.manage.register(function (c) -- Set floating placement to be smart! if use_titlebar then -- Add a titlebar awful.titlebar.add(c, { modkey = modkey }) end -- Add mouse bindings c:buttons({ button({ }, 1, function (c) client.focus = c; c:raise() end), button({ modkey }, 1, function (c) c:mouse_move() end), button({ modkey }, 3, function (c) c:mouse_resize() end) }) -- New client may not receive focus -- if they're not focusable, so set border anyway. c.border_width = beautiful.border_width c.border_color = beautiful.border_normal client.focus = c -- Check if the application should be floating. local cls = c.class local inst = c.instance if floatapps[cls] then c.floating = floatapps[cls] elseif floatapps[inst] then c.floating = floatapps[inst] end -- Check application->screen/tag mappings. local target if apptags[cls] then target = apptags[cls] elseif apptags[inst] then target = apptags[inst] end if target then c.screen = target.screen awful.client.movetotag(tags[target.screen][target.tag], c) end -- Honor size hints: if you want to drop the gaps between windows, set this to false. c.honorsizehints = true end) awful.hooks.arrange.register(function (screen) local layout = awful.layout.get(screen) if layout then mylayoutbox[screen].image = image(beautiful["layout_" .. layout]) else mylayoutbox[screen].image = nil end -- Give focus to the latest client in history if no window has focus -- or if the current window is a desktop or a dock one. if not client.focus then local c = awful.client.focus.history.get(screen, 0) if c then client.focus = c end end end) -- Hook called every second to update clock awful.hooks.timer.register(1, function () clockbox.text = widget_clock() datebox.text = widget_date() end) --}}} --{{{ WorkAround -- I hate having to do this, but I really need some of those Java apps awful.util.spawn("wmname compiz") --}}} -- vim: set filetype=lua fdm=marker tabstop=4 shiftwidth=4 expandtab smarttab autoindent smartindent nu: