rc.lua: Move some keys and apps auto start to config

This commit is contained in:
Alice Gaudon 2019-08-13 21:57:54 +02:00
parent c9c5755a26
commit 6d26491560
4 changed files with 530 additions and 405 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# IDEs
.idea/

View File

@ -6,11 +6,91 @@ local naughty = require("naughty")
local config = {} local config = {}
-- General
config.modkey = "Mod4"
-- Terminal --
config.terminal = "terminator" -- Awesome WM
--
config.awesome = {
-- Enable window autofocus on mouse hover
autofocus = true,
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
hotkeys_popup = true,
-- Terminal
terminal = "terminator",
-- Default terminal editor
-- editor = "vi",
editor = os.getenv("EDITOR") or "nano",
editor_cmd = config.awesome.terminal .. " -e " .. config.awesome.editor,
}
--
-- Keys / Hotkeys / Shortcuts
--
-- To disable a shortcut, simply remove it (tip: comment it out with a leading "--")
--
config.keys = {
-- Main modifier key for meta hotkeys like moving windows or locking the session
-- Usually, Mod4 is the key with a logo between Control and Alt.
modkey = "Mod4",
-- Hotkeys globally available (through the entire OS, regardless of what's focused)
globalkeys = {
media_control = {
--
-- Media and volume controls
-- See media_control.lua
--
-- Raise volume
raiseVolume = "XF86AudioRaiseVolume",
-- Lower volume
lowerVolume = "XF86AudioLowerVolume",
-- Toggle mute
toggleMute = "XF86AudioMute",
-- Toggle Play / Pause
playPause = "XF86AudioPlay",
-- Next track
nextTrack = "XF86AudioNext",
-- Previous track
previousTrack = "XF86AudioPrev",
},
},
}
--
-- Widgets
--
config.widgets = {
-- Enable/disable the system resources monitoring widget
system_resources = true,
}
--
-- Auto start custom applications
--
config.autostart = {
-- Network manager widget
{
"nm-applet --help", -- Verification command that will be checked before spawning the next command
"nm-applet", -- The app
},
-- Screenshot utility
"flameshot",
}
-- Theme -- Theme
-- Change to gears.filesystem.get_themes_dir() .. "default/theme.lua" to use default awesome theme -- Change to gears.filesystem.get_themes_dir() .. "default/theme.lua" to use default awesome theme
@ -18,8 +98,6 @@ config.theme = awful.util.getdir("config") .. "/default_theme.lua"
-- Screenshot utility -- Screenshot utility
config.screenshot_utility_command = "flameshot gui" config.screenshot_utility_command = "flameshot gui"
config.screenshot_utility_auto_start = true
config.screenshot_utility_auto_start_command = "flameshot"
-- Keyboard layout -- Keyboard layout
config.kbSwitchCmd = "setxkbmap" config.kbSwitchCmd = "setxkbmap"

View File

@ -1,9 +1,13 @@
--
-- Control playing music/media and sound volume -- Control playing music/media and sound volume
-- Currently supports : -- Currently supports :
-- - playerctl -- - playerctl
-- - Spotify -- - Spotify
--
--
-- DEBUG -- DEBUG
--
local inspect = require("debug/inspect") local inspect = require("debug/inspect")
local awful = require("awful") local awful = require("awful")
@ -34,6 +38,7 @@ function getVolume()
handle:close() handle:close()
return volume return volume
end end
function isMuted() function isMuted()
local handle = io.popen("amixer -D pulse sget Master | awk -F\"[][]\" '/[onf]{2,3}/ { print $4 }' | head -n -1", "r") local handle = io.popen("amixer -D pulse sget Master | awk -F\"[][]\" '/[onf]{2,3}/ { print $4 }' | head -n -1", "r")
local muted = string.gsub(handle:read("*a"), "[\n]+", "") == "off" local muted = string.gsub(handle:read("*a"), "[\n]+", "") == "off"
@ -56,7 +61,7 @@ function getVolumeImage(volume)
end end
local volumeWibox = wibox({ local volumeWibox = wibox({
ontop=true, ontop = true,
bg = beautiful.volume_osd_bg, bg = beautiful.volume_osd_bg,
border_width = beautiful.volume_osd_border_width, border_width = beautiful.volume_osd_border_width,
border_color = beautiful.volume_osd_border_color, border_color = beautiful.volume_osd_border_color,
@ -175,11 +180,25 @@ local toggleMute = function()
end end
-- }}} -- }}}
function getKeys(config)
return
-- Volume control
config.raiseVolume ~= nil and awful.key({}, config.raiseVolume, raiseVolume,
{ description = "Raise volume", group = "media control" }) or nil,
config.lowerVolume ~= nil and awful.key({}, config.lowerVolume, lowerVolume,
{ description = "Lower volume", group = "media control" }) or nil,
config.toggleMute ~= nil and awful.key({}, config.toggleMute, toggleMute,
{ description = "Toggle mute audio", group = "media control" }) or nil,
-- Media control
config.playPause ~= nil and awful.key({}, config.playPause, playPause,
{ description = "Toggle Play / Pause", group = "media control" }) or nil,
config.nextTrack ~= nil and awful.key({}, config.nextTrack, nextTrack,
{ description = "Next track", group = "media control" }) or nil,
config.previousTrack ~= nil and awful.key({}, config.previousTrack, previousTrack,
{ description = "Previous track", group = "media control" }) or nil
end
return { return {
playPause = playPause, getKeys = getKeys,
nextTrack = nextTrack,
previousTrack = previousTrack,
raiseVolume = raiseVolume,
lowerVolume = lowerVolume,
toggleMute = toggleMute
} }

586
rc.lua
View File

@ -1,93 +1,130 @@
-- If LuaRocks is installed, make sure that packages installed through it are --
-- found (e.g. lgi). If LuaRocks is not installed, do nothing. -- Simple Awesome main file - By Arisu & Arkhist
pcall(require, "luarocks.loader") -- To configure Simple Awesome without losing your changes when updating, see the `config.lua` file.
--
--
-- DEBUG -- DEBUG
--
local inspect = require("debug/inspect") local inspect = require("debug/inspect")
-- Standard awesome library --
local gears = require("gears") -- Simple Awesome configuration
--
local config = require("config")
--
-- Awesome WM
--
local awful = require("awful") local awful = require("awful")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful") local beautiful = require("beautiful")
-- Notification library local gears = require("gears")
local naughty = require("naughty") local naughty = require("naughty")
local menubar = require("menubar") local wibox = require("wibox")
-- Widgets and layout components
local hotkeys_popup = require("awful.hotkeys_popup") local hotkeys_popup = require("awful.hotkeys_popup")
-- Enable hotkeys help widget for VIM and other apps local menubar = require("menubar")
-- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")
-- Window autofocus
if config.awesome.autofocus then
require("awful.autofocus")
end
-- {{{ Error handling -- Hotkeys popup
-- Check if awesome encountered an error during startup and fell back to if hotkeys_popup then
-- another config (This code will only ever execute for the fallback config) require("awful.hotkeys_popup.keys")
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end end
-- Handle runtime errors after startup --
-- Error handling
--
-- Startup errors
if awesome.startup_errors then
naughty.notify({
preset = naughty.config.presets.critical,
title = "Something went wrong while booting Awesome",
text = awesome.startup_errors
})
end
-- Runtime errors handling routine
do do
local in_error = false local in_error = false
awesome.connect_signal("debug::error", function (err) awesome.connect_signal("debug::error", function(err)
-- Make sure we don't go into an endless error loop -- Make sure we don't go into an endless error loop
if in_error then return end if in_error then return end
in_error = true in_error = true
naughty.notify({ preset = naughty.config.presets.critical, naughty.notify({
title = "Oops, an error happened!", preset = naughty.config.presets.critical,
text = tostring(err) }) title = "An error happened during Awesome runtime",
text = tostring(err)
})
in_error = false in_error = false
end) end)
end end
-- }}}
-- Simple awesome start --
local config = require("config") -- Variables that need to be populated during the whole setup
--
-- {{{ Variable definitions -- Hotkeys
-- Themes define colours, icons, font and wallpapers. local globalkeys = {}
function registerKeys(...)
globalkeys = gears.table.join(globalkeys, ...)
end
--
-- Theme
--
beautiful.init(config.theme) beautiful.init(config.theme)
-- Media control
local media_control = require("media_control")
-- System Resources widget
local system_resources_widget = require("widgets/system_resources/system_resources")
--
-- Tiling -- Tiling
--
local tiling = require("tiling") local tiling = require("tiling")
-- Network widget
if os.execute("nm-applet --help") == true then
awful.spawn("nm-applet")
else
-- Support for more network managers should be requested via issues
end
-- Screenshot auto launch --
if config.screenshot_utility_auto_start then -- Media control keys and widget
awful.spawn(config.screenshot_utility_auto_start_command) --
local media_control = require("media_control")
registerKeys(media_control.getKeys(config.keys.globalkeys.media_control))
--
-- Widgets
--
-- System resources
local system_resources_widget
if config.widgets.system_resources then
system_resources_widget = require("widgets/system_resources/system_resources")
end end
-- This is used later as the default terminal and editor to run. --
editor = os.getenv("EDITOR") or "nano" -- Auto start
editor_cmd = config.terminal .. " -e " .. editor --
for _, app in ipairs(config.autostart) do
local type = type(app)
if type == "table" then -- Has a verification command that checks if it exists on the system
if os.execute(app[1]) == true then
awful.spawn(app[2])
end
elseif type == "string" then -- Simple command
awful.spawn(app)
end
end
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- 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 = config.modkey
-- Table of layouts to cover with awful.layout.inc, order matters. -- Table of layouts to cover with awful.layout.inc, order matters.
awful.layout.layouts = { awful.layout.layouts = {
@ -114,22 +151,26 @@ awful.layout.layouts = {
-- Create a launcher widget and a main menu -- Create a launcher widget and a main menu
myawesomemenu = { myawesomemenu = {
{ "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
{ "manual", config.terminal .. " -e man awesome" }, { "manual", config.awesome.terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awesome.conffile }, { "edit config", config.awesome.editor_cmd .. " " .. awesome.conffile },
{ "restart", awesome.restart }, { "restart", awesome.restart },
{ "quit", function() awesome.quit() end }, { "quit", function() awesome.quit() end },
} }
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, mymainmenu = awful.menu({
{ "open terminal", config.terminal } items = {
{ "awesome", myawesomemenu, beautiful.awesome_icon },
{ "open terminal", config.awesome.terminal }
} }
}) })
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, mylauncher = awful.widget.launcher({
menu = mymainmenu }) image = beautiful.awesome_icon,
menu = mymainmenu
})
-- Menubar configuration -- Menubar configuration
menubar.utils.terminal = config.terminal -- Set the terminal for applications that require it menubar.utils.terminal = config.awesome.terminal -- Set the terminal for applications that require it
-- }}} -- }}}
-- Keyboard map indicator and switcher -- Keyboard map indicator and switcher
@ -140,7 +181,7 @@ kbdlayout.cur = 1
kbdlayout.switch = function() kbdlayout.switch = function()
kbdlayout.cur = (kbdlayout.cur % #(config.kbLayouts)) + 1 kbdlayout.cur = (kbdlayout.cur % #(config.kbLayouts)) + 1
local t = config.kbLayouts[kbdlayout.cur] local t = config.kbLayouts[kbdlayout.cur]
os.execute( config.kbSwitchCmd .. " " .. t ) os.execute(config.kbSwitchCmd .. " " .. t)
end end
shutdown_icon = awesome.load_image(awful.util.getdir("config") .. "/icons/power.svg") shutdown_icon = awesome.load_image(awful.util.getdir("config") .. "/icons/power.svg")
@ -149,30 +190,39 @@ logout_icon = awesome.load_image(awful.util.getdir("config") .. "/icons/log-out.
lock_icon = awesome.load_image(awful.util.getdir("config") .. "/icons/lock.svg") lock_icon = awesome.load_image(awful.util.getdir("config") .. "/icons/lock.svg")
shutdownMenu_items = { shutdownMenu_items = {
{ "Shutdown", {
"Shutdown",
function() function()
os.execute('shutdown now') os.execute('shutdown now')
end, end,
shutdown_icon }, shutdown_icon
{ "Restart", },
{
"Restart",
function() function()
os.execute('shutdown -r now') os.execute('shutdown -r now')
end, end,
restart_icon }, restart_icon
{ "Logout", },
{
"Logout",
function() function()
awesome.quit() awesome.quit()
end, end,
logout_icon }, logout_icon
{ "Lock", },
{
"Lock",
function() function()
awful.spawn("xscreensaver-command -lock") awful.spawn("xscreensaver-command -lock")
end, end,
lock_icon } lock_icon
} }
}
shutdownMenu_launcher = awful.widget.launcher({ shutdownMenu_launcher = awful.widget.launcher({
image = beautiful.awesome_icon, image = beautiful.awesome_icon,
menu = awful.menu({ items = shutdownMenu_items}) }) menu = awful.menu({ items = shutdownMenu_items })
})
-- {{{ Wibar -- {{{ Wibar
@ -180,42 +230,37 @@ shutdownMenu_launcher = awful.widget.launcher({
mytextclock = wibox.widget.textclock() mytextclock = wibox.widget.textclock()
-- Create a wibox for each screen and add it -- Create a wibox for each screen and add it
local taglist_buttons = gears.table.join( local taglist_buttons = gears.table.join(awful.button({}, 1, function(t) t:view_only() end),
awful.button({ }, 1, function(t) t:view_only() end), awful.button({ config.keys.modkey }, 1, function(t)
awful.button({ modkey }, 1, function(t)
if client.focus then if client.focus then
client.focus:move_to_tag(t) client.focus:move_to_tag(t)
end end
end), end),
awful.button({ }, 3, awful.tag.viewtoggle), awful.button({}, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, function(t) awful.button({ config.keys.modkey }, 3, function(t)
if client.focus then if client.focus then
client.focus:toggle_tag(t) client.focus:toggle_tag(t)
end end
end), end),
awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end))
)
local tasklist_buttons = gears.table.join( local tasklist_buttons = gears.table.join(awful.button({}, 1, function(c)
awful.button({ }, 1, function (c)
if c == client.focus then if c == client.focus then
c.minimized = true c.minimized = true
else else
c:emit_signal( c:emit_signal("request::activate",
"request::activate",
"tasklist", "tasklist",
{raise = true} { raise = true })
)
end end
end), end),
awful.button({ }, 3, function() awful.button({}, 3, function()
awful.menu.client_list({ theme = { width = 250 } }) awful.menu.client_list({ theme = { width = 250 } })
end), end),
awful.button({ }, 4, function () awful.button({}, 4, function()
awful.client.focus.byidx(1) awful.client.focus.byidx(1)
end), end),
awful.button({ }, 5, function () awful.button({}, 5, function()
awful.client.focus.byidx(-1) awful.client.focus.byidx(-1)
end)) end))
@ -246,11 +291,10 @@ awful.screen.connect_for_each_screen(function(s)
-- Create an imagebox widget which will contain 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. -- We need one layoutbox per screen.
s.mylayoutbox = awful.widget.layoutbox(s) s.mylayoutbox = awful.widget.layoutbox(s)
s.mylayoutbox:buttons(gears.table.join( s.mylayoutbox:buttons(gears.table.join(awful.button({}, 1, function() awful.layout.inc(1) end),
awful.button({ }, 1, function () awful.layout.inc( 1) end), awful.button({}, 3, 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({ }, 4, function () awful.layout.inc( 1) end), awful.button({}, 5, function() awful.layout.inc(-1) end)))
awful.button({ }, 5, function () awful.layout.inc(-1) end)))
-- Create a taglist widget -- Create a taglist widget
s.mytaglist = awful.widget.taglist { s.mytaglist = awful.widget.taglist {
screen = s, screen = s,
@ -312,14 +356,16 @@ awful.screen.connect_for_each_screen(function(s)
-- Add widgets to the wibox -- Add widgets to the wibox
s.mywibox:setup { s.mywibox:setup {
layout = wibox.layout.align.horizontal, layout = wibox.layout.align.horizontal,
{ -- Left widgets {
-- Left widgets
layout = wibox.layout.fixed.horizontal, layout = wibox.layout.fixed.horizontal,
mylauncher, mylauncher,
s.mytaglist, s.mytaglist,
s.mypromptbox, s.mypromptbox,
}, },
s.mytasklist, -- Middle widget s.mytasklist, -- Middle widget
{ -- Right widgets {
-- Right widgets
matchesScreen(config.system_resources_widget_screens) and system_resources_widget.widget or nil, matchesScreen(config.system_resources_widget_screens) and system_resources_widget.widget or nil,
layout = wibox.layout.fixed.horizontal, layout = wibox.layout.fixed.horizontal,
mykeyboardlayout, mykeyboardlayout,
@ -333,49 +379,44 @@ end)
-- }}} -- }}}
-- {{{ Mouse bindings -- {{{ Mouse bindings
root.buttons(gears.table.join( root.buttons(gears.table.join(awful.button({}, 3, function() mymainmenu:toggle() end),
awful.button({ }, 3, function () mymainmenu:toggle() end), awful.button({}, 4, awful.tag.viewnext),
awful.button({ }, 4, awful.tag.viewnext), awful.button({}, 5, awful.tag.viewprev)))
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}} -- }}}
-- {{{ Key bindings -- {{{ Key bindings
globalkeys = gears.table.join( globalkeys = gears.table.join(globalkeys, awful.key({ config.keys.modkey, }, "s", hotkeys_popup.show_help,
awful.key({ modkey, }, "s", hotkeys_popup.show_help, { description = "show help", group = "awesome" }),
{description="show help", group="awesome"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore, awful.key({ config.keys.modkey, }, "Escape", awful.tag.history.restore,
{description = "go back", group = "tag"}), { description = "go back", group = "tag" }),
awful.key({ modkey, }, "j", awful.key({ config.keys.modkey, }, "j",
function () function()
awful.client.focus.byidx( 1) awful.client.focus.byidx(1)
end, end,
{description = "focus next by index", group = "client"} { description = "focus next by index", group = "client" }),
), awful.key({ config.keys.modkey, }, "k",
awful.key({ modkey, }, "k", function()
function ()
awful.client.focus.byidx(-1) awful.client.focus.byidx(-1)
end, end,
{description = "focus previous by index", group = "client"} { description = "focus previous by index", group = "client" }),
), awful.key({ config.keys.modkey, }, "w", function() mymainmenu:show() end,
awful.key({ modkey, }, "w", function () mymainmenu:show() end, { description = "show main menu", group = "awesome" }),
{description = "show main menu", group = "awesome"}),
-- Layout manipulation -- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end, awful.key({ config.keys.modkey, "Shift" }, "j", function() awful.client.swap.byidx(1) end,
{description = "swap with next client by index", group = "client"}), { description = "swap with next client by index", group = "client" }),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end, awful.key({ config.keys.modkey, "Shift" }, "k", function() awful.client.swap.byidx(-1) end,
{description = "swap with previous client by index", group = "client"}), { description = "swap with previous client by index", group = "client" }),
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, awful.key({ config.keys.modkey, "Control" }, "j", function() awful.screen.focus_relative(1) end,
{description = "focus the next screen", group = "screen"}), { description = "focus the next screen", group = "screen" }),
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, awful.key({ config.keys.modkey, "Control" }, "k", function() awful.screen.focus_relative(-1) end,
{description = "focus the previous screen", group = "screen"}), { description = "focus the previous screen", group = "screen" }),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto, awful.key({ config.keys.modkey, }, "u", awful.client.urgent.jumpto,
{description = "jump to urgent client", group = "client"}), { description = "jump to urgent client", group = "client" }),
awful.key({ modkey, }, "Tab", awful.key({ config.keys.modkey, }, "Tab",
function () function()
if config.windowSwitcher == "" then if config.windowSwitcher == "" then
awful.client.focus.history.previous() awful.client.focus.history.previous()
if client.focus then if client.focus then
@ -385,51 +426,49 @@ globalkeys = gears.table.join(
os.execute(config.windowSwitcher) os.execute(config.windowSwitcher)
end end
end, end,
{description = "switch window", group = "client"}), { description = "switch window", group = "client" }),
-- Standard program -- Standard program
awful.key({ modkey, }, "Return", function () awful.spawn(config.terminal) end, awful.key({ config.keys.modkey, }, "Return", function() awful.spawn(config.awesome.terminal) end,
{description = "open a terminal", group = "launcher"}), { description = "open a terminal", group = "launcher" }),
awful.key({ modkey, "Control" }, "r", awesome.restart, awful.key({ config.keys.modkey, "Control" }, "r", awesome.restart,
{description = "reload awesome", group = "awesome"}), { description = "reload awesome", group = "awesome" }),
awful.key({ modkey, "Shift" }, "q", awesome.quit, awful.key({ config.keys.modkey, "Shift" }, "q", awesome.quit,
{description = "quit awesome", group = "awesome"}), { description = "quit awesome", group = "awesome" }),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end, awful.key({ config.keys.modkey, }, "l", function() awful.tag.incmwfact(0.05) end,
{description = "increase master width factor", group = "layout"}), { description = "increase master width factor", group = "layout" }),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end, awful.key({ config.keys.modkey, }, "h", function() awful.tag.incmwfact(-0.05) end,
{description = "decrease master width factor", group = "layout"}), { description = "decrease master width factor", group = "layout" }),
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end, awful.key({ config.keys.modkey, "Shift" }, "h", function() awful.tag.incnmaster(1, nil, true) end,
{description = "increase the number of master clients", group = "layout"}), { description = "increase the number of master clients", group = "layout" }),
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end, awful.key({ config.keys.modkey, "Shift" }, "l", function() awful.tag.incnmaster(-1, nil, true) end,
{description = "decrease the number of master clients", group = "layout"}), { description = "decrease the number of master clients", group = "layout" }),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end, awful.key({ config.keys.modkey, "Control" }, "h", function() awful.tag.incncol(1, nil, true) end,
{description = "increase the number of columns", group = "layout"}), { description = "increase the number of columns", group = "layout" }),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end, awful.key({ config.keys.modkey, "Control" }, "l", function() awful.tag.incncol(-1, nil, true) end,
{description = "decrease the number of columns", group = "layout"}), { description = "decrease the number of columns", group = "layout" }),
awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, awful.key({ config.keys.modkey, }, "space", function() awful.layout.inc(1) end,
{description = "select next", group = "layout"}), { description = "select next", group = "layout" }),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end, awful.key({ config.keys.modkey, "Shift" }, "space", function() awful.layout.inc(-1) end,
{description = "select previous", group = "layout"}), { description = "select previous", group = "layout" }),
awful.key({ modkey, "Control" }, "n", awful.key({ config.keys.modkey, "Control" }, "n",
function () function()
local c = awful.client.restore() local c = awful.client.restore()
-- Focus restored client -- Focus restored client
if c then if c then
c:emit_signal( c:emit_signal("request::activate", "key.unminimize", { raise = true })
"request::activate", "key.unminimize", {raise = true}
)
end end
end, end,
{description = "restore minimized", group = "client"}), { description = "restore minimized", group = "client" }),
-- Prompt -- Prompt
awful.key({ modkey }, "r", function () os.execute(config.runMenu) end, awful.key({ config.keys.modkey }, "r", function() os.execute(config.runMenu) end,
{description = "show the run menu", group = "launcher"}), { description = "show the run menu", group = "launcher" }),
awful.key({ modkey }, "x", awful.key({ config.keys.modkey }, "x",
function () function()
awful.prompt.run { awful.prompt.run {
prompt = "Run Lua code: ", prompt = "Run Lua code: ",
textbox = awful.screen.focused().mypromptbox.widget, textbox = awful.screen.focused().mypromptbox.widget,
@ -437,95 +476,74 @@ globalkeys = gears.table.join(
history_path = awful.util.get_cache_dir() .. "/history_eval" history_path = awful.util.get_cache_dir() .. "/history_eval"
} }
end, end,
{description = "lua execute prompt", group = "awesome"}), { description = "lua execute prompt", group = "awesome" }),
-- Menubar -- Menubar
awful.key({ modkey }, "space", function() os.execute(config.runMenu) end, awful.key({ config.keys.modkey }, "space", function() os.execute(config.runMenu) end,
{description = "show the run menu", group = "launcher"}), { description = "show the run menu", group = "launcher" }),
-- Keyboard layout switch -- Keyboard layout switch
awful.key({ "Mod1" }, "Shift_L", function () kbdlayout.switch() end, awful.key({ "Mod1" }, "Shift_L", function() kbdlayout.switch() end,
{description = "switch keyboard layout"}), { description = "switch keyboard layout" }),
awful.key({ "Shift" }, "Alt_L", function () kbdlayout.switch() end, awful.key({ "Shift" }, "Alt_L", function() kbdlayout.switch() end,
{description = "switch keyboard layout"}), { description = "switch keyboard layout" }),
-- Flameshot -- Flameshot
awful.key({}, "Print", function () os.execute(config.screenshot_utility_command) end, awful.key({}, "Print", function() os.execute(config.screenshot_utility_command) end,
{description = "Take a screenshot using the screenshot utility", group="utilities"}), { description = "Take a screenshot using the screenshot utility", group = "utilities" }))
-- Media control
awful.key({}, "XF86AudioPlay", media_control.playPause,
{description = "Toggle Play / Pause", group="media control"}),
awful.key({}, "XF86AudioNext", media_control.nextTrack,
{description = "Next track", group="media control"}),
awful.key({}, "XF86AudioPrev", media_control.previousTrack,
{description = "Previous track", group="media control"}),
-- Volume control
awful.key({}, "XF86AudioRaiseVolume", media_control.raiseVolume,
{description = "Raise volume", group="media control"}),
awful.key({}, "XF86AudioLowerVolume", media_control.lowerVolume,
{description = "Lower volume", group="media control"}),
awful.key({}, "XF86AudioMute", media_control.toggleMute,
{description = "Toggle mute audio", group="media control"})
)
clientkeys = gears.table.join( clientkeys = gears.table.join(-- tiling
-- tiling awful.key({ config.keys.modkey, }, "Right",
awful.key({modkey,}, "Right",
tiling.key.tileRight, tiling.key.tileRight,
{description = "Tile right", group = "tiling"} { description = "Tile right", group = "tiling" }),
), awful.key({ config.keys.modkey, }, "Left",
awful.key({modkey,}, "Left",
tiling.key.tileLeft, tiling.key.tileLeft,
{description = "Tile left", group = "tiling"} { description = "Tile left", group = "tiling" }),
), awful.key({ config.keys.modkey, }, "Up",
awful.key({modkey,}, "Up",
tiling.key.toggleMaximized, tiling.key.toggleMaximized,
{description = "Toggle maximized", group = "tiling"} { description = "Toggle maximized", group = "tiling" }),
), awful.key({ config.keys.modkey, }, "Down",
awful.key({modkey,}, "Down",
tiling.key.minimize, tiling.key.minimize,
{description = "Lower", group = "tiling"} { description = "Lower", group = "tiling" }),
),
awful.key({ modkey, }, "f", awful.key({ config.keys.modkey, }, "f",
function (c) function(c)
c.fullscreen = not c.fullscreen c.fullscreen = not c.fullscreen
c:raise() c:raise()
end, end,
{description = "toggle fullscreen", group = "client"}), { description = "toggle fullscreen", group = "client" }),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end, awful.key({ config.keys.modkey, "Shift" }, "c", function(c) c:kill() end,
{description = "close", group = "client"}), { description = "close", group = "client" }),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle , awful.key({ config.keys.modkey, "Control" }, "space", awful.client.floating.toggle,
{description = "toggle floating", group = "client"}), { description = "toggle floating", group = "client" }),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end, awful.key({ config.keys.modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end,
{description = "move to master", group = "client"}), { description = "move to master", group = "client" }),
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end, awful.key({ config.keys.modkey, }, "o", function(c) c:move_to_screen() end,
{description = "move to screen", group = "client"}), { description = "move to screen", group = "client" }),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, awful.key({ config.keys.modkey, }, "t", function(c) c.ontop = not c.ontop end,
{description = "toggle keep on top", group = "client"}), { description = "toggle keep on top", group = "client" }),
awful.key({ modkey, }, "n", awful.key({ config.keys.modkey, }, "n",
function (c) function(c)
-- The client currently has the input focus, so it cannot be -- The client currently has the input focus, so it cannot be
-- minimized, since minimized clients can't have the focus. -- minimized, since minimized clients can't have the focus.
c.minimized = true c.minimized = true
end , end,
{description = "minimize", group = "client"}), { description = "minimize", group = "client" }),
awful.key({ modkey, }, "m", awful.key({ config.keys.modkey, }, "m",
function (c) function(c)
c.maximized = not c.maximized c.maximized = not c.maximized
c:raise() c:raise()
end , end,
{description = "(un)maximize", group = "client"}), { description = "(un)maximize", group = "client" }),
awful.key({ modkey, "Control" }, "m", awful.key({ config.keys.modkey, "Control" }, "m",
function (c) function(c)
c.maximized_vertical = not c.maximized_vertical c.maximized_vertical = not c.maximized_vertical
c:raise() c:raise()
end , end,
{description = "(un)maximize vertically", group = "client"}), { description = "(un)maximize vertically", group = "client" }),
awful.key({ modkey, "Shift" }, "m", awful.key({ config.keys.modkey, "Shift" }, "m",
function (c) function(c)
c.maximized_horizontal = not c.maximized_horizontal c.maximized_horizontal = not c.maximized_horizontal
c:raise() c:raise()
end , end,
{description = "(un)maximize horizontally", group = "client"}) { description = "(un)maximize horizontally", group = "client" }))
)
-- Bind all key numbers to tags. -- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it work on any keyboard layout. -- Be careful: we use keycodes to make it work on any keyboard layout.
@ -533,28 +551,28 @@ clientkeys = gears.table.join(
for i = 1, 9 do for i = 1, 9 do
globalkeys = gears.table.join(globalkeys, globalkeys = gears.table.join(globalkeys,
-- View tag only. -- View tag only.
awful.key({ modkey }, "#" .. i + 9, awful.key({ config.keys.modkey }, "#" .. i + 9,
function () function()
local screen = awful.screen.focused() local screen = awful.screen.focused()
local tag = screen.tags[i] local tag = screen.tags[i]
if tag then if tag then
tag:view_only() tag:view_only()
end end
end, end,
{description = "view tag #"..i, group = "tag"}), { description = "view tag #" .. i, group = "tag" }),
-- Toggle tag display. -- Toggle tag display.
awful.key({ modkey, "Control" }, "#" .. i + 9, awful.key({ config.keys.modkey, "Control" }, "#" .. i + 9,
function () function()
local screen = awful.screen.focused() local screen = awful.screen.focused()
local tag = screen.tags[i] local tag = screen.tags[i]
if tag then if tag then
awful.tag.viewtoggle(tag) awful.tag.viewtoggle(tag)
end end
end, end,
{description = "toggle tag #" .. i, group = "tag"}), { description = "toggle tag #" .. i, group = "tag" }),
-- Move client to tag. -- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9, awful.key({ config.keys.modkey, "Shift" }, "#" .. i + 9,
function () function()
if client.focus then if client.focus then
local tag = client.focus.screen.tags[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
@ -562,10 +580,10 @@ for i = 1, 9 do
end end
end end
end, end,
{description = "move focused client to tag #"..i, group = "tag"}), { description = "move focused client to tag #" .. i, group = "tag" }),
-- Toggle tag on focused client. -- Toggle tag on focused client.
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, awful.key({ config.keys.modkey, "Control", "Shift" }, "#" .. i + 9,
function () function()
if client.focus then if client.focus then
local tag = client.focus.screen.tags[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
@ -573,23 +591,20 @@ for i = 1, 9 do
end end
end end
end, end,
{description = "toggle focused client on tag #" .. i, group = "tag"}) { description = "toggle focused client on tag #" .. i, group = "tag" }))
)
end end
clientbuttons = gears.table.join( clientbuttons = gears.table.join(awful.button({}, 1, function(c)
awful.button({ }, 1, function (c) c:emit_signal("request::activate", "mouse_click", { raise = true })
c:emit_signal("request::activate", "mouse_click", {raise = true}) end),
end), awful.button({ config.keys.modkey }, 1, function(c)
awful.button({ modkey }, 1, function (c) c:emit_signal("request::activate", "mouse_click", { raise = true })
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.move(c) awful.mouse.client.move(c)
end), end),
awful.button({ modkey }, 3, function (c) awful.button({ config.keys.modkey }, 3, function(c)
c:emit_signal("request::activate", "mouse_click", {raise = true}) c:emit_signal("request::activate", "mouse_click", { raise = true })
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end))
)
-- Set keys -- Set keys
root.keys(globalkeys) root.keys(globalkeys)
@ -599,20 +614,23 @@ root.keys(globalkeys)
-- Rules to apply to new clients (through the "manage" signal). -- Rules to apply to new clients (through the "manage" signal).
awful.rules.rules = { awful.rules.rules = {
-- All clients will match this rule. -- All clients will match this rule.
{ rule = { }, {
properties = { border_width = beautiful.border_width, rule = {},
properties = {
border_width = beautiful.border_width,
border_color = beautiful.border_normal, border_color = beautiful.border_normal,
focus = awful.client.focus.filter, focus = awful.client.focus.filter,
raise = true, raise = true,
keys = clientkeys, keys = clientkeys,
buttons = clientbuttons, buttons = clientbuttons,
screen = awful.screen.preferred, screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen placement = awful.placement.no_overlap + awful.placement.no_offscreen
} }
}, },
-- Floating clients. -- Floating clients.
{ rule_any = { {
rule_any = {
instance = { instance = {
"DTA", -- Firefox addon DownThemAll. "DTA", -- Firefox addon DownThemAll.
"copyq", -- Includes session name in class. "copyq", -- Includes session name in class.
@ -628,7 +646,8 @@ awful.rules.rules = {
"Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
"Wpa_gui", "Wpa_gui",
"veromix", "veromix",
"xtightvncviewer"}, "xtightvncviewer"
},
-- Note that the name property shown in xprop might be set slightly after creation of the client -- 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. -- and the name shown there might not match defined rules here.
@ -640,11 +659,16 @@ awful.rules.rules = {
"ConfigManager", -- Thunderbird's about:config. "ConfigManager", -- Thunderbird's about:config.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools. "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
} }
}, properties = { floating = true }}, },
properties = { floating = true }
},
-- Add titlebars to normal clients and dialogs -- 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. -- Set Firefox to always map on the tag named "2" on screen 1.
@ -655,7 +679,7 @@ awful.rules.rules = {
-- {{{ Signals -- {{{ Signals
-- Signal function to execute when a new client appears. -- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c) client.connect_signal("manage", function(c)
-- Set the windows at the slave, -- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master. -- 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 not awesome.startup then awful.client.setslave(c) end
@ -671,37 +695,39 @@ end)
-- Add a titlebar if titlebars_enabled is set to true in the rules. -- Add a titlebar if titlebars_enabled is set to true in the rules.
client.connect_signal("request::titlebars", function(c) client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar -- buttons for the titlebar
local buttons = gears.table.join( local buttons = gears.table.join(awful.button({}, 1, function()
awful.button({ }, 1, function() c:emit_signal("request::activate", "titlebar", { raise = true })
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.move(c) awful.mouse.client.move(c)
end), end),
awful.button({ }, 3, function() awful.button({}, 3, function()
c:emit_signal("request::activate", "titlebar", {raise = true}) c:emit_signal("request::activate", "titlebar", { raise = true })
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end))
)
awful.titlebar(c) : setup { awful.titlebar(c):setup {
{ -- Left {
-- Left
awful.titlebar.widget.iconwidget(c), awful.titlebar.widget.iconwidget(c),
buttons = buttons, buttons = buttons,
layout = wibox.layout.fixed.horizontal layout = wibox.layout.fixed.horizontal
}, },
{ -- Middle {
{ -- Title -- Middle
{
-- Title
align = "center", align = "center",
widget = awful.titlebar.widget.titlewidget(c) widget = awful.titlebar.widget.titlewidget(c)
}, },
buttons = buttons, buttons = buttons,
layout = wibox.layout.flex.horizontal layout = wibox.layout.flex.horizontal
}, },
{ -- Right {
awful.titlebar.widget.floatingbutton (c), -- Right
awful.titlebar.widget.floatingbutton(c),
awful.titlebar.widget.maximizedbutton(c), awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.stickybutton (c), awful.titlebar.widget.stickybutton(c),
awful.titlebar.widget.ontopbutton (c), awful.titlebar.widget.ontopbutton(c),
awful.titlebar.widget.closebutton (c), awful.titlebar.widget.closebutton(c),
layout = wibox.layout.fixed.horizontal() layout = wibox.layout.fixed.horizontal()
}, },
layout = wibox.layout.align.horizontal layout = wibox.layout.align.horizontal
@ -710,7 +736,7 @@ end)
-- Enable sloppy focus, so that focus follows mouse. -- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c) client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false}) c:emit_signal("request::activate", "mouse_enter", { raise = false })
end) end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)