]> 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 bdbf42d6e114ea56bd61a5ae7638a83bc5fa8799..7d798cf85567655465f6f6bffc15a9d56d34d08b 100644 (file)
@@ -1,6 +1,7 @@
 -- Include awesome libraries, with lots of useful function!
 require("awful")
 require("beautiful")
+require("naughty")
 
 -- Load Debian menu entries
 require("debian.menu")
@@ -616,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
@@ -626,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)
+})