merge in the latest version of the default rc.lua
authorBenjamin Mako Hill <mako@atdot.cc>
Fri, 9 Oct 2020 17:23:21 +0000 (10:23 -0700)
committerBenjamin Mako Hill <mako@atdot.cc>
Fri, 9 Oct 2020 17:23:21 +0000 (10:23 -0700)
1  2 
rc.lua

diff --combined rc.lua
index c2c26c452d52c7a9c5a9b141846263bfc2f3ef51,9458979455685d0f79157c387f1be7eca7e99f26..2289a1217c81303dbae248c34bf3132e0bc189e4
--- 1/rc.lua
--- 2/rc.lua
+++ b/rc.lua
@@@ -1,16 -1,7 +1,20 @@@
 +-- read the timezone from /etc/timezone (this doesn't work, somehow)
 +local function read_tz_file(path)
 +    local file = io.open(path, "r") -- r read mode and b binary mode
 +    if not file then return nil end
 +    local content = file:read "*a" -- *a or *all reads the whole file
 +    file:close()
 +    content = content:gsub("^%s*", "")
 +    content = content:gsub("%s*$", "")
 +    return content
 +end
 +
 +local tz_string = read_tz_file("/etc/timezone")
 +
+ -- If LuaRocks is installed, make sure that packages installed through it are
+ -- found (e.g. lgi). If LuaRocks is not installed, do nothing.
+ pcall(require, "luarocks.loader")
  -- Standard awesome library
  local gears = require("gears")
  local awful = require("awful")
@@@ -22,14 -13,14 +26,18 @@@ local beautiful = require("beautiful"
  -- Notification library
  local naughty = require("naughty")
  local menubar = require("menubar")
- local hotkeys_popup = require("awful.hotkeys_popup").widget
+ local hotkeys_popup = require("awful.hotkeys_popup")
+ -- Enable hotkeys help widget for VIM and other apps
+ -- when client with a matching name is opened:
+ require("awful.hotkeys_popup.keys")
  
 +-- load the volume widget code and set settings
 +local volume_control = require("volume-control")
 +volumecfg = volume_control({})
 +
  -- Load Debian menu entries
- require("debian.menu")
+ local debian = require("debian.menu")
+ local has_fdo, freedesktop = pcall(require, "freedesktop")
  
  -- {{{ Error handling
  -- Check if awesome encountered an error during startup and fell back to
@@@ -58,9 -49,7 +66,8 @@@ en
  
  -- {{{ Variable definitions
  -- Themes define colours, icons, font and wallpapers.
- -- beautiful.init(awful.util.get_themes_dir() .. "default/theme.lua")
 -beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua")
 +beautiful.init(awful.util.get_themes_dir() .. "sky/theme.lua")
 +beautiful.wallpaper = "/home/mako/images/Flag_of_Cascadia.png"
  
  -- This is used later as the default terminal and editor to run.
  terminal = "x-terminal-emulator"
@@@ -76,42 -65,53 +83,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.bottom,
 -    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.max,
 -    awful.layout.suit.max.fullscreen,
 -    awful.layout.suit.magnifier,
 -    awful.layout.suit.corner.nw,
 -    -- awful.layout.suit.corner.ne,
 -    -- awful.layout.suit.corner.sw,
 -    -- awful.layout.suit.corner.se,
 +    awful.layout.suit.floating
  }
  -- }}}
  
- -- {{{ Helper functions
- local function client_menu_toggle_fn()
-     local instance = nil
-     return function ()
-         if instance and instance.wibox.visible then
-             instance:hide()
-             instance = nil
-         else
-             instance = awful.menu.clients({ theme = { width = 250 } })
-         end
-     end
- end
- -- }}}
  -- {{{ Menu
  -- Create a launcher widget and a main menu
  myawesomemenu = {
-    { "hotkeys", function() return false, hotkeys_popup.show_help end},
+    { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
     { "manual", terminal .. " -e man awesome" },
     { "edit config", editor_cmd .. " " .. awesome.conffile },
     { "restart", awesome.restart },
-    { "quit", function() awesome.quit() end}
+    { "quit", function() awesome.quit() end },
  }
  
- mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
-                                     { "Debian", debian.menu.Debian_menu.Debian },
-                                     { "open terminal", terminal }
-                                   }
-                         })
+ local menu_awesome = { "awesome", myawesomemenu, beautiful.awesome_icon }
+ local menu_terminal = { "open terminal", terminal }
+ if has_fdo then
+     mymainmenu = freedesktop.menu.build({
+         before = { menu_awesome },
+         after =  { menu_terminal }
+     })
+ else
+     mymainmenu = awful.menu({
+         items = {
+                   menu_awesome,
+                   { "Debian", debian.menu.Debian_menu.Debian },
+                   menu_terminal,
+                 }
+     })
+ end
  
  mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
                                       menu = mymainmenu })
@@@ -125,10 -125,10 +130,10 @@@ mykeyboardlayout = awful.widget.keyboar
  
  -- {{{ Wibar
  -- Create a textclock widget
 -mytextclock = wibox.widget.textclock()
 +mytextclock = wibox.widget.textclock("%a %m %d %H:%M", 60, tz_string)
  
  -- Create a wibox for each screen and add it
- local taglist_buttons = awful.util.table.join(
+ local taglist_buttons = gears.table.join(
                      awful.button({ }, 1, function(t) t:view_only() end),
                      awful.button({ modkey }, 1, function(t)
                                                if client.focus then
                      awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
                  )
  
- local tasklist_buttons = awful.util.table.join(
+ local tasklist_buttons = gears.table.join(
                       awful.button({ }, 1, function (c)
                                                if c == client.focus then
                                                    c.minimized = true
                                                else
-                                                   -- Without this, the following
-                                                   -- :isvisible() makes no sense
-                                                   c.minimized = false
-                                                   if not c:isvisible() and c.first_tag then
-                                                       c.first_tag:view_only()
-                                                   end
-                                                   -- This will also un-minimize
-                                                   -- the client, if needed
-                                                   client.focus = c
-                                                   c:raise()
+                                                   c:emit_signal(
+                                                       "request::activate",
+                                                       "tasklist",
+                                                       {raise = true}
+                                                   )
                                                end
                                            end),
-                      awful.button({ }, 3, client_menu_toggle_fn()),
+                      awful.button({ }, 3, function()
+                                               awful.menu.client_list({ theme = { width = 250 } })
+                                           end),
                       awful.button({ }, 4, function ()
                                                awful.client.focus.byidx(1)
                                            end),
@@@ -194,19 -191,27 +196,27 @@@ awful.screen.connect_for_each_screen(fu
  
      -- Create a promptbox for each screen
      s.mypromptbox = awful.widget.prompt()
-     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
+     -- Create an imagebox widget which will contain an icon indicating which layout we're using.
      -- We need one layoutbox per screen.
      s.mylayoutbox = awful.widget.layoutbox(s)
-     s.mylayoutbox:buttons(awful.util.table.join(
+     s.mylayoutbox:buttons(gears.table.join(
                             awful.button({ }, 1, function () awful.layout.inc( 1) end),
                             awful.button({ }, 3, function () awful.layout.inc(-1) end),
                             awful.button({ }, 4, function () awful.layout.inc( 1) end),
                             awful.button({ }, 5, function () awful.layout.inc(-1) end)))
      -- Create a taglist widget
-     s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
+     s.mytaglist = awful.widget.taglist {
+         screen  = s,
+         filter  = awful.widget.taglist.filter.all,
+         buttons = taglist_buttons
+     }
  
      -- Create a tasklist widget
-     s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
+     s.mytasklist = awful.widget.tasklist {
+         screen  = s,
+         filter  = awful.widget.tasklist.filter.currenttags,
+         buttons = tasklist_buttons
+     }
  
      -- Create the wibox
      s.mywibox = awful.wibar({ position = "top", screen = s })
              layout = wibox.layout.fixed.horizontal,
              mykeyboardlayout,
              wibox.widget.systray(),
 +          -- volumecfg.widget,
              mytextclock,
              s.mylayoutbox,
          },
  end)
  -- }}}
  
 +-- right_layout:add(volumecfg.widget)
 +
  -- {{{ Mouse bindings
- root.buttons(awful.util.table.join(
+ root.buttons(gears.table.join(
      awful.button({ }, 3, function () mymainmenu:toggle() end),
      awful.button({ }, 4, awful.tag.viewnext),
      awful.button({ }, 5, awful.tag.viewprev)
  -- }}}
  
  -- {{{ Key bindings
- globalkeys = awful.util.table.join(
+ globalkeys = gears.table.join(
      awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
                {description="show help", group="awesome"}),
      awful.key({ modkey,           }, "Left",   awful.tag.viewprev,
                    local c = awful.client.restore()
                    -- Focus restored client
                    if c then
-                       client.focus = c
-                       c:raise()
+                     c:emit_signal(
+                         "request::activate", "key.unminimize", {raise = true}
+                     )
                    end
                end,
                {description = "restore minimized", group = "client"}),
      -- Prompt
      awful.key({ modkey },            "r",     function () awful.screen.focused().mypromptbox:run() end,
                {description = "run prompt", group = "launcher"}),
 +    
 +    awful.key({ modkey,  }, "x",
 +              function ()
 +                  awful.prompt.run {
 +                    prompt       = "Run in terminal: ",
 +                    textbox      = awful.screen.focused().mypromptbox.widget,
 +                    exe_callback = function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end
 +                  }
 +              end,
 +              {description = "terminal execute prompt", group = "awesome"}),
  
 -    awful.key({ modkey }, "x",
 +    -- Mako's additional keybindings
 +    --- {{{
 +    awful.key({ modkey, "Shift", }, "x",
                function ()
                    awful.prompt.run {
                      prompt       = "Run Lua code: ",
                    }
                end,
                {description = "lua execute prompt", group = "awesome"}),
 +
 +    awful.key({ modkey }, "q",
 +                  function ()
 +                      awful.tag.incnmaster(-1)
 +                      awful.tag.incncol(3)
 +              end),
 +
 +    awful.key({ modkey, "Shift" }, "t", awful.titlebar.toggle),
 +
 +    --- }}}
 +
      -- Menubar
      awful.key({ modkey }, "p", function() menubar.show() end,
                {description = "show the menubar", group = "launcher"})
  )
  
- clientkeys = awful.util.table.join(
+ clientkeys = gears.table.join(
      awful.key({ modkey,           }, "f",
          function (c)
              c.fullscreen = not c.fullscreen
              c.maximized = not c.maximized
              c:raise()
          end ,
-         {description = "maximize", group = "client"})
+         {description = "(un)maximize", group = "client"}),
+     awful.key({ modkey, "Control" }, "m",
+         function (c)
+             c.maximized_vertical = not c.maximized_vertical
+             c:raise()
+         end ,
+         {description = "(un)maximize vertically", group = "client"}),
+     awful.key({ modkey, "Shift"   }, "m",
+         function (c)
+             c.maximized_horizontal = not c.maximized_horizontal
+             c:raise()
+         end ,
+         {description = "(un)maximize horizontally", group = "client"})
  )
  
  -- Bind all key numbers to tags.
- -- Be careful: we use keycodes to make it works on any keyboard layout.
+ -- Be careful: we use keycodes to make it work on any keyboard layout.
  -- This should map on the top row of your keyboard, usually 1 to 9.
  for i = 1, 9 do
-     globalkeys = awful.util.table.join(globalkeys,
+     globalkeys = gears.table.join(globalkeys,
          -- View tag only.
          awful.key({ modkey }, "#" .. i + 9,
                    function ()
                            end
                        end
                    end,
 -                  {description = "toggle focused client on tag #" .. i, group = "tag"})
 +                  {description = "toggle focused client on tag #" .. i, group = "tag"}),
 +        awful.key({}, "XF86AudioRaiseVolume", function() volumecfg:up() end),
 +        awful.key({}, "XF86AudioLowerVolume", function() volumecfg:down() end),
 +        awful.key({}, "XF86AudioMute",        function() volumecfg:toggle() end)
      )
  end
  
- clientbuttons = awful.util.table.join(
-     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
-     awful.button({ modkey }, 1, awful.mouse.client.move),
-     awful.button({ modkey }, 3, awful.mouse.client.resize))
+ clientbuttons = gears.table.join(
+     awful.button({ }, 1, function (c)
+         c:emit_signal("request::activate", "mouse_click", {raise = true})
+     end),
+     awful.button({ modkey }, 1, function (c)
+         c:emit_signal("request::activate", "mouse_click", {raise = true})
+         awful.mouse.client.move(c)
+     end),
+     awful.button({ modkey }, 3, function (c)
+         c:emit_signal("request::activate", "mouse_click", {raise = true})
+         awful.mouse.client.resize(c)
+     end)
+ )
  
  -- Set keys
  root.keys(globalkeys)
@@@ -482,30 -480,35 +514,35 @@@ awful.rules.rules = 
          instance = {
            "DTA",  -- Firefox addon DownThemAll.
            "copyq",  -- Includes session name in class.
+           "pinentry",
          },
          class = {
            "Arandr",
+           "Blueman-manager",
            "Gpick",
            "Kruler",
            "MessageWin",  -- kalarm.
            "Sxiv",
+           "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
            "Wpa_gui",
-           "pinentry",
            "veromix",
            "xtightvncviewer"},
  
+         -- Note that the name property shown in xprop might be set slightly after creation of the client
+         -- and the name shown there might not match defined rules here.
          name = {
            "Event Tester",  -- xev.
          },
          role = {
            "AlarmWindow",  -- Thunderbird's calendar.
+           "ConfigManager",  -- Thunderbird's about:config.
            "pop-up",       -- e.g. Google Chrome's (detached) Developer Tools.
          }
        }, properties = { floating = true }},
  
      -- Add titlebars to normal clients and dialogs
      { rule_any = {type = { "normal", "dialog" }
-       }, properties = { titlebars_enabled = false }
+       }, properties = { titlebars_enabled = true }
      },
  
      -- Set Firefox to always map on the tag named "2" on screen 1.
@@@ -521,8 -524,8 +558,8 @@@ client.connect_signal("manage", functio
      -- i.e. put it at the end of others instead of setting it master.
      -- if not awesome.startup then awful.client.setslave(c) end
  
-     if awesome.startup and
-       not c.size_hints.user_position
+     if awesome.startup
+       and not c.size_hints.user_position
        and not c.size_hints.program_position then
          -- Prevent clients from being unreachable after screen count changes.
          awful.placement.no_offscreen(c)
@@@ -532,15 -535,13 +569,13 @@@ end
  -- Add a titlebar if titlebars_enabled is set to true in the rules.
  client.connect_signal("request::titlebars", function(c)
      -- buttons for the titlebar
-     local buttons = awful.util.table.join(
+     local buttons = gears.table.join(
          awful.button({ }, 1, function()
-             client.focus = c
-             c:raise()
+             c:emit_signal("request::activate", "titlebar", {raise = true})
              awful.mouse.client.move(c)
          end),
          awful.button({ }, 3, function()
-             client.focus = c
-             c:raise()
+             c:emit_signal("request::activate", "titlebar", {raise = true})
              awful.mouse.client.resize(c)
          end)
      )
@@@ -573,12 -574,9 +608,9 @@@ end
  
  -- Enable sloppy focus, so that focus follows mouse.
  client.connect_signal("mouse::enter", function(c)
-     if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
-         and awful.client.focus.filter(c) then
-         client.focus = c
-     end
+     c:emit_signal("request::activate", "mouse_enter", {raise = false})
  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)
 --- }}}
 +-- }}}

Benjamin Mako Hill || Want to submit a patch?