Browse Source

Update awesome configuration

Emmanuel Bouthenot 13 years ago
parent
commit
9ae322b8e4
3 changed files with 45 additions and 185 deletions
  1. 0 168
      .config/awesome/awqterm.lua
  2. 6 0
      .config/awesome/helpers.lua
  3. 39 17
      .config/awesome/rc.lua

+ 0 - 168
.config/awesome/awqterm.lua

@@ -1,168 +0,0 @@
--- {{{ License
--- Awesome dropdown Quake like console
--- 2012, Emmanuel Bouthenot <kolter@openics.org>
---
--- (very) partially inspired from http://awesome.naquadah.org/wiki/Drop-down_terminal
---
--- This file is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY
---
--- }}}
-
--- {{{ Libraries
-require('utils')
--- }}}
-
--- {{{ Variables
-awq = {}
-awq_tag = nil
-awq_name = ''
-awq_scr = nil
-awq_idx = 0
-awqterm_prog = 'xterm'
--- }}}
-
--- {{{ Keys
-awqkeys = awful.util.table.join(
-    awful.key({ "Control" }, "Prior", function(c) awq_client_show_next() end),
-    awful.key({ "Control" }, "Next" , function(c) awq_client_show_prev()  end),
-    awful.key({ "Mod1" }   , "Up"   , function(c) awq_client_new()  end)
-)
--- }}}
-
--- {{{ Functions (“private”)
-function awq_client_show_pos(reverse)
-    local keys = awful.util.table.keys(awq)
-    if reverse then
-        keys = awful.util.table.reverse(keys)
-    end
-    local pos = table.pos(keys, awq_name)
-    if not (pos == nil) then
-        local pos = pos+1
-        local newname = table.keypos(keys, pos)
-        if newname == nil then
-            newname = table.keyfirst(keys)
-        end
-        if not (awq_name == newname) then
-            awq_client_hide(awq_name)
-            awq_name = newname
-            awq_client_show(awq_name)
-        end
-    end
-end
-
-function awq_client_show_next()
-    awq_client_show_pos(true)
-end
-
-function awq_client_show_prev()
-    awq_client_show_pos(false)
-end
-
-function awq_client_new()
-    awq_idx = awq_idx+1
-    awq_name = 'awq_' .. awq_idx
-    local name = awq_name
-    if not awq[name] then
-        -- Create table
-        awq[name] = {}
-        -- Add unmanage hook for awq programs
-        client.add_signal("unmanage", function (c, startup)
-            awq_client_show_prev()
-            for name,data in pairs(awq) do
-                for s, cl in pairs(data) do
-                    if cl == c then
-                        awq[name] = nil
-                    end
-                end
-            end
-        end)
-    end
-    -- Get workarea
-    local workarea = screen[awq_scr].workarea
-    spawnw = function (c)
-        -- Store client
-        awq[name][awq_scr] = c
-        -- Float client
-        awful.client.floating.set(c, true)
-        -- Resize client
-        c:geometry({
-            x = workarea.x,
-            y = workarea.y-19,
-            width = workarea.width,
-            height = workarea.height+20
-        })
-        -- Set keys
-        c:keys(awful.util.table.join(
-            c:keys(),
-            awqkeys
-        ))
-        -- Focus and raise client
-        c:raise()
-        client.focus = c
-        -- Remove hook
-        client.remove_signal("manage", spawnw)
-    end
-    -- Add hook
-    client.add_signal("manage", spawnw)
-    -- Spawn program
-    awful.util.spawn(awqterm_prog)
-    awq_tag = awful.tag.selected(awq_scr)
-end
-
-function awq_client_show(name)
-    -- Get client
-    local c = awq[name][awq_scr]
-    awful.client.movetotag(awful.tag.selected(awq_scr), c)
-    c.hidden = false
-    c:raise()
-    client.focus = c
-end
-
-function awq_client_hide(name)
-    -- Get client
-    local c = awq[name][awq_scr]
-    if awful.tag.selected(awq_scr) == awq_tag then
-        c.hidden = true
-        local ctags = c:tags()
-        for i, t in pairs(ctags) do
-            ctags[i] = nil
-        end
-        c:tags(ctags)
-    else
-        awful.client.movetotag(awful.tag.selected(awq_scr), c)
-        c:raise()
-        client.focus = c
-    end
-end
-
-function awq_client_toggle()
-    -- Get client
-    if awq[awq_name] then
-        c = awq[awq_name][awq_scr]
-    end
-    if c == nil then
-        awq_client_new()
-    else
-        if c.hidden then
-            awq_client_show(awq_name)
-        else
-            awq_client_hide(awq_name)
-        end
-        awq_tag = awful.tag.selected(awq_scr)
-    end
-end
--- }}}
-
--- {{{ Functions (“public”)
-function awqterm_toggle()
-    awq_scr = mouse.screen
-    if next(awq) == nil then
-        awq_client_new()
-    else
-        awq_client_toggle()
-    end
-end
--- }}}
-
--- vim: foldmethod=marker

+ 6 - 0
.config/awesome/helpers.lua

@@ -25,6 +25,12 @@ function whereis(program)
     return path
 end
 
+function runonce(cmd, screen)
+    if cmd then
+        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. cmd .. "' >/dev/null 2>&1 || (" .. cmd .. " ; echo Starting '" .. cmd .. "')", screen)
+    end
+end
+
 function debug(message)
     naughty.notify({ preset = naughty.config.presets.critical,
         title = "Debug message", text = message})

+ 39 - 17
.config/awesome/rc.lua

@@ -23,7 +23,6 @@ require("wicked")
 require("vicious")
 -- User libraries
 require("helpers")
-require("awqterm")
 -- }}}
 
 -- {{{ Error handling
@@ -65,8 +64,8 @@ editor_cmd = terminal .. ' -e ' .. editor
 -- 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"
-altkey = "Mod1"
+-- modkey = "Mod4"
+modkey = "Mod1"
 
 -- Table of layouts to cover with awful.layout.inc, order matters.
 layouts =
@@ -84,6 +83,9 @@ layouts =
     awful.layout.suit.max.fullscreen,
     awful.layout.suit.magnifier
 }
+
+-- Store the current tag
+mycurrenttag = 1
 -- }}}
 
 -- {{{ Tags
@@ -272,7 +274,7 @@ globalkeys = awful.util.table.join(
             awful.client.focus.byidx(-1)
             if client.focus then client.focus:raise() end
         end),
-    awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
+    -- awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
 
     -- Layout manipulation
     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
@@ -280,7 +282,7 @@ globalkeys = awful.util.table.join(
     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,           }, "u", awful.client.urgent.jumpto),
-    awful.key({ altkey,           }, "Tab",
+    awful.key({ modkey,           }, "Tab",
         function ()
             awful.client.focus.history.previous()
             if client.focus then
@@ -293,14 +295,16 @@ globalkeys = awful.util.table.join(
     awful.key({ modkey, "Control" }, "r", awesome.restart),
     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
 
-    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),
+    -- 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({ "Shift" }, "Right", function () awful.layout.inc(layouts,  1) end),
+    -- awful.key({ "Shift" }, "Left", function () awful.layout.inc(layouts, -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),
 
     awful.key({ modkey, "Control" }, "n", awful.client.restore),
 
@@ -316,9 +320,18 @@ globalkeys = awful.util.table.join(
               end),
 
     -- Screensaver
-    awful.key({ altkey, "Control"}, "l", function () awful.util.spawn("xscreensaver-command -lock") end),
+    awful.key({ modkey, "Control"}, "l", function() awful.util.spawn("xscreensaver-command -lock") end),
     -- Dropdown terminal
-    awful.key({ altkey }, "space", function () awqterm_toggle() end)
+    awful.key({ modkey }, "space", function()
+        local curtag = awful.tag.getidx(awful.tag.selected(mouse.screen))
+        local lasttag = table.getn(tags[mouse.screen])
+        if not (curtag == lasttag) then
+            mycurrenttag = curtag
+            awful.tag.viewonly(tags[mouse.screen][lasttag])
+        else
+            awful.tag.viewonly(tags[mouse.screen][mycurrenttag])
+        end
+    end)
 )
 
 -- Extend globalkeys
@@ -326,7 +339,10 @@ for i = 1, table.getn(tags[mouse.screen]) do
     globalkeys = awful.util.table.join(
         globalkeys,
         -- Ctrl Fx keys shows (goes to) tag X
-        awful.key({ "Control"}, 'F' .. i, function() awful.tag.viewonly(tags[mouse.screen][i]) end),
+        awful.key({ "Control"}, 'F' .. i, function()
+            awful.tag.viewonly(tags[mouse.screen][i])
+            mycurrenttag = i
+        end),
         -- Shift Fx move focused application to tag X
         awful.key({ "Control", "Shift" },  'F' .. i,
             function ()
@@ -339,7 +355,7 @@ end
 
 clientkeys = awful.util.table.join(
     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
-    awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
+    awful.key({ modkey,           }, "c",      function (c) c:kill()                         end),
     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
@@ -456,5 +472,11 @@ client.add_signal("focus", function(c) c.border_color = beautiful.border_focus e
 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
 -- }}}
 
+-- {{{ Startup programs
+runonce('xscreensaver -no-splash')
+runonce('clipit')
+runonce('roxterm --disable-sm')
+runonce('pidgin')
+-- }}}
 
 -- vim: foldmethod=marker