radix/files/awesome/rc.lua

1035 lines
38 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- awesome_mode: api-level=4:screen=on
-- 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")
-- @DOC_REQUIRE_SECTION@
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
require("collision")()
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
-- Declarative object management
local ruled = require("ruled")
local menubar = require("menubar")
local hotkeys_popup = require("awful.hotkeys_popup")
-- Freedesktop
local freedesktop = require("freedesktop")
-- Lain utils
local lain = require("lain")
-- DPI
local dpi = require("beautiful.xresources").apply_dpi
-- Table
local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
-- require("awful.hotkeys_popup.keys")
-- {{{ 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)
-- @DOC_ERROR_HANDLING@
naughty.connect_signal("request::display_error", function(message, startup)
naughty.notification {
urgency = "critical",
title = "Oops, an error happened"..(startup and " during startup!" or "!"),
message = message
}
end)
-- }}}
-- {{{ Variable definitions
-- @DOC_LOAD_THEME@
-- Themes define colours, icons, font and wallpapers.
beautiful.init(gears.filesystem.get_dir("config").."/themes/current-theme.lua")
local theme = beautiful.get()
-- @DOC_DEFAULT_APPLICATIONS@
-- This is used later as the default terminal and editor to run.
terminal = "xst"
editor = "kak"
browser = "icecat"
editor_cmd = terminal.." -e "..editor
file_manager = terminal.." -g 137x31-320+16 -c Lf -e "..gears.filesystem.get_dir("config").."/../lf/lfrun"
irc_client = terminal.." -g 137x31-320+16 -c Weechat -e weechat"
rss_reader = terminal.." -g 137x31-320+16 -e newsraft"
music_player = terminal.." -g 137x31-320+16 -e ncmpcpp"
link_handler = "dmenu_link"
-- 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 = "Mod4"
altkey = "Mod1"
-- }}}
-- {{{ Menu
-- @DOC_MENU@
-- Create a launcher widget and a main menu
myawesomemenu = {
{ "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 },
}
mymainmenu = freedesktop.menu.build {
before = {
{ "awesome", myawesomemenu },
-- other triads can be put here
},
after = {
{ "open terminal", terminal },
-- other triads can be put here
}
}
mylauncher = awful.widget.launcher({
image = beautiful.awesome_icon,
menu = mymainmenu
})
-- Menubar configuration
menubar.utils.terminal = terminal
-- }}}
-- {{{ Tag layout
-- @DOC_LAYOUT@
-- Table of layouts to cover with awful.layout.inc, order matters.
tag.connect_signal("request::default_layouts",
function()
awful.layout.append_default_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.max,
--awful.layout.suit.fair,
--awful.layout.suit.fair.horizontal,
--awful.layout.suit.spiral,
--awful.layout.suit.spiral.dwindle,
--awful.layout.suit.max.fullscreen,
--awful.layout.suit.magnifier,
--awful.layout.suit.corner.nw,
})
end)
-- }}}
-- {{{ Wallpaper
-- @DOC_WALLPAPER@
screen.connect_signal("request::wallpaper",
function(s)
awful.wallpaper {
screen = s,
widget = {
{
image = beautiful.wallpaper,
upscale = true,
downscale = true,
widget = wibox.widget.imagebox,
},
valign = "center",
halign = "center",
tiled = false,
widget = wibox.container.tile,
}
}
end)
-- }}}
-- {{{ Wibar
local markup = lain.util.markup
local separators = lain.util.separators
-- Keyboard map indicator and switcher
mykeyboardlayout = awful.widget.keyboardlayout()
-- Create a textclock widget
mytextclock = wibox.widget.textclock()
local clock = awful.widget.watch(
"date +'%a %d %b %R'", 60,
function(widget, stdout)
widget:set_markup(" " .. markup.font(beautiful.font, stdout))
end
)
-- Calendar
beautiful.cal = lain.widget.cal({
icons = "",
attach_to = { clock },
notification_preset = {
font = beautiful.font,
fg = beautiful.fg_normal,
bg = beautiful.bg_normal
}
})
-- MPD
local musicplr = terminal .. " -title Music -g 137x31-320+16 -e ncmpcpp"
local mpdicon = wibox.widget.imagebox(beautiful.widget_music)
mpdicon:buttons(my_table.join(
awful.button({ modkey }, 1, function () awful.spawn.with_shell(musicplr) end),
awful.button({ }, 1, function ()
os.execute("mpc prev")
beautiful.mpd.update()
end),
awful.button({ }, 2, function ()
os.execute("mpc toggle")
beautiful.mpd.update()
end),
awful.button({ }, 3, function ()
os.execute("mpc next")
beautiful.mpd.update()
end)))
beautiful.mpd = lain.widget.mpd({
settings = function()
if mpd_now.state == "play" then
artist = mpd_now.artist .. " "
title = mpd_now.title .. " "
mpdicon:set_image(beautiful.widget_music_on)
elseif mpd_now.state == "pause" then
artist = "mpd "
title = "paused "
else
artist = ""
title = ""
mpdicon:set_image(beautiful.widget_music)
end
widget:set_markup(markup.font(beautiful.font, markup("#8581E0", artist) .. title))
end
})
-- Mail IMAP check
--[[
local mailicon = wibox.widget.imagebox(beautiful.widget_mail)
mailicon:buttons(my_table.join(awful.button({ }, 1, function () awful.spawn(mail) end)))
beautiful.mail = lain.widget.imap({
timeout = 180,
server = "server",
mail = "luisguilhermecoelho@usp.br",
password = "",
settings = function()
if mailcount > 0 then
widget:set_markup(markup.font(beautiful.font, " " .. mailcount .. " "))
mailicon:set_image(beautiful.widget_mail_on)
else
widget:set_text("")
mailicon:set_image(beautiful.widget_mail)
end
end
})
--]]
-- MEM
local memicon = wibox.widget.imagebox(beautiful.widget_mem)
local mem = lain.widget.mem({
settings = function()
widget:set_markup(markup.font(beautiful.font, mem_now.used .. "MB "))
end
})
-- CPU
local cpuicon = wibox.widget.imagebox(beautiful.widget_cpu)
local cpu = lain.widget.cpu({
settings = function()
widget:set_markup(markup.font(beautiful.font, cpu_now.usage .. "% "))
end
})
-- Coretemp
local tempicon = wibox.widget.imagebox(beautiful.widget_temp)
local temp = lain.widget.temp({
settings = function()
widget:set_markup(markup.font(beautiful.font, math.ceil(coretemp_now) .. "°C "))
end
})
-- Battery
local baticon = wibox.widget.imagebox(beautiful.widget_battery)
local bat = lain.widget.bat({
settings = function()
if bat_now.status and bat_now.status ~= "N/A" then
if bat_now.ac_status == 1 then
baticon:set_image(beautiful.widget_ac)
elseif bat_now.perc and tonumber(bat_now.perc) < 25 then
baticon:set_image(beautiful.widget_battery_20)
elseif bat_now.perc and tonumber(bat_now.perc) < 45 then
baticon:set_image(beautiful.widget_battery_40)
elseif bat_now.perc and tonumber(bat_now.perc) < 65 then
baticon:set_image(beautiful.widget_battery_60)
elseif bat_now.perc and tonumber(bat_now.perc) < 85 then
baticon:set_image(beautiful.widget_battery_80)
else
baticon:set_image(beautiful.widget_battery_100)
end
widget:set_markup(markup.font(beautiful.font, bat_now.perc .. "% "))
else
widget:set_markup(markup.font(beautiful.font, "AC "))
baticon:set_image(beautiful.widget_ac)
end
end
})
-- ALSA volume
local volicon = wibox.widget.imagebox(beautiful.widget_vol)
beautiful.volume = lain.widget.alsa({
settings = function()
if volume_now.status == "off" then
volicon:set_image(beautiful.widget_vol_mute)
elseif volume_now.level then
if tonumber(volume_now.level) == 0 then
volicon:set_image(beautiful.widget_vol_no)
elseif tonumber(volume_now.level) <= 50 then
volicon:set_image(beautiful.widget_vol_low)
else
volicon:set_image(beautiful.widget_vol)
end
end
widget:set_markup(markup.font(beautiful.font, volume_now.level .. "% "))
end
})
beautiful.volume.widget:buttons(awful.util.table.join(
awful.button({}, 4, function ()
awful.util.spawn("amixer set Master 1%+")
beautiful.volume.update()
end),
awful.button({}, 5, function ()
awful.util.spawn("amixer set Master 1%-")
beautiful.volume.update()
end)
))
-- Net
local netdownicon = wibox.widget.imagebox(beautiful.widget_netdown)
local netdowninfo = wibox.widget.textbox()
local netupicon = wibox.widget.imagebox(beautiful.widget_netup)
local netupinfo = lain.widget.net({
settings = function()
widget:set_markup(markup.font(beautiful.font, net_now.sent .. " "))
netdowninfo:set_markup(markup.font(beautiful.font, net_now.received .. " "))
end
})
-- Separators
local spr = wibox.widget.textbox(' ')
local arrl_dl = separators.arrow_left(beautiful.bg_focus, "alpha")
local arrl_ld = separators.arrow_left("alpha", beautiful.bg_focus)
-- @DOC_FOR_EACH_SCREEN@
screen.connect_signal("request::desktop_decoration", function(s)
-- Each screen has its own tag table.
awful.tag({ "α", "β", "γ", "δ", "ε", "ζ", "η" }, s, awful.layout.layouts[1])
-- Create a promptbox for each screen
s.mypromptbox = awful.widget.prompt()
-- 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 {
screen = s,
buttons = {
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 {
screen = s,
filter = awful.widget.taglist.filter.all,
buttons = {
awful.button({ }, 1, function(t) t:view_only() end),
awful.button({ modkey }, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, function(t)
if client.focus then
client.focus:toggle_tag(t)
end
end),
-- Changing workspaces with scroll is so irritating
-- awful.button({ }, 4, function(t) awful.tag.viewprev(t.screen) end),
-- awful.button({ }, 5, function(t) awful.tag.viewnext(t.screen) end),
}
}
-- @TASKLIST_BUTTON@
-- Create a tasklist widget
s.mytasklist = awful.widget.tasklist {
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = {
awful.button({ }, 1, function (c)
c:activate { context = "tasklist", action = "toggle_minimization" }
end),
awful.button({ }, 3, function() awful.menu.client_list { theme = { width = 250 } } end),
awful.button({ }, 4, function() awful.client.focus.byidx(-1) end),
awful.button({ }, 5, function() awful.client.focus.byidx( 1) end),
}
}
-- @DOC_WIBAR@
-- Create the wibox
s.mywibox = awful.wibar {
height = dpi(19),
position = "top",
screen = s,
-- @DOC_SETUP_WIDGETS@
widget = {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
--mylauncher,
s.mytaglist,
s.mypromptbox,
},
-- Middle widget
s.mytasklist,
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
--mykeyboardlayout,
--wibox.widget.systray(),
spr,
arrl_ld,
wibox.container.background(netdownicon, beautiful.bg_focus),
wibox.container.background(netdowninfo, beautiful.bg_focus),
wibox.container.background(netupicon, beautiful.bg_focus),
wibox.container.background(netupinfo.widget, beautiful.bg_focus),
arrl_dl,
wibox.container.background(memicon, beautiful.bg_normal),
wibox.container.background(mem.widget, beautiful.bg_normal),
arrl_ld,
wibox.container.background(cpuicon, beautiful.bg_focus),
wibox.container.background(cpu.widget, beautiful.bg_focus),
arrl_dl,
wibox.container.background(tempicon, beautiful.bg_normal),
wibox.container.background(temp.widget, beautiful.bg_normal),
arrl_ld,
wibox.container.background(volicon, beautiful.bg_focus),
wibox.container.background(beautiful.volume.widget, beautiful.bg_focus),
arrl_dl,
wibox.container.background(baticon, beautiful.bg_normal),
wibox.container.background(bat.widget, beautiful.bg_normal),
arrl_ld,
wibox.container.background(clock, beautiful.bg_focus),
wibox.container.background(spr, beautiful.bg_focus),
arrl_dl,
wibox.container.background(s.mylayoutbox, beautiful.bg_normal),
},
}
}
--[[
s.mybottomwibox = awful.wibar {
height = dpi(19),
position = "bottom",
screen = s,
-- @DOC_SETUP_WIDGETS@
widget = {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
--s.mypromptbox,
spr,--mylauncher,
--s.mytaglist,
--s.mypromptbox,
},
-- Middle widget
--s.mytasklist,
spr,
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
--mykeyboardlayout,
--wibox.widget.systray(),
spr,
arrl_ld,
wibox.container.background(mpdicon, theme.bg_focus),
wibox.container.background(beautiful.mpd.widget, theme.bg_focus),
--arrl_dl,
--wibox.container.background(mailicon, theme.bg_normal),
--wibox.container.background(beautiful.mail.widget, theme.bg_normal),
},
}
}
--]]
end)
-- }}}
-- {{{ Mouse bindings
-- @DOC_ROOT_BUTTONS@
awful.mouse.append_global_mousebindings({
awful.button({ }, 2, function () mymainmenu:toggle() end),
--awful.button({ }, 4, awful.tag.viewprev),
--awful.button({ }, 5, awful.tag.viewnext),
})
-- }}}
-- {{{ Key bindings
-- @DOC_GLOBAL_KEYBINDINGS@
-- General Awesome keys
awful.keyboard.append_global_keybindings({
awful.key({ modkey, }, "s",
function () hotkeys_popup.widget.new(
{ width = 909,
height = 0.525*awful.screen.focused().workarea.height,
font = "Meslo LG M DZ 8",
description_font = "Meslo LG M DZ 8"}):show_help() end,
{description="show help", group="awesome"}),
--[[awful.key({ modkey, }, "w", function ()
mymainmenu:show() end,
{description = "show main menu", group = "awesome"}), ]]
awful.key({ modkey, "Control" }, "r", awesome.restart,
{description = "reload awesome", group = "awesome"}),
awful.key({ modkey, "Control" }, "q", awesome.quit,
{description = "quit awesome", group = "awesome"}),
awful.key({ altkey, }, "Print", function ()
os.execute("screenshot activewindow") end,
{description = "print focused window", group = "launcher"}),
awful.key({ }, "Print", function ()
os.execute("screenshot selectregion") end,
{description = "print selected region", group = "launcher"}),
awful.key({ }, "XF86WebCam", function ()
os.execute("cam") end,
{description = "run cam", group = "launcher"}),
awful.key({ modkey, }, "c", function ()
awful.spawn("keepassxc") end,
{description = "run keepassxc", group = "launcher"}),
awful.key({ modkey, }, "a", function ()
awful.spawn("telegram-desktop") end,
{description = "run telegram-desktop", group = "launcher"}),
awful.key({ modkey, }, "r", function ()
awful.spawn.with_shell("notify-send $(rem)") end,
{description = "run telegram-desktop", group = "launcher"}),
awful.key({ modkey, }, "w", function ()
awful.spawn.raise_or_spawn(irc_client) end,
{description = "run irc client", group = "launcher"}),
awful.key({ modkey, }, "e", function ()
awful.spawn(editor_cmd) end,
{description = "run editor", group = "launcher"}),
awful.key({ modkey, }, "Down", function ()
awful.spawn(music_player) end,
{description = "run music player", group = "launcher"}),
awful.key({ modkey, }, "b", function ()
awful.spawn(browser) end,
{description = "run browser", group = "launcher"}),
awful.key({ modkey, }, "d", function ()
awful.spawn(file_manager) end,
{description = "run file manager", group = "launcher"}),
awful.key({ }, "XF86Launch1", function ()
awful.spawn.raise_or_spawn(rss_reader) end,
{description = "run newsraft", group = "launcher"}),
awful.key({"Mod4" }, "x", function ()
os.execute("xkill") end,
{description = "launch xkill", group = "launcher"}),
awful.key({"Mod4" }, "z", function ()
os.execute("/home/radio/.local/bin/zlib") end,
{description = "loot some ships", group = "launcher"}),
awful.key({"Mod4" }, "g", function ()
awful.spawn(terminal.." -e lf /home/radio/projects/guile/radix") end,
{description = "run link handler", group = "launcher"}),
awful.key({ modkey, }, "Return", function ()
awful.spawn(terminal) end,
{description = "run terminal", group = "launcher",}),
awful.key({ modkey, }, ":", function ()
awful.screen.focused().mypromptbox:run() end,
{description = "run prompt", group = "launcher"}),
--[[
awful.key({ modkey }, "p", function()
menubar.show() end,
{description = "show the menubar", group = "launcher"}),
awful.key({ modkey }, "x",
function ()
awful.prompt.run {
prompt = "Run Lua code: ",
textbox = awful.screen.focused().mypromptbox.widget,
exe_callback = awful.util.eval,
history_path = awful.util.get_cache_dir() .. "/history_eval"
}
end,
{description = "lua execute prompt", group = "awesome"}),
--]]
})
-- Tags related keybindings
awful.keyboard.append_global_keybindings({
awful.key({ modkey, }, "h", awful.tag.viewprev,
{description = "focus previous tag", group = "tag"}),
awful.key({ modkey, }, "l", awful.tag.viewnext,
{description = "focus next tag", group = "tag"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore,
{description = "go back", group = "tag"}),
})
-- Focus related keybindings
awful.keyboard.append_global_keybindings({
awful.key({ modkey, }, "j", function ()
awful.client.focus.byidx( 1) end,
{description = "focus previous by index", group = "client"}
),
awful.key({ modkey, }, "k", function ()
awful.client.focus.byidx(-1) end,
{description = "focus next by index", group = "client"}
),
awful.key({ modkey, }, "Tab", function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end,
{description = "go back", group = "client"}),
awful.key({ modkey, "Control" }, "h", function ()
awful.screen.focus_relative( 1) end,
{description = "focus the next screen", group = "screen"}),
awful.key({ modkey, "Control" }, "l", function ()
awful.screen.focus_relative(-1) end,
{description = "focus the previous screen", group = "screen"}),
awful.key({ modkey, "Control" }, ".", function ()
local c = awful.client.restore()
-- Focus restored client
if c then
c:activate { raise = true, context = "key.unminimize" }
end
end,
{description = "restore minimized", group = "client"}),
})
-- Layout related keybindings
awful.keyboard.append_global_keybindings({
--awful.key({ modkey, "Shift" }, "j", function ()
-- awful.client.swap.byidx( 1) end,
-- {description = "swap with next client by index", group = "client"}),
--awful.key({ modkey, "Shift" }, "k", function ()
-- awful.client.swap.byidx( -1) end,
-- {description = "swap with previous client by index", group = "client"}),
--awful.key({ modkey, }, "l", function ()
-- awful.tag.incmwfact( 0.05) end,
-- {description = "increase master width factor", group = "layout"}),
--awful.key({ modkey, }, "h", function ()
-- awful.tag.incmwfact(-0.05) end,
-- {description = "decrease master width factor", group = "layout"}),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
{description = "jump to urgent client", group = "client"}),
awful.key({ modkey, "Control" }, "h", function ()
awful.tag.incnmaster( 1, nil, true) end,
{description = "increase the number of master clients", group = "layout"}),
awful.key({ modkey, "Control" }, "l", function ()
awful.tag.incnmaster(-1, nil, true) end,
{description = "decrease the number of master clients", group = "layout"}),
--awful.key({ modkey, "Control" }, "h", function ()
-- awful.tag.incncol( 1, nil, true) end,
-- {description = "increase the number of columns", group = "layout"}),
--awful.key({ modkey, "Control" }, "l", function ()
-- awful.tag.incncol(-1, nil, true) end,
-- {description = "decrease the number of columns", group = "layout"}),
awful.key({ modkey, }, "space", function ()
awful.layout.inc( 1) end,
{description = "select next", group = "layout"}),
awful.key({ modkey, "Control" }, "space", function ()
awful.layout.inc(-1) end,
{description = "select previous", group = "layout"}),
})
-- @DOC_NUMBER_KEYBINDINGS@
awful.keyboard.append_global_keybindings({
awful.key {
modifiers = { modkey },
keygroup = "numrow",
description = "only view tag",
group = "tag",
on_press = function (index)
local screen = awful.screen.focused()
local tag = screen.tags[index]
if tag then
tag:view_only()
end
end,
},
awful.key {
modifiers = { modkey, "Control" },
keygroup = "numrow",
description = "toggle tag",
group = "tag",
on_press = function (index)
local screen = awful.screen.focused()
local tag = screen.tags[index]
if tag then
awful.tag.viewtoggle(tag)
end
end,
},
awful.key {
modifiers = { modkey, "Shift" },
keygroup = "numrow",
description = "move focused client to tag",
group = "tag",
on_press = function (index)
if client.focus then
local tag = client.focus.screen.tags[index]
if tag then
client.focus:move_to_tag(tag)
end
end
end,
},
awful.key {
modifiers = { modkey, "Control", "Shift" },
keygroup = "numrow",
description = "toggle focused client on tag",
group = "tag",
on_press = function (index)
if client.focus then
local tag = client.focus.screen.tags[index]
if tag then
client.focus:toggle_tag(tag)
end
end
end,
},
})
-- Audio related keybindings
awful.keyboard.append_global_keybindings({
awful.key({ }, "XF86AudioRaiseVolume", function ()
awful.util.spawn("amixer -q set Master 1%+", false) end,
{description = "volume up", group = "hotkeys"}),
awful.key({ }, "XF86AudioLowerVolume", function ()
awful.util.spawn("amixer -q set Master 1%-", false) end,
{description = "volume down", group = "hotkeys"}),
awful.key({ }, "XF86AudioMute", function ()
awful.util.spawn("amixer -D set Master 1+ toggle", false) end,
{description = "toggle mute", group = "hotkeys"}),
})
-- MPD related keybinds
awful.keyboard.append_global_keybindings({
awful.key({ }, "XF86AudioPlay", function ()
os.execute("mpc toggle")
-- beautiful.mpd.update() -- MPD widget must be set
end,
{description = "mpc toggle", group = "widgets"}),
awful.key({ }, "XF86AudioStop", function ()
os.execute("mpc stop")
-- beautiful.mpd.update() -- MPD widget must be set
end,
{description = "mpc stop", group = "widgets"}),
awful.key({ }, "XF86AudioPrev", function ()
os.execute("mpc prev")
-- beautiful.mpd.update() -- MPD widget must be set
end,
{description = "mpc prev", group = "widgets"}),
awful.key({ }, "XF86AudioNext", function ()
os.execute("mpc next")
-- beautiful.mpd.update() -- MPD widget must be set
end,
{description = "mpc next", group = "widgets"}),
-- awful.key({ altkey }, "0", function ()
-- local common = { text = "MPD widget ", position = "top_middle", timeout = 2 }
-- if beautiful.mpd.timer.started then
-- beautiful.mpd.timer:stop()
-- common.text = common.text .. lain.util.markup.bold("OFF")
-- else
-- beautiful.mpd.timer:start()
-- common.text = common.text .. lain.util.markup.bold("ON")
-- end
-- naughty.notify(common)
-- end,
-- {description = "ncmpcpp on/off", group = "widgets"}),
})
-- Generic hotkeys
awful.keyboard.append_global_keybindings({
awful.key({ "Control", }, "space", function()
naughty.destroy_all_notifications() end,
{description = "destroy notifications", group = "hotkeys"}),
awful.key({ }, "XF86Sleep", function ()
os.execute("doas zzz") end,
{description = "Sleep", group = "hotkeys"}),
awful.key({ }, "XF86Battery", function ()
os.execute("i3lock -u -i /home/radio/Pictures/guix-artwork/backgrounds/guix-silver-checkered-16-9.svg") end,
{description = "lock screen", group = "hotkeys"}),
})
-- Show/hide wibox
awful.keyboard.append_global_keybindings({
awful.key({ modkey }, "Up", function ()
for s in screen do
s.mywibox.visible = not s.mywibox.visible
end
end,
{description = "toggle wibox", group = "awesome"}),
--[[ awful.key({ modkey }, "Down", function ()
for s in screen do
s.mybottomwibox.visible = not s.mybottomwibox.visible
end
end,
{description = "toggle bottom wibox", group = "awesome"}),
--]]
})
-- @DOC_CLIENT_BUTTONS@
client.connect_signal("request::default_mousebindings", function()
awful.mouse.append_client_mousebindings({
awful.button({ }, 1, function (c)
c:activate { context = "mouse_click" } end),
awful.button({ modkey, }, 1, function (c)
c:activate { context = "mouse_click", action = "mouse_move" } end),
awful.button({ modkey, }, 3, function (c)
c:activate { context = "mouse_click", action = "mouse_resize"} end),
})
end)
-- @DOC_CLIENT_KEYBINDINGS@
client.connect_signal("request::default_keybindings", function()
awful.keyboard.append_client_keybindings({
awful.key({ modkey, }, "f", function (c)
c.fullscreen = not c.fullscreen
c:raise()
end,
{description = "toggle fullscreen", group = "client"}),
awful.key({ modkey, }, "q", function (c)
c:kill() end,
{description = "close", group = "client"}),
awful.key({ modkey, "Shift" }, "Return", function (c)
c:swap(awful.client.getmaster()) end,
{description = "move to master", group = "client"}),
awful.key({ modkey, }, "o", function (c)
c:move_to_screen() end,
{description = "move to screen", group = "client"}),
awful.key({ modkey, }, "t", function (c)
c.ontop = not c.ontop end,
{description = "toggle keep on top", group = "client"}),
awful.key({ modkey, }, ".", function (c)
c.minimized = true end ,
{description = "minimize", group = "client"}),
awful.key({ modkey, }, "m", lain.util.magnify_client,
{description = "toggle magnify", group = "client"})})
end)
-- }}}
-- {{{ Rules
-- Rules to apply to new clients.
-- @DOC_RULES@
ruled.client.connect_signal("request::rules", function()
-- @DOC_GLOBAL_RULE@
-- All clients will match this rule.
ruled.client.append_rule {
id = "global",
rule = { },
properties = {
focus = awful.client.focus.filter,
raise = true,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen
}
}
-- @DOC_FLOATING_RULE@
-- Floating clients.
ruled.client.append_rule {
id = "floating",
rule_any = {
instance = {
"copyq",
"pinentry"
},
class = {
"Arandr",
"TelegramDesktop",
"KeePassXC",
"Gpick",
"Keepassxc",
"Tor Browser",
"Weechat",
"Wpa_gui",
"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. Browser's (detached) Developer Tools.
}
},
properties = { floating = true }
}
-- Please st, respect my size hints :(
ruled.client.append_rule {
id = "respeitador de size hints",
rule_any = {
class = {"Emacs", "St"},
},
properties = { size_hints_honor = false }
}
-- @DOC_ONTOP_RULE@
-- Ontop clients.
ruled.client.append_rule {
id = "ontop",
rule_any = {
name = { "Media viewer" },
class = { "mpv" },
},
properties = { ontop = true },
}
-- Establish a default size and position for telegram
ruled.client.append_rule {
id = "TelegramDesktop",
rule_any = {
class = { "TelegramDesktop" },
},
except_any = {
name = { "Choose Files", "Media viewer" }
},
properties = {
above = true,
placement = awful.placement.centered,
width = 380,
height = awful.screen.focused().workarea.height - 4 * beautiful.useless_gap - 2
}
}
-- @DOC_DIALOG_RULE@
-- Add titlebars to normal clients and dialogs
ruled.client.append_rule {
-- @DOC_CSD_TITLEBARS@
id = "titlebars",
rule_any = { type = { "normal", "dialog" } },
properties = { titlebars_enabled = false }
}
-- Set Firefox to always map on the tag named "2" on screen 1.
-- ruled.client.append_rule {
-- rule = { class = "Firefox" },
-- properties = { screen = 1, tag = "2" }
-- }
end)
-- }}}
-- {{{ Titlebars
-- @DOC_TITLEBARS@
-- 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.button({ }, 1, function()
c:activate { context = "titlebar", action = "mouse_move" }
end),
awful.button({ }, 3, function()
c:activate { context = "titlebar", action = "mouse_resize"}
end),
}
awful.titlebar(c).widget = {
{ -- Left
awful.titlebar.widget.iconwidget(c),
buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
{ -- Title
halign = "center",
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{ -- Right
awful.titlebar.widget.floatingbutton (c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.stickybutton (c),
awful.titlebar.widget.ontopbutton (c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal()
},
layout = wibox.layout.align.horizontal
}
end)
-- }}}
--{{{ Autorun programs
autorun = true
autorunApps = {
"xrdb /home/radio/.Xresources",
"keepassxc",
"/home/radio/.profile",
"xmodmap .xmodmap",
"mpd --no-config",
"xset r rate 160 35",
"xset b off",
"setxkbmap -layout 'us,br' -option 'grp:menu_switch,parens:swap_brackets,caps:swapescape'",
"xbanish",
-- "/home/radio/.config/tox/toxic-scripts/auto-open.sh",
"xset r rate 200 30",
"pkill oneko",
"oneko -tofocus -bg '#606060' -fg '#101010' -speed 22",
"adjust-trackpoint",
}
if autorun then
for app = 1, #autorunApps do
awful.util.spawn(autorunApps[app])
end
end
---}}}
-- {{{ Notifications
ruled.notification.connect_signal('request::rules', function()
-- All notifications will match this rule.
ruled.notification.append_rule {
rule = { },
properties = {
screen = awful.screen.preferred,
implicit_timeout = 5,
}
}
end)
naughty.connect_signal("request::display", function(n)
naughty.layout.box { notification = n }
end)
-- }}}
-- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c)
c:activate { context = "mouse_enter", raise = false }
end)