X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=.config%2Fawesome%2Frc.lua;h=a3b3b94bf54219d83010183a7ec8d51c61625f79;hb=c4e225c02c4a854a443b6a13bc4dea3cf77461d8;hp=813cea915b5053798d52c953590c4e77240a2162;hpb=75b6d1db05411de0ce9ce782cd109889f6d96764;p=x_base.git diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 813cea9..a3b3b94 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -13,6 +13,23 @@ require("obvious.battery") -- Load Debian menu entries require("debian.menu") +-- from https://github.com/tony/awesome-config/blob/master/helpers.lua +function clean(string) + s = string.gsub(string, '^%s+', '') + s = string.gsub(s, '%s+$', '') + s = string.gsub(s, '[\n\r]+', ' ') + return s +end + +function file_exists(file) + local cmd = "/bin/dash -c 'if [ -e " .. file .. " ]; then echo true; fi;'" + local fh = io.popen(cmd) + + s = clean(fh:read('*a')) + + if s == 'true' then return true else return nil end +end + -- {{{ Variable definitions -- Themes define colours, icons, and wallpapers beautiful.init("/usr/share/awesome/themes/default/theme.lua") @@ -21,6 +38,37 @@ beautiful.init("/usr/share/awesome/themes/default/theme.lua") terminal = "x-terminal-emulator" editor = os.getenv("EDITOR") or "editor" editor_cmd = terminal .. " -e " .. editor +home = os.getenv("HOME") + +hostname = awful.util.pread("hostname -f"):gsub("\n", "") + +wallpaper_dir = home .. "/media/photos/gallery.donarmstrong.com/" +if (not file_exists(wallpaper_dir)) then + wallpaper_dir = "/usr/share/awesome/themes/default/background.png" +end + +wallpaper_cmd = "find " .. wallpaper_dir .. + " -xtype f \\( -iname '*.jpg' -o -iname '*.png' \\) " .. + " -not -name '.*' -print0 | shuf -n" .. screen.count() .. " -z | xargs -0 feh --bg-max" + +-- set up the wallpaper timer +wallpaper_timer = timer { timeout = 0 } +wallpaper_timer:add_signal("timeout", + function() + -- tell awsetbg to randomly choose a wallpaper from your wallpaper directory + if file_exists(wallpaper_dir) and whereis_app('feh') then + os.execute(wallpaper_cmd) + end + -- stop the timer (we don't need multiple instances running at the same time) + mytimer:stop() + + -- define the interval in which the next wallpaper change should occur in seconds + -- (in this case anytime between 10 and 20 minutes) + --restart the timer + mytimer.timeout = math.random(600,1200) + mytimer:start() + end +) -- Default modkey. -- Usually, Mod4 is the key with a logo between Control and Alt. @@ -49,10 +97,12 @@ layouts = -- {{{ Tags -- Define a tag table which hold all screen tags. -tags = {} +tags = {names={"mail","emacs","www","remotes",5,6,7,8,9} + } for s = 1, screen.count() do -- Each screen has its own tag table. - tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1]) + defaultlayout=layouts[9] + tags[s] = awful.tag(tags.names, s, defaultlayout) end -- }}} @@ -223,14 +273,14 @@ globalkeys = awful.util.table.join( awful.key({ modkey, "Shift" }, "n", function () awful.layout.inc(layouts, -1) end), -- resize floats - awful.key({ modkey, "Shift" }, "Down", function () awful.client.moveresize(0, 20, 0, 0) end), - awful.key({ modkey, "Shift" }, "Up", function () awful.client.moveresize(0, -20, 0, 0) end), - awful.key({ modkey, "Shift" }, "Left", function () awful.client.moveresize(-20, 0, 0, 0) end), - awful.key({ modkey, "Shift" }, "Right", function () awful.client.moveresize(20, 0, 0, 0) end), - awful.key({ modkey, "Control" }, "Down", function () awful.client.moveresize(0, 0, 0, -20) end), - awful.key({ modkey, "Control" }, "Up", function () awful.client.moveresize(0, 0, 0, 20) end), - awful.key({ modkey, "Control" }, "Left", function () awful.client.moveresize(0, 0, -20, 0) end), - awful.key({ modkey, "Control" }, "Right", function () awful.client.moveresize(0, 0, 20, 0) end), + awful.key({ modkey, "Control" }, "Down", function () awful.client.moveresize(0, 20, 0, 0) end), + awful.key({ modkey, "Control" }, "Up", function () awful.client.moveresize(0, -20, 0, 0) end), + awful.key({ modkey, "Control" }, "Left", function () awful.client.moveresize(-20, 0, 0, 0) end), + awful.key({ modkey, "Control" }, "Right", function () awful.client.moveresize(20, 0, 0, 0) end), + awful.key({ modkey, "Control" , "Shift" }, "Down", function () awful.client.moveresize(0, 0, 0, -20) end), + awful.key({ modkey, "Control" , "Shift" }, "Up", function () awful.client.moveresize(0, 0, 0, 20) end), + awful.key({ modkey, "Control" , "Shift" }, "Left", function () awful.client.moveresize(0, 0, -20, 0) end), + awful.key({ modkey, "Control" , "Shift" }, "Right", function () awful.client.moveresize(0, 0, 20, 0) end), -- Prompt awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), @@ -249,7 +299,9 @@ clientkeys = awful.util.table.join( awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), awful.key({ modkey, }, "space", function (c) c:swap(awful.client.getmaster()) end), awful.key({ modkey, }, "o", awful.client.movetoscreen ), - awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end) + awful.key({ modkey, "Shift" }, "Right", function(c) awful.client.movetoscreen(c,c.screen-1 % screen.count()) end), + awful.key({ modkey, "Shift" }, "Left", function(c) awful.client.movetoscreen(c,c.screen+1 % screen.count()) end), + awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end), awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end), awful.key({ modkey, "Shift" }, "m", function (c) c.minimized = not c.minimized end), awful.key({ modkey, }, "m", @@ -359,7 +411,7 @@ function warp_mouse() c = client.focus if c then local g = c:geometry() - mouse.coords({ x = g.x + 30, y = g.y + 30}, true) + mouse.coords({ x = g.x + 1, y = g.y + 1}, true) end end