summaryrefslogtreecommitdiff
path: root/rc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rc.lua')
-rw-r--r--rc.lua154
1 files changed, 84 insertions, 70 deletions
diff --git a/rc.lua b/rc.lua
index 3a7d225..0ac1499 100644
--- a/rc.lua
+++ b/rc.lua
@@ -1,3 +1,7 @@
+-- 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")
@@ -8,10 +12,11 @@ local wibox = require("wibox")
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
-local hotkeys_popup = require("awful.hotkeys_popup").widget
+local hotkeys_popup = require("awful.hotkeys_popup")
-- 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
@@ -45,7 +50,7 @@ local cal = require("widgets.cal")
-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
-beautiful.init(awful.util.getdir("config") .. "/ni/theme.lua")
+beautiful.init(gears.filesystem.get_configuration_dir() .. "ni/theme.lua")
-- This is used later as the default terminal and editor to run.
terminal = "x-terminal-emulator"
@@ -85,43 +90,38 @@ awful.layout.layouts = {
}
-- }}}
--- {{{ 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 })
--- Keyboard map indicator and switcher
-mykeyboardlayout = awful.widget.keyboardlayout()
-
-- {{{ Wibar
-- Create a textclock widget
mytextclock = wibox.widget.textclock()
@@ -163,7 +163,7 @@ myseparator.image = image(beautiful.widget_sep)
]]--
-- 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
@@ -180,24 +180,21 @@ local taglist_buttons = awful.util.table.join(
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),
@@ -229,23 +226,31 @@ awful.screen.connect_for_each_screen(function(s)
-- 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 = "bottom", screen = s, height =
- beautiful.wibar_height })
+ s.mywibox = awful.wibar({ position = "bottom", screen = s,
+ height = beautiful.wibar_height })
-- Add widgets to the wibox
s.mywibox:setup {
@@ -259,7 +264,6 @@ awful.screen.connect_for_each_screen(function(s)
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
- mykeyboardlayout,
wibox.widget.systray(),
myvolume,
mytextclock,
@@ -270,7 +274,7 @@ end)
-- }}}
-- {{{ 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)
@@ -278,7 +282,7 @@ root.buttons(awful.util.table.join(
-- }}}
-- {{{ Key bindings
-globalkeys = awful.util.table.join(
+globalkeys = gears.table.join(
awful.key({ modkey, "Shift" }, "#57", hotkeys_popup.show_help,
{description="show help", group="awesome"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore,
@@ -371,7 +375,7 @@ globalkeys = awful.util.table.join(
{description = "lua execute prompt", group = "awesome"})
)
-clientkeys = awful.util.table.join(
+clientkeys = gears.table.join(
awful.key({ modkey, }, "f",
function (c)
c.fullscreen = not c.fullscreen
@@ -393,7 +397,7 @@ clientkeys = awful.util.table.join(
)
-- 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.
local tagkeys = { "t", "s", "r", "n", "m" }
for i, v in ipairs(tagkeys) do
@@ -443,10 +447,19 @@ for i, v in ipairs(tagkeys) do
)
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)
@@ -473,30 +486,36 @@ 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 = true } },
+ -- { rule_any = {type = { "normal", "dialog" }
+ -- }, properties = { titlebars_enabled = true }
+ -- },
-- Set Firefox to always map on the tag named "2" on screen 1.
-- { rule = { class = "Firefox" },
@@ -523,8 +542,8 @@ client.connect_signal("manage", function (c)
-- 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)
@@ -534,15 +553,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)
)
@@ -575,10 +592,7 @@ 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)