Hi all,

I installed the git version of Awesome on Ubuntu and tried to migrate my
configuration file. Whenever I change a tag, no client is focused. This
is rather annoying.

Then I tried the default configuration and this is not a problem. So I
assume that I broke something in the configuration.

I have uploaded the [difference between upstream rc.lua and my
rc.lua](https://paste.kde.org/pkfwjafol) such that you can easily view
it with syntax highlighting.

Could you please look at it and tell me whether there is something wrong
in it?


Regards

Martin
-- 
http://martin-ueding.de/#pk_campaign=Email

This email is formatted with
[Markdown](https://en.wikipedia.org/wiki/Markdown).
diff --git a/rc.lua b/rc.lua
index 9d512bd..a390c55 100644
--- a/rc.lua
+++ b/rc.lua
@@ -11,6 +11,35 @@ local beautiful = require("beautiful")
 local naughty = require("naughty")
 local menubar = require("menubar")
 
+local vicious = require("vicious")
+
+solarized = {
+    red = '#dc322f',
+    orange = '#cb4b16',
+    yellow = '#b58900',
+    magenta = '#d33682',
+    violet = '#6c71c4',
+    blue = '#268bd2',
+    cyan = '#2aa198',
+    green = '#859900',
+    base01 = '#586e75',
+    base02 = '#073642',
+    base0 = '#839496',
+    base1 = '#93a1a1',
+}
+
+span = {}
+
+for color, hex in pairs(solarized) do
+    span[color] = '<span color="' .. hex .. '">'
+end
+
+endspan = '</span>'
+
+function wrap_with_color(string, color) 
+    return span[color] .. string .. endspan
+end
+
 -- {{{ Error handling
 -- Check if awesome encountered an error during startup and fell back to
 -- another config (This code will only ever execute for the fallback config)
@@ -38,10 +67,11 @@ end
 
 -- {{{ Variable definitions
 -- Themes define colours, icons, font and wallpapers.
-beautiful.init("/usr/local/share/awesome/themes/default/theme.lua")
+--beautiful.init("/usr/local/share/awesome/themes/default/theme.lua")
+beautiful.init("/home/mu/.config/awesome/themes/default/theme.lua")
 
 -- This is used later as the default terminal and editor to run.
-terminal = "xterm"
+terminal = "konsole"
 editor = os.getenv("EDITOR") or "nano"
 editor_cmd = terminal .. " -e " .. editor
 
@@ -55,19 +85,40 @@ modkey = "Mod4"
 -- Table of layouts to cover with awful.layout.inc, order matters.
 awful.layout.layouts = {
     awful.layout.suit.floating,
-    awful.layout.suit.tile,
     awful.layout.suit.tile.left,
+    awful.layout.suit.tile,
     awful.layout.suit.tile.bottom,
-    awful.layout.suit.tile.top,
+    -- awful.layout.suit.tile.top,
     awful.layout.suit.fair,
-    awful.layout.suit.fair.horizontal,
-    awful.layout.suit.spiral,
-    awful.layout.suit.spiral.dwindle,
+    -- awful.layout.suit.fair.horizontal,
+    -- awful.layout.suit.spiral,
+    -- awful.layout.suit.spiral.dwindle,
     awful.layout.suit.max,
-    awful.layout.suit.max.fullscreen,
-    awful.layout.suit.magnifier
+    -- awful.layout.suit.max.fullscreen,
+    -- awful.layout.suit.magnifier
 }
--- }}}
+
+default_layout = awful.layout.suit.tile
+
+tag_for_eml = 10
+tag_for_im = 12
+tag_for_music = 11
+tag_for_www = 9
+
+tag_numbers = { 1, 2, 3, 4, 5, '6', '7', '8', '9', '0', '-', '=' }
+tag_names = tag_numbers
+
+tags = {}
+tags[1] = awful.tag(
+    tag_names,
+    s,
+    { default_layout, default_layout, default_layout, default_layout,
+    default_layout, default_layout, default_layout, awful.layout.suit.fair,
+    default_layout, default_layout, awful.layout.suit.max, awful.layout.suit.fair }
+)
+for s = 2, screen.count() do
+    tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, default_layout)
+end
 
 -- {{{ Wallpaper
 if beautiful.wallpaper then
@@ -77,42 +128,168 @@ if beautiful.wallpaper then
 end
 -- }}}
 
--- {{{ Tags
--- Define a tag table which hold all screen tags.
-tags = {}
-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, awful.layout.layouts[1])
+
+-- {{{ Wibox
+
+-- sunrise_widget = widget({ type = "textbox" })
+-- sunrise_widget.text = wrap_with_color(awful.util.pread("sunrise"), 'blue')
+
+spacer = "   "
+
+function bat_func(widget, data)
+    local state = data[1]
+    local percentage = tonumber(data[2])
+    local time = data[2]
+    local color
+    local span
+
+    if percentage > 30 or state ~= '-' then
+        span = '<span color="' .. solarized.green .. '">'
+    elseif percentage > 10 then
+        span = '<span color="black" bgcolor="' .. solarized.yellow .. '">'
+    else
+        span = '<span color="black" bgcolor="' .. solarized.red .. '">'
+    end
+
+    return span .. vicious.helpers.format('$1 <b>$2%</b> $3', data) .. endspan .. spacer
 end
--- }}}
 
--- {{{ Menu
--- Create a laucher widget and a main menu
-myawesomemenu = {
-   { "manual", terminal .. " -e man awesome" },
-   { "edit config", editor_cmd .. " " .. awesome.conffile },
-   { "restart", awesome.restart },
-   { "quit", awesome.quit }
-}
+function if_exists(data, iface)
+    return data['{' .. iface .. ' up_kb}'] ~= nil and data['{' .. iface .. ' down_kb}'] ~= nil
+end
+
+function if_active(data, iface)
+    return data['{' .. iface .. ' up_kb}'] ~= '0.0' or data['{' .. iface .. ' down_kb}'] ~= '0.0'
+end
+
+function if_format(data, iface)
+    local string = vicious.helpers.format(iface .. ': ${' .. iface .. ' down_kb} ↓ ${' .. iface .. ' up_kb} ↑ kB/s', data)
+    if if_active(data, iface) then
+        return wrap_with_color(string, 'blue')
+    else
+        return wrap_with_color(string, 'base01')
+    end
+end
+
+last_shown = nil
+
+function net_widget_function(widget, data)
+    local snippets = {}
+    local ifaces = {'eth0', 'wlan0', 'vibr0'}
+
+    -- Compile a list of active interfaces
+    local active_ifaces = {}
+    for ignored, iface in pairs(ifaces) do
+        if if_exists(data, iface) and if_active(data, iface) then
+            table.insert(active_ifaces, iface)
+        end
+    end
+
+    local to_show = ''
+    if last_shown ~= nil and if_active(data, last_shown) then
+        to_show = last_shown
+    elseif #active_ifaces > 0 then
+        to_show = active_ifaces[1]
+    else
+        to_show = ifaces[1]
+    end
+    last_shown = to_show
+
+    if to_show ~= nil then
+        return if_format(data, to_show) .. spacer
+    else
+        return ''
+    end
+end
+
+function dio_exists(data, dev)
+    return data['{' .. dev .. ' read_mb}'] ~= nil and data['{' .. dev .. ' write_mb}'] ~= nil
+end
+
+function dio_active(data, dev)
+    return data['{' .. dev .. ' read_mb}'] ~= '0.0' or data['{' .. dev .. ' write_mb}'] ~= '0.0'
+end
+
+function dio_format(data, dev)
+    local string = vicious.helpers.format(dev .. ': ${' .. dev .. ' write_mb} ↓ ${' .. dev .. ' read_mb} ↑ MB/s', data)
+    if dio_active(data, dev) then
+        return wrap_with_color(string, 'cyan')
+    else
+        return wrap_with_color(string, 'base01')
+    end
+end
+
+function dio_widget_function(widget, data)
+    local snippets = {}
+    local devs = {'sda', 'sdc', 'sdd'}
+
+    for ignored, dev in pairs(devs) do
+        if dio_exists(data, dev) then
+            table.insert(snippets, dio_format(data, dev))
+        end
+    end
+
+    if #snippets > 0 then
+        local result = table.concat(snippets, spacer)
+        return result .. spacer
+    else
+        return ''
+    end
+end
+
+function widget_printer(entity, format, index, limit_show, limit_bad, limit_critical)
+    function formatter(widget, data)
+        local snippets = {}
+        local indicator = tonumber(data[index])
+        local span
+
+        if indicator >= limit_critical then
+            span = '<span color="black" bgcolor="' .. solarized.red .. '">'
+        elseif indicator >= limit_bad then
+            span = '<span color="black" bgcolor="' .. solarized.orange .. '">'
+        elseif indicator >= limit_show then
+            span = '<span color="' .. solarized.yellow .. '">'
+        else
+            span = '<span color="' .. solarized.base01 .. '">'
+        end
+
+        table.insert(snippets, span)
+        table.insert(snippets, entity .. ': ')
+        table.insert(snippets, vicious.helpers.format(format, data))
+        table.insert(snippets, '</span>')
+        table.insert(snippets, spacer)
+        local result = table.concat(snippets, '')
+        return result
+    end
 
-mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
-                                    { "open terminal", terminal }
-                                  }
-                        })
+    return formatter
+end
+
+batwidget = wibox.widget.textbox()
+vicious.register(batwidget, vicious.widgets.bat, bat_func, 15, "BAT0")
+
+netwidget = wibox.widget.textbox()
+vicious.register(netwidget, vicious.widgets.net, net_widget_function, 2)
+
+diowidget = wibox.widget.textbox()
+vicious.register(diowidget, vicious.widgets.dio, dio_widget_function, 2)
 
-mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
-                                     menu = mymainmenu })
+cpuwidget = wibox.widget.textbox()
+vicious.register(cpuwidget, vicious.widgets.cpu, widget_printer('CPU', '$1 %', 1, 20, 90, 101), 2)
 
+memwidget = wibox.widget.textbox()
+vicious.register(memwidget, vicious.widgets.mem, widget_printer('RAM', '$2 / $3 MB', 1, 75, 85, 95), 5)
+
+mytextclock = wibox.widget.textbox()
+vicious.register(mytextclock, vicious.widgets.date, wrap_with_color("%a, %Y-%m-%d <b>%H:%M</b> %z" .. spacer, 'blue'), 10)
+
+mysystray = wibox.widget.systray()
 -- Menubar configuration
 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
 -- }}}
 
 -- Keyboard map indicator and switcher
-mykeyboardlayout = awful.widget.keyboardlayout()
-
--- {{{ Wibox
--- Create a textclock widget
-mytextclock = awful.widget.textclock()
+-- mykeyboardlayout = wibox.widget.keyboardlayout()
 
 -- Create a wibox for each screen and add it
 mywibox = {}
@@ -124,8 +301,8 @@ mytaglist.buttons = awful.util.table.join(
                     awful.button({ modkey }, 1, awful.client.movetotag),
                     awful.button({ }, 3, awful.tag.viewtoggle),
                     awful.button({ modkey }, 3, awful.client.toggletag),
-                    awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
-                    awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
+                    awful.button({ }, 5, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
+                    awful.button({ }, 4, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
                     )
 mytasklist = {}
 mytasklist.buttons = awful.util.table.join(
@@ -156,11 +333,11 @@ mytasklist.buttons = awful.util.table.join(
                                               end
                                           end),
                      awful.button({ }, 4, function ()
-                                              awful.client.focus.byidx(1)
+                                              awful.client.focus.byidx(-1)
                                               if client.focus then client.focus:raise() end
                                           end),
                      awful.button({ }, 5, function ()
-                                              awful.client.focus.byidx(-1)
+                                              awful.client.focus.byidx(1)
                                               if client.focus then client.focus:raise() end
                                           end))
 
@@ -182,17 +359,20 @@ for s = 1, screen.count() do
     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
 
     -- Create the wibox
-    mywibox[s] = awful.wibox({ position = "top", screen = s })
+    mywibox[s] = awful.wibox({ position = "bottom", screen = s })
 
     -- Widgets that are aligned to the left
     local left_layout = wibox.layout.fixed.horizontal()
-    left_layout:add(mylauncher)
     left_layout:add(mytaglist[s])
     left_layout:add(mypromptbox[s])
 
     -- Widgets that are aligned to the right
     local right_layout = wibox.layout.fixed.horizontal()
-    right_layout:add(mykeyboardlayout)
+    right_layout:add(cpuwidget)
+    right_layout:add(memwidget)
+    right_layout:add(diowidget)
+    right_layout:add(netwidget)
+    right_layout:add(batwidget)
 
     if s == 1 then right_layout:add(wibox.widget.systray()) end
     right_layout:add(mytextclock)
@@ -267,6 +447,8 @@ globalkeys = awful.util.table.join(
     -- Prompt
     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
 
+    awful.key({ modkey },            "d",     function () awful.util.spawn("dolphin") end),
+    awful.key({ modkey },            "F12",     function () awful.util.spawn("lock-and-off") end),
     awful.key({ modkey }, "x",
               function ()
                   awful.prompt.run({ prompt = "Run Lua code: " },
@@ -278,30 +460,62 @@ globalkeys = awful.util.table.join(
     awful.key({ modkey }, "p", function() menubar.show() end)
 )
 
+function wrapped_kill(client)
+    if client.class == 'Plasma' then
+        return
+    end
+
+    client:kill()
+end
+
+function wrapped_fullscreen(client)
+    if client.class == 'Plasma' then
+        return
+    end
+
+    client.fullscreen = not client.fullscreen
+end
+
+function wrapped_minimize(client)
+    if client.class == 'Plasma' then
+        return
+    end
+
+    -- The client currently has the input focus, so it cannot be
+    -- minimized, since minimized clients can't have the focus.
+    client.minimized = true
+end
+
+function wrapped_maximize(client)
+    if client.class == 'Plasma' then
+        return
+    end
+
+    client.maximized_horizontal = not client.maximized_horizontal
+    client.maximized_vertical   = not client.maximized_vertical
+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,           }, "f",      wrapped_fullscreen),
+    awful.key({ modkey,           }, "c",      wrapped_kill),
     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                        ),
     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
-    awful.key({ modkey,           }, "n",
-        function (c)
-            -- The client currently has the input focus, so it cannot be
-            -- minimized, since minimized clients can't have the focus.
-            c.minimized = true
-        end),
-    awful.key({ modkey,           }, "m",
-        function (c)
-            c.maximized_horizontal = not c.maximized_horizontal
-            c.maximized_vertical   = not c.maximized_vertical
-        end)
+    awful.key({ modkey,           }, "n", wrapped_minimize),
+    awful.key({ modkey,           }, "m", wrapped_maximize)
 )
 
+-- Compute the maximum number of digit we need, limited to 9
+keynumber = 0
+for s = 1, screen.count() do
+   keynumber = math.min(12, math.max(#tags[s], keynumber));
+end
+
 -- Bind all key numbers to tags.
 -- Be careful: we use keycodes to make it works on any keyboard layout.
 -- This should map on the top row of your keyboard, usually 1 to 9.
-for i = 1, 9 do
+for i = 1, keynumber do
     globalkeys = awful.util.table.join(globalkeys,
         -- View tag only.
         awful.key({ modkey }, "#" .. i + 9,
@@ -356,22 +570,94 @@ root.keys(globalkeys)
 -- Rules to apply to new clients (through the "manage" signal).
 awful.rules.rules = {
     -- All clients will match this rule.
-    { rule = { },
-      properties = { border_width = beautiful.border_width,
-                     border_color = beautiful.border_normal,
-                     focus = awful.client.focus.filter,
-                     raise = true,
-                     keys = clientkeys,
-                     buttons = clientbuttons } },
-    { rule = { class = "MPlayer" },
-      properties = { floating = true } },
-    { rule = { class = "pinentry" },
-      properties = { floating = true } },
-    { rule = { class = "gimp" },
-      properties = { floating = true } },
-    -- Set Firefox to always map on tags number 2 of screen 1.
-    -- { rule = { class = "Firefox" },
-    --   properties = { tag = tags[1][2] } },
+    {
+        rule = { },
+        properties = {
+            border_width = beautiful.border_width,
+            border_color = beautiful.border_normal,
+            focus = true,
+            keys = clientkeys,
+            maximized_vertical = false,
+            maximized_horizontal = false,
+            buttons = clientbuttons,
+            callback = function(c)
+                if c.class == "Xournal" then
+                    c.screen = 2
+                    c:tags({tags[c.screen][1]})
+                else
+                    c.screen = 1
+                    --c:tags({tags[c.screen][1]})
+                end
+            end
+        }
+    },
+    {
+        rule = { class = "pinentry" },
+        properties = { floating = true }
+    },
+    {
+        rule = { class = "gimp" },
+        properties = { floating = true }
+    },
+    {
+        rule = { class = "Klipper" },
+        properties = { floating = true }
+    },
+    {
+        rule = { class = "Plasma-desktop" },
+        properties = { floating = true },
+        callback = function(c)
+            c:geometry( { width = 600 , height = 500 } )
+        end,
+    },
+--    {
+--        rule = { class = "plasmashell" },
+--        properties = { minimized = true },
+--    },
+    {
+        rule = { class = "Firefox" },
+        properties = { tag = tags[1][tag_for_www] }
+    },
+    {
+        rule = { class = "Rekonq" },
+        properties = { tag = tags[1][tag_for_www] }
+    },
+    {
+        rule = { class = "Skype" },
+        properties = { tag = tags[1][tag_for_im] }
+    },
+    {
+        rule = { class = "Kopete" },
+        properties = { tag = tags[1][tag_for_im] }
+    },
+    {
+        rule = { class = "Pidgin" },
+        properties = { tag = tags[1][tag_for_im] }
+    },
+    {
+        rule = { class = "Ekiga" },
+        properties = { tag = tags[1][tag_for_im] }
+    },
+    {
+        rule = { class = "Empathy" },
+        properties = { tag = tags[1][tag_for_im] }
+    },
+    {
+        rule = { class = "Linphone" },
+        properties = { tag = tags[1][tag_for_im] }
+    },
+    {
+        rule = { class = "Sflphone-client-kde" },
+        properties = { tag = tags[1][tag_for_im] }
+    },
+    {
+        rule = { class = "Clementine" },
+        properties = { tag = tags[1][tag_for_music] }
+    },
+    {
+        rule = { class = "Thunderbird" },
+        properties = { tag = tags[1][tag_for_eml] }
+    },
 }
 -- }}}
 
@@ -450,3 +736,14 @@ end)
 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
 -- }}}
+
+-- naughty.config.default_preset.timeout = 4
+
+awful.screen.focus(1)
+
+if screen.count() > 1 then
+    awful.tag.setncol(2, tags[1][tag_for_eml])
+    awful.tag.setmwfact(0.37, tags[1][tag_for_eml])
+end
+
+awful.util.spawn_with_shell("mu-wakeup")

Reply via email to