]> git.madduck.net Git - etc/awesome.git/blobdiff - .config/awesome/rc.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

remove trailing whitespace
[etc/awesome.git] / .config / awesome / rc.lua
index 743b3189be4a6f02140e9ba79c8938aed8489bdd..7d798cf85567655465f6f6bffc15a9d56d34d08b 100644 (file)
@@ -1,20 +1,24 @@
 -- Include awesome libraries, with lots of useful function!
 require("awful")
 require("beautiful")
+require("naughty")
+
+-- Load Debian menu entries
+require("debian.menu")
 
 -- {{{ Variable definitions
 -- Themes define colours, icons, and wallpapers
 -- The default is a dark theme
-theme_path = "/home/madduck/code/awesome/share/awesome/themes/default/theme"
+theme_path = "/usr/share/awesome/themes/default/theme"
 -- Uncommment this for a lighter theme
--- theme_path = "/home/madduck/code/awesome/share/awesome/themes/sky/theme"
+-- theme_path = "/usr/share/awesome/themes/sky/theme"
 
 -- Actually load theme
 beautiful.init(theme_path)
 
 -- This is used later as the default terminal and editor to run.
 terminal = "x-terminal-emulator"
-editor = "sensible-editor"
+editor = os.getenv("EDITOR") or "editor"
 editor_cmd = terminal .. " -e " .. editor
 
 -- Default modkey.
@@ -122,7 +126,8 @@ myawesomemenu = {
 }
 
 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
-                                        { "open terminal", terminal }
+                                        { "open terminal", terminal },
+                                        { "Debian", debian.menu.Debian_menu.Debian }
                                       }
                             })
 
@@ -271,20 +276,20 @@ keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
 
 -- Client manipulation
 keybinding({ modkey }, "m", awful.client.maximize):add()
-keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
-keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
-keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
-keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1);  client.focus:raise() end):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(-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 () client.focus:swap(awful.client.getmaster()) end):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 () client.focus:redraw() end):add()
+keybinding({ modkey, "Shift" }, "r", function () if client.focus then client.focus:redraw() end end):add()
 
 -- Layout manipulation
 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
@@ -310,7 +315,7 @@ keybinding({ modkey, "Ctrl" }, "i", function ()
                                         local s = mouse.screen
                                         if mypromptbox[s].text then
                                             mypromptbox[s].text = nil
-                                        else
+                                        elseif client.focus then
                                             mypromptbox[s].text = nil
                                             if client.focus.class then
                                                 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
@@ -612,8 +617,8 @@ keybinding({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end):add()
 keybinding({ cmdmodkey }, "x", function () awful.util.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end):add()
 
--- Highlight statusbars on the screen that has focus, 
--- set this to false if you only have one screen or 
+-- Highlight statusbars on the screen that has focus,
+-- set this to false if you only have one screen or
 -- you don't like it :P
 if screen.count() > 1 then
   statusbar_highlight_focus = true
@@ -622,3 +627,87 @@ else
 end
 
 hook_battery()
+
+function displayMonth(month,year,weekStart)
+    local t,wkSt=os.time{year=year, month=month+1, day=0},weekStart or 1
+    local d=os.date("*t",t)
+    local mthDays,stDay=d.day,(d.wday-d.day-wkSt+1)%7
+
+    local lines = {}
+
+    for x=0,6 do
+        lines[x+1] = os.date("%a ",os.time{year=2006,month=1,day=x+wkSt})
+    end
+    lines[8] = "    "
+
+    local writeLine = 1
+    while writeLine < (stDay + 1) do
+        lines[writeLine] = lines[writeLine] .. "   "
+        writeLine = writeLine + 1
+    end
+
+    for x=1,mthDays do
+        if writeLine == 8 then
+            writeLine = 1
+        end
+        if writeLine == 1 or x == 1 then
+            lines[8] = lines[8] .. os.date(" %V",os.time{year=year,month=month,day=x})
+        end
+        if (#(tostring(x)) == 1) then
+            x = " " .. x
+        end
+        lines[writeLine] = lines[writeLine] .. " " .. x
+        writeLine = writeLine + 1
+    end
+    local header = os.date("%B %Y\n",os.time{year=year,month=month,day=1})
+    header = string.rep(" ", math.floor((#(lines[1]) - #header) / 2 )) .. header
+
+    return header .. table.concat(lines, '\n')
+end
+
+local calendar = {}
+function switchNaughtyMonth(switchMonths)
+    if (#calendar < 3) then return end
+    local swMonths = switchMonths or 1
+    calendar[1] = calendar[1] + swMonths
+    calendar[3].box.widgets[2].text = displayMonth(calendar[1], calendar[2], 2)
+end
+
+mytimebox.mouse_enter = function ()
+    local month, year = os.date('%m'), os.date('%Y')
+    calendar = { month, year,
+                naughty.notify({
+                    text = displayMonth(month, year, 2),
+                    timeout = 0, hover_timeout = 0.5,
+                    width = 200, screen = mouse.screen
+                })
+               }
+end
+mytimebox.mouse_leave = function () naughty.destroy(calendar[3]) end
+
+mytimebox:buttons({
+    button({ }, 1, function()
+        switchNaughtyMonth(-1)
+    end),
+    button({ }, 3, function()
+        switchNaughtyMonth(1)
+    end),
+    button({ }, 4, function()
+        switchNaughtyMonth(-1)
+    end),
+    button({ }, 5, function()
+        switchNaughtyMonth(1)
+    end),
+    button({ 'Shift' }, 1, function()
+        switchNaughtyMonth(-12)
+    end),
+    button({ 'Shift' }, 3, function()
+        switchNaughtyMonth(12)
+    end),
+    button({ 'Shift' }, 4, function()
+        switchNaughtyMonth(-12)
+    end),
+    button({ 'Shift' }, 5, function()
+        switchNaughtyMonth(12)
+    end)
+})