Bindings and rules

This commit is contained in:
Alexander Gehrke 2023-10-27 11:11:35 +02:00
parent 81cba76bde
commit dcf3a84ba8
7 changed files with 40 additions and 55 deletions

15
actions.lua Normal file
View file

@ -0,0 +1,15 @@
local naughty = require("naughty")
actions = {}
function actions.toggle_naughty()
if naughty.is_suspended() then
naughty.resume()
naughty.notify({ text = "Notifications enabled", timeout = 2 })
else
naughty.notify({ text = "Notifications disabled", timeout = 2 })
naughty.suspend()
end
end
return actions

View file

@ -1,27 +0,0 @@
-- Notification library
local naughty = require("naughty")
-- {{{ 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)
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = err })
in_error = false
end)
end
-- }}}

View file

@ -83,13 +83,17 @@ M.prompt.artist = function()
dmenu("-a") dmenu("-a")
end end
M.prompt.albumartist = function()
dmenu("-A")
end
M.prompt.album = function() M.prompt.album = function()
dmenu("-a -b") dmenu("-A -b")
end end
M.prompt.title = function() M.prompt.title = function()
dmenu("-a -b -t") dmenu("-A -b -t")
end end
M.prompt.jump = function() M.prompt.jump = function()

View file

@ -1,10 +1,11 @@
-- key bindings -- key bindings
local awful = require("awful") local awful = require("awful")
local conf = conf local conf = require("localconf")
local naughty = require("naughty") local actions = require("actions")
local modkey = conf.modkey or "Mod4" local modkey = conf.modkey or "Mod4"
local hyper = {"Ctrl", "Shift", "Mod1", "Mod4"}
local binder = binder or require("separable.binder") local binder = binder or require("separable.binder")
local mb = binder.modal local mb = binder.modal
@ -27,8 +28,11 @@ local function mpdserver(host)
end end
end end
local terminal_handy = conf.cmd.terminal .. " " .. conf.cmd.terminal_wmclass .. " handy " local terminal_handy = conf.cmd.terminal .. " " .. conf.cmd.terminal_wmclass .. " handy "
local terminal_handy_exec = terminal_handy .. conf.cmd.terminal_exec .. " " local terminal_handy_exec = terminal_handy .. conf.cmd.terminal_exec .. " "
print("terminal_handy: " .. terminal_handy)
print("terminal_handy_exec: " .. terminal_handy_exec)
local mpdhosts = { local mpdhosts = {
{"n", mpdserver("nashorn"), "NAS" }, {"n", mpdserver("nashorn"), "NAS" },
@ -43,7 +47,8 @@ local mpdmap = {
{"S", binder.spawn("mpd --kill"), "kill MPD" }, {"S", binder.spawn("mpd --kill"), "kill MPD" },
{"g", binder.spawn(conf.cmd.mpd_client), "Gmpc", stay_in_mode=false }, {"g", binder.spawn(conf.cmd.mpd_client), "Gmpc", stay_in_mode=false },
{"separator", "Search" }, {"separator", "Search" },
{"a", mpd.prompt.artist, "artist" }, {"a", mpd.prompt.albumartist, "albumartist" },
{"A", mpd.prompt.artist, "artist" },
{"b", mpd.prompt.album, "album" }, {"b", mpd.prompt.album, "album" },
{"t", mpd.prompt.title, "title" }, {"t", mpd.prompt.title, "title" },
{"j", mpd.prompt.jump, "jump" }, {"j", mpd.prompt.jump, "jump" },
@ -68,11 +73,11 @@ local mprismap = {
{"m", binder.spawn(playerctl .. " play-pause"), "Toggle" }, {"m", binder.spawn(playerctl .. " play-pause"), "Toggle" },
{"n", binder.spawn(playerctl .. " next"), "Next" }, {"n", binder.spawn(playerctl .. " next"), "Next" },
{"N", binder.spawn(playerctl .. " previous"), "Prev" }, {"N", binder.spawn(playerctl .. " previous"), "Prev" },
{"s", binder.spawn(playerctl .. " stop"), "Prev" }, {"s", binder.spawn(playerctl .. " stop"), "Stop" },
} }
local messengermap = { local messengermap = {
{"e", binder.spawn("launch-elements"), "Element" }, {"e", binder.spawn("schildichat"), "Element" },
{"i", binder.spawn(conf.cmd.irc_client), "IRC" }, {"i", binder.spawn(conf.cmd.irc_client), "IRC" },
{"m", binder.spawn(conf.cmd.mail_client), "Mail" }, {"m", binder.spawn(conf.cmd.mail_client), "Mail" },
{"r", binder.spawn("rocketchat"), "RocketChat" }, {"r", binder.spawn("rocketchat"), "RocketChat" },
@ -120,7 +125,7 @@ local notifymap = {
local myglobalkeys = awful.util.table.join( local myglobalkeys = awful.util.table.join(
awful.key({ }, "Pause", binder.spawn('rofi -show window')), awful.key({ }, "Pause", binder.spawn('rofi -show window')),
--awful.key({ }, "Print", binder.spawn('dmscrot')), awful.key({ modkey }, "w", binder.spawn('rofi -show window')),
awful.key({ }, "Print", binder.spawn('flameshot gui')), awful.key({ }, "Print", binder.spawn('flameshot gui')),
--{{{ Modal mappings --{{{ Modal mappings
@ -140,15 +145,7 @@ local myglobalkeys = awful.util.table.join(
awful.key({ modkey }, "c", mb.grabf{keymap=progmap, name="Commands"}), awful.key({ modkey }, "c", mb.grabf{keymap=progmap, name="Commands"}),
awful.key({ modkey }, "d", mb.grabf{keymap=docmap, name="Documents"}), awful.key({ modkey }, "d", mb.grabf{keymap=docmap, name="Documents"}),
awful.key({ modkey }, "b", mb.grabf{keymap=brightnessmap, name="Brightness"}), awful.key({ modkey }, "b", mb.grabf{keymap=brightnessmap, name="Brightness"}),
awful.key({ modkey }, "n", function() awful.key({ modkey }, "n", actions.toggle_naughty),
if naughty.is_suspended() then
naughty.resume()
naughty.notify({ text = "Notifications enabled", timeout = 2 })
else
naughty.notify({ text = "Notifications disabled", timeout = 2 })
naughty.suspend()
end
end),
--}}} --}}}
-- {{{ handy console -- {{{ handy console

View file

@ -101,6 +101,10 @@ awful.rules.rules = {
properties = { sticky = true, ontop = true }}, properties = { sticky = true, ontop = true }},
{ rule = { class = "adobe dng converter.exe" }, { rule = { class = "adobe dng converter.exe" },
properties = { floating = true, size_hints_honor = true }}, properties = { floating = true, size_hints_honor = true }},
{ rule = { class = "pentablet", type = "normal"},
properties = { floating = true, size_hints_honor = true}},
{ rule = { class = "pentablet", type = "utility"},
properties = { floating = true, size_hints_honor = true, focusable = false}},
{ rule = { class = "Onboard" }, { rule = { class = "Onboard" },
properties = { sticky = true, ontop = true, focusable = false}}, properties = { sticky = true, ontop = true, focusable = false}},
} }

View file

@ -135,7 +135,6 @@ awful.key({ modkey, "Shift" }, "l", screen_move_client_wrapdir("right")),
awful.key({ modkey, "Control" }, "o", function (c) c.ontop = not c.ontop end), awful.key({ modkey, "Control" }, "o", function (c) c.ontop = not c.ontop end),
awful.key({ modkey, "Shift" }, "a", function (c) c.sticky = not c.sticky end), awful.key({ modkey, "Shift" }, "a", function (c) c.sticky = not c.sticky end),
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end), awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
--awful.key({ modkey, }, "b", function (c) c.border_width = c.border_width > 0 and 0 or beautiful.border_width end),
awful.key({ modkey, }, "Up", function(c) client_opacity_set(c, 1, 1, 0.1) end), awful.key({ modkey, }, "Up", function(c) client_opacity_set(c, 1, 1, 0.1) end),
awful.key({ modkey, }, "Down", function(c) client_opacity_set(c, 1, 0, -0.1) end), awful.key({ modkey, }, "Down", function(c) client_opacity_set(c, 1, 0, -0.1) end),
awful.key({ }, "XF86Calculater", awful.client.movetoscreen ), awful.key({ }, "XF86Calculater", awful.client.movetoscreen ),
@ -216,8 +215,6 @@ local default_bindings = awful.util.table.join(
awful.key({ modkey, "Shift" }, "k", function () awful.key({ modkey, "Shift" }, "k", function ()
awful.client.swap.byidx( -1) awful.client.swap.byidx( -1)
end), end),
--awful.key({ modkey, }, "h", screen_focus_wrapdir("left")),
--awful.key({ modkey, }, "l", screen_focus_wrapdir("right")),
awful.key({ modkey, }, "h", function() awful.screen.focus_relative(1) end), awful.key({ modkey, }, "h", function() awful.screen.focus_relative(1) end),
awful.key({ modkey, }, "l", function() awful.screen.focus_relative(-1) end), awful.key({ modkey, }, "l", function() awful.screen.focus_relative(-1) end),
--}}} --}}}
@ -228,14 +225,6 @@ local default_bindings = awful.util.table.join(
awful.key({ modkey, "Control" }, "space", mb.grabf{keymap=layoutsettings, name="Layout settings", stay_in_mode=true}), awful.key({ modkey, "Control" }, "space", mb.grabf{keymap=layoutsettings, name="Layout settings", stay_in_mode=true}),
--}}} --}}}
--{{{ Audio control
--awful.key({ }, "XF86AudioLowerVolume", spawnf("amixer set Master 2%-")),
--awful.key({ }, "XF86AudioRaiseVolume", spawnf("amixer set Master 2%+")),
--awful.key({ }, "XF86AudioMute", spawnf("amixer set Master toggle")),
--}}}
--{{{ Prompt --{{{ Prompt
awful.key({ modkey }, "r", conf.cmd.run), awful.key({ modkey }, "r", conf.cmd.run),

View file

@ -20,6 +20,9 @@ local fixed_clients = {
{ rule = { name = "", class = "jetbrains-idea", type = "dialog" } }, { rule = { name = "", class = "jetbrains-idea", type = "dialog" } },
-- password inputs -- password inputs
{ rule = { class = "Pinentry-gtk-2" } }, { rule = { class = "Pinentry-gtk-2" } },
{ rule = { class = "pinentry-qt" } },
-- nextcloud closes on focus loss
{ rule = { class = "Nextcloud" } },
} }
local function may_lose_focus(c) local function may_lose_focus(c)