Updated river config

This commit is contained in:
Alexey 2025-01-21 15:06:49 +03:00
commit f635cfc80e

View file

@ -1,13 +1,5 @@
#!/usr/bin/lua5.4 #!/usr/bin/lua5.4
--[[
NOTE:
- execp() needs 'lua-posix' package
- bitwise operands for tag mappings need Lua version >= 5.3
--]]
-- Convenient functions ──────────────────────────────────────────────────────── -- Convenient functions ────────────────────────────────────────────────────────
-- Wrapper around table.concat() to also handle other types -- Wrapper around table.concat() to also handle other types
@ -33,6 +25,11 @@ local monitors = {
external = 'HDMI-A-1' external = 'HDMI-A-1'
} }
local pointers = {
touchpad = 'pointer-10248-514-ASUF1204:00_2808:0202_Touchpad',
mouse = 'pointer-9639-64124-Compx_2.4G_Wireless_Receiver'
}
local startup_commands = { local startup_commands = {
-- Inform dbus about the environment variables -- Inform dbus about the environment variables
{ {
@ -45,16 +42,12 @@ local startup_commands = {
{ {
'waybar' 'waybar'
}, },
-- Wallpaper
{ {
string.format("swaybg -o %s -i %s -o %s -i %s", string.format("swaybg -o %s -i %s -o %s -i %s",
monitors.main, wallpapers.primary, monitors.main, wallpapers.primary,
monitors.external, wallpapers.secondary) monitors.external, wallpapers.secondary)
} }
-- Startup programs
--{
-- 'swayidle',
-- 'timeout 300 "swaylock"',
--},
} }
local outputs = { local outputs = {
@ -75,7 +68,7 @@ local outputs = {
} }
local inputs = { local inputs = {
['pointer-10248-514-ASUF1204:00_2808:0202_Touchpad'] = { [pointers.touchpad] = {
['drag'] = 'enabled', ['drag'] = 'enabled',
['tap'] = 'enabled', ['tap'] = 'enabled',
['tap-button-map'] = 'left-right-middle', ['tap-button-map'] = 'left-right-middle',
@ -83,7 +76,7 @@ local inputs = {
['scroll-method'] = 'two-finger', ['scroll-method'] = 'two-finger',
['accel-profile'] = 'none', ['accel-profile'] = 'none',
}, },
['pointer-9639-64124-Compx_2.4G_Wireless_Receiver'] = { [pointers.mouse] = {
['accel-profile'] = 'none', ['accel-profile'] = 'none',
} }
} }
@ -115,30 +108,6 @@ local gsettings = {
}, },
} }
local window_rules = {
['float-filter-add'] = {
['app-id'] = {
'float',
'popup',
'swappy',
'pinentry-qt',
'pavucontrol-qt',
},
['title'] = {
'Picture-in-Picture',
-- 'About *',
},
},
['csd-filter-add'] = {
['app-id'] = { 'swappy' },
},
}
-- Additional modes and their mappings to switch between them and 'normal' mode
--
-- name: string (the name of the additional mode)
-- mod: string|list (modifiers for key binding, concanated by '+')
-- key: string
local modes = { local modes = {
{ {
name = 'passthrough', name = 'passthrough',
@ -147,49 +116,46 @@ local modes = {
}, },
} }
-- Each mapping contains 4 keys:
--
-- mod: string|list (modifiers, concanated by '+')
-- key: string
-- command: string|list (the command passed to riverctl)
-- opt: string ('release' or 'repeat')
local mappings = { local mappings = {
-- Key bindings
map = { map = {
normal = { normal = {
-- Terminal emulator
{ {
mod = { 'Super', 'Shift' }, mod = { 'Super', 'Shift' },
key = 'T', key = 'T',
command = { 'spawn', 'alacritty' }, command = { 'spawn', 'alacritty' },
}, },
-- Application launcher
{ {
mod = { 'Shift', 'Control' }, mod = { 'Shift', 'Control' },
key = 'Escape', key = 'Escape',
command = { 'spawn', [['wofi --show drun']] } command = { 'spawn', [['wofi --show drun']] }
}, },
-- Screenshot
{ {
mod = { 'Super', 'Shift' }, mod = { 'Super', 'Shift' },
key = 'S', key = 'S',
command = { 'spawn', [['slurp | grim -g - - | wl-copy']] } command = { 'spawn', [['slurp | grim -g - - | wl-copy']] }
}, },
-- Screen locker
{ {
mod = { 'Super' }, mod = { 'Super' },
key = 'O', key = 'O',
command = { 'spawn', [['waylock -init-color 0x352e2c -input-color 0x575e7a -fail-color 0x833b18']] } command = { 'spawn', [['waylock -init-color 0x352e2c -input-color 0x575e7a -fail-color 0x833b18']] }
}, },
-- Super+Q to close the focused view -- Close view
{ {
mod = 'Alt', mod = 'Alt',
key = 'F4', key = 'F4',
command = 'close', command = 'close',
}, },
-- Super+Shift+Q to exit river -- Exit river
{ {
mod = { 'Super', 'Shift' }, mod = { 'Super', 'Shift' },
key = 'Q', key = 'Q',
command = 'exit', command = 'exit',
}, },
-- Super+{J,K} to focus next/previous view in the layout stack -- Focus next/previous view
{ {
mod = 'Super', mod = 'Super',
key = 'J', key = 'J',
@ -200,7 +166,7 @@ local mappings = {
key = 'K', key = 'K',
command = { 'focus-view', 'next' }, command = { 'focus-view', 'next' },
}, },
-- Super+Shift+{J,K} to swap focused view with the next/previous view in the layout stack -- Swap focused view with the next/previous view
{ {
mod = { 'Super', 'Shift' }, mod = { 'Super', 'Shift' },
key = 'J', key = 'J',
@ -211,7 +177,7 @@ local mappings = {
key = 'K', key = 'K',
command = { 'swap', 'next' }, command = { 'swap', 'next' },
}, },
-- Super+{P,N} to focus next/previous output -- Focus next/previous output
{ {
mod = 'Super', mod = 'Super',
key = 'P', key = 'P',
@ -222,7 +188,7 @@ local mappings = {
key = 'N', key = 'N',
command = { 'focus-output', 'next' }, command = { 'focus-output', 'next' },
}, },
-- Super+Shift+{P,N} to send the focused view to next/previous output -- Send the focused view to next/previous output
{ {
mod = { 'Super', 'Shift' }, mod = { 'Super', 'Shift' },
key = 'P', key = 'P',
@ -233,13 +199,13 @@ local mappings = {
key = 'N', key = 'N',
command = { 'send-to-output', 'next' }, command = { 'send-to-output', 'next' },
}, },
-- Super+E to bump the focused view to the top of the layout stack -- Make view primary
{ {
mod = 'Super', mod = 'Super',
key = 'E', key = 'E',
command = 'zoom', command = 'zoom',
}, },
-- Super+{H,L} to decrease/increase the main_factor value of rivertile by 0.02 -- Decrease/increase the main view ratio
{ {
mod = 'Super', mod = 'Super',
key = 'H', key = 'H',
@ -250,7 +216,7 @@ local mappings = {
key = 'L', key = 'L',
command = { 'send-layout-cmd', 'rivertile', [['main-ratio +0.02']] }, command = { 'send-layout-cmd', 'rivertile', [['main-ratio +0.02']] },
}, },
-- Super+Shift+{H,L} to increment/decrement the main_count value of rivertile -- Increment/decrement the main_count value of rivertile
{ {
mod = { 'Super', 'Shift' }, mod = { 'Super', 'Shift' },
key = 'H', key = 'H',
@ -261,7 +227,7 @@ local mappings = {
key = 'L', key = 'L',
command = { 'send-layout-cmd', 'rivertile', [['main-count -1']] }, command = { 'send-layout-cmd', 'rivertile', [['main-count -1']] },
}, },
-- Control+Alt+{H,J,K,L} to change layout orientation -- Change layout orientation
{ {
mod = { 'Control', 'Alt' }, mod = { 'Control', 'Alt' },
key = 'H', key = 'H',
@ -282,13 +248,13 @@ local mappings = {
key = 'L', key = 'L',
command = { 'send-layout-cmd', 'rivertile', [['main-location right']] }, command = { 'send-layout-cmd', 'rivertile', [['main-location right']] },
}, },
-- Super+Space to toggle float -- Toggle float
{ {
mod = 'Super', mod = 'Super',
key = 'Space', key = 'Space',
command = 'toggle-float', command = 'toggle-float',
}, },
-- Super+F to toggle fullscreen -- Toggle fullscreen
{ {
mod = 'Super', mod = 'Super',
key = 'F', key = 'F',
@ -299,13 +265,13 @@ local mappings = {
-- Mappings for pointer (mouse) -- Mappings for pointer (mouse)
['map-pointer'] = { ['map-pointer'] = {
normal = { normal = {
-- Super + Left Mouse Button to move views -- Move floating views
{ {
mod = 'Super', mod = 'Super',
key = 'BTN_LEFT', key = 'BTN_LEFT',
command = 'move-view', command = 'move-view',
}, },
-- Super + Right Mouse Button to resize views -- Resize floating views
{ {
mod = 'Super', mod = 'Super',
key = 'BTN_RIGHT', key = 'BTN_RIGHT',
@ -341,10 +307,6 @@ end
-- Apply settings ────────────────────────────────────────────────────────────── -- Apply settings ──────────────────────────────────────────────────────────────
-- Run startup commands
--
-- 'riverctl spawn ...' always returns (even when the child process is a daemon)
-- so we don't need to resort to posix.unistd.spawn()
for _, cmd in ipairs(startup_commands) do for _, cmd in ipairs(startup_commands) do
os.execute(string.format([[riverctl spawn '%s']], concat(cmd, ' '))) os.execute(string.format([[riverctl spawn '%s']], concat(cmd, ' ')))
end end
@ -415,6 +377,7 @@ for map_type, tbl in pairs(mappings) do
opt = '-' .. opt opt = '-' .. opt
end end
-- -layout 0 is hardcoded to make mappings work on any layout
os.execute(string.format('riverctl %s -layout 0 %s %s %s %s %s', map_type, opt, mode, modifiers, binding.key, cmd)) os.execute(string.format('riverctl %s -layout 0 %s %s %s %s %s', map_type, opt, mode, modifiers, binding.key, cmd))
-- Duplicate mappings of mode 'locked' for mode 'normal' -- Duplicate mappings of mode 'locked' for mode 'normal'
@ -428,20 +391,7 @@ end
-- Mappings for tag management -- Mappings for tag management
tag_mappings() tag_mappings()
-- Window rules (float/csd filters)
for key, value in pairs(window_rules) do
for type, patterns in pairs(value) do
for _, pattern in ipairs(patterns) do
os.execute(string.format('riverctl %s %s %s', key, type, pattern))
end
end
end
-- Launch the layout generator as the final initial process. -- Launch the layout generator as the final initial process.
--
-- River run the init file as a process group leader and send
-- SIGTERM to the group on exit. Therefore, keep the main init
-- process running (replace it with the layout generator process).
local unistd = require('posix.unistd') local unistd = require('posix.unistd')
unistd.execp('rivertile', { unistd.execp('rivertile', {
'-view-padding', 5, '-view-padding', 5,