Skip to content

Instantly share code, notes, and snippets.

@kverb
Created January 21, 2025 14:58
Show Gist options
  • Save kverb/11dfe1533d9b623a99d382ba7558b41c to your computer and use it in GitHub Desktop.
Save kverb/11dfe1533d9b623a99d382ba7558b41c to your computer and use it in GitHub Desktop.
river config
#!/bin/sh
# lots of config lifted from https://github.com/warrior0x7/rivercfg/blob/main/.config/river/init
#
# Note: the "Super" modifier is also known as Logo, GUI, Windows, Mod4, etc.
# Set background and border color
riverctl background-color 0x000000
riverctl border-width 1
riverctl border-color-focused 0xb0e0e6
riverctl border-color-unfocused 0x586e75
# -----------------
# helper functions
# -----------------
# Specify tags app will start on
function tags () {
case $# in
2)
if [ "$2" != "all" ]; then
ruleAdd "$1" tags $(( 1 << ($2-1) ))
else
ruleAdd "$1" tags $(( (1 << 32)-1 ))
fi
;;
3)
if [ "$3" != "all" ]; then
ruleAdd "$1" -title "$2" tags $(( 1 << ($3-1) ))
else
ruleAdd "$1" -title "$2" tags $(( (1 << 32)-1 ))
fi
;;
esac
}
# --------------------
# WM-related keybinds
# --------------------
riverctl map normal Super Q close # defeault, kills the focused view
# Super+J and Super+K to focus the next/previous view in the layout stack
riverctl map normal Super J focus-view next
riverctl map normal Super K focus-view next
# L H is redundant but helps it work as you would expect when there are mixed splits
riverctl map normal Super L focus-view next
riverctl map normal Super H focus-view previous
# Super+Shift+J and Super+Shift+K to swap the focused view with the next/previous view in the layout stack
riverctl map normal Super+Shift J swap next
riverctl map normal Super+Shift H swap next
riverctl map normal Super+Shift K swap previous
riverctl map normal Super+Shift L swap previous
# Super+Period and Super+Comma to focus the next/previous output (display)
riverctl map normal Super Period focus-output next
riverctl map normal Super Comma focus-output previous
# Super+Shift+{Period,Comma} to send the focused view to the next/previous output
riverctl map normal Super+Shift Period send-to-output next
riverctl map normal Super+Shift Comma send-to-output previous
# Super+Shift+Return to bump the focused view to the top of the layout stack
riverctl map normal Super+Shift Return zoom
# Super+N and Super+M to decrease/increase the main ratio of rivertile(1)
# riverctl map normal Super H send-layout-cmd rivertile "main-ratio -0.05"
# riverctl map normal Super L send-layout-cmd rivertile "main-ratio +0.05"
# Super+Alt+{H,J,K,L} to move views
riverctl map normal Super+Alt H move left 100
riverctl map normal Super+Alt J move down 100
riverctl map normal Super+Alt K move up 100
riverctl map normal Super+Alt L move right 100
# Super+Alt+Control+{H,J,K,L} to snap views to screen edges
riverctl map normal Super+Alt+Control H snap left
riverctl map normal Super+Alt+Control J snap down
riverctl map normal Super+Alt+Control K snap up
riverctl map normal Super+Alt+Control L snap right
# Super+Alt+Shift+{H,J,K,L} to resize views
riverctl map normal Super+Alt+Shift H resize horizontal -100
riverctl map normal Super+Alt+Shift J resize vertical 100
riverctl map normal Super+Alt+Shift K resize vertical -100
riverctl map normal Super+Alt+Shift L resize horizontal 100
# Super + Left Mouse Button to move views
riverctl map-pointer normal Super BTN_LEFT move-view
# Super + Right Mouse Button to resize views
riverctl map-pointer normal Super BTN_RIGHT resize-view
# Super + Middle Mouse Button to toggle float
riverctl map-pointer normal Super BTN_MIDDLE toggle-float
for i in $(seq 1 7)
do
tags=$((1 << ($i - 1)))
# Super+[1-7] to focus tag [0-6]
riverctl map normal Super $i set-focused-tags $tags
# Super+Shift+[1-7] to tag focused view with tag [0-6]
riverctl map normal Super+Shift $i set-view-tags $tags
# Super+Control+[1-7] to toggle focus of tag [0-6]
riverctl map normal Super+Control $i toggle-focused-tags $tags
done
# Super+0 to focus all tags
# Super+Shift+0 to tag focused view with all tags
all_tags=$(((1 << 32) - 1))
riverctl map normal Super 0 set-focused-tags $all_tags
riverctl map normal Super+Shift 0 set-view-tags $all_tags
# Super+Space to toggle float
riverctl map normal Super+Shift Space toggle-float
# Super+F to toggle fullscreen
riverctl map normal Super F toggle-fullscreen
# Super+{Up,Right,Down,Left} to change layout orientation
riverctl map normal Super Up send-layout-cmd rivertile "main-location top"
riverctl map normal Super Right send-layout-cmd rivertile "main-location right"
riverctl map normal Super Down send-layout-cmd rivertile "main-location bottom"
riverctl map normal Super Left send-layout-cmd rivertile "main-location left"
# Declare a passthrough mode. This mode has only a single mapping to return to
# normal mode. This makes it useful for testing a nested wayland compositor
riverctl declare-mode passthrough
# Super+F11 to enter passthrough mode
riverctl map normal Super F11 enter-mode passthrough
# Super+F11 to return to normal mode
riverctl map passthrough Super F11 enter-mode normal
# --------------------------------
# application and custom keybinds
# --------------------------------
# terminal
riverctl map normal Super Return spawn "wezterm start --always-new-process"
# launcher
riverctl map normal Super Space spawn fuzzel
# Power menu
riverctl map normal Super+Shift E spawn ~/.config/river/scripts/powermenu.sh
# clipboard history via fuzzel
riverctl map normal Alt+Shift C spawn " \
cliphist list | \
fuzzel -d -R -p '  ' | \
cliphist decode | \
wl-copy
"
# Audio controls
riverctl map normal None XF86AudioRaiseVolume spawn "pamixer -i 4"
riverctl map normal None XF86AudioLowerVolume spawn "pamixer -d 4"
riverctl map normal None XF86AudioMute spawn "pamixer --toggle-mute"
# Brightness controls
riverctl map normal None XF86MonBrightnessUp spawn "brightnessctl -c backlight set +2%"
riverctl map normal None XF86MonBrightnessDown spawn "brightnessctl -c backlight set 2%-"
# Custom screenshot shortcuts
riverctl map normal Control+Shift+Alt+3 spawn ~/.config/sway/scripts/screenshot-upload.sh
riverctl map normal Control+Alt+3 spawn 'grim -g "$(slurp)" - | wl-copy'
riverctl map normal Shift+Alt+3 spawn ~/.config/sway/scripts/screenshot.sh
riverctl map normal Shift+Alt+4 spawn ~/.config/sway/scripts/screenrecord.sh
riverctl map normal Control+Alt+4 spawn 'pkill --signal SIGINT wf-recorder'
# ----------------
# libinput config
# ----------------
riverctl set-repeat 50 180 # key-repeat rate. very fast.
riverctl keyboard-layout -options 'ctrl:nocaps,compose:prsc' us # remaps capslock to control, and print screen to compose key
riverctl input *Touchpad natural-scroll disabled
riverctl input *Touchpad tap enabled
riverctl input *Touchpad disable-while-typing enabled
riverctl input *Touchpad pointer-accel 0.3
riverctl input *Touchpad scroll-factor 0.2
riverctl input "1578:16768:MOSART_Semi._2.4G_INPUT_DEVICE_Mouse" pointer-accel 1
riverctl input "1578:16768:MOSART_Semi._2.4G_INPUT_DEVICE_Mouse" scroll-factor 2
# ----------------------------
# leftover stuff from the default bash
# ----------------------------
# Make all views with an app-id that starts with "float" and title "foo" start floating.
riverctl rule-add -app-id 'float*' float
# Make all views with app-id "bar" and any title use client-side decorations
riverctl rule-add -app-id "bar" csd
# riverctl default-layout rivertile
# rivertile -view-padding 6 -outer-padding 6 &
# --------------
# Tiling config
# --------------
#
# send command to tiler (in this case, wideriver)
TILER=wideriver
TILER_MODE=layout
riverctl declare-mode $TILER_MODE
riverctl map normal Super+Shift R enter-mode $TILER_MODE
riverctl map $TILER_MODE None Escape enter-mode normal
function tiler () { riverctl map -layout 0 $TILER_MODE $1 $2 send-layout-cmd $TILER "$3"; }
# requires wideriver - https://github.com/alex-courtis/wideriver
riverctl default-layout $TILER
# wideriver --layout left \
# --layout-alt monocle \
# --count-master 1 \
# --ratio-master 0.55 \
# --stack dwindle \
# --smart-gaps \
# &
# set layout manager
riverctl default-layout wideriver
# start layout manager
wideriver \
--layout left \
--layout-alt monocle \
--stack dwindle \
--count-master 1 \
--ratio-master 0.50 \
--count-wide-left 0 \
--ratio-wide 0.35 \
--no-smart-gaps \
--inner-gaps 0 \
--outer-gaps 0 \
--border-width 2 \
--border-width-monocle 0 \
--border-width-smart-gaps 0 \
--border-color-focused "0x93a1a1" \
--border-color-focused-monocle "0x586e75" \
--border-color-unfocused "0x586e75" \
--log-threshold info \
> "/tmp/wideriver.${XDG_VTNR}.${USER}.log" 2>&1 &
tiler None H "--ratio -0.05" # resize left
tiler None L "--ratio +0.05" # resize right
tiler None Tab "--layout-toggle" # toggle layout
# requires river-bsp-layout installed
# riverctl default-layout bsp-layout
# river-bsp-layout --inner-gap 3 \
# --outer-gap 0 \
# --og-top 5 \
# --vsplit-perc 0.45 \
# --hsplit-perc 0.5 &
# riverctl declare-mode resize
# riverctl map normal Super+Shift R enter-mode resize
# riverctl map resize None Escape enter-mode normal
# # similar to adjusting the tiling ratios
# riverctl map resize None L send-layout-cmd bsp-layout '--inc-vsplit 0.05'
# riverctl map resize None J send-layout-cmd bsp-layout '--inc-hsplit 0.05'
# riverctl map resize None K send-layout-cmd bsp-layout '--dec-hsplit 0.05'
# riverctl map resize None H send-layout-cmd bsp-layout '--dec-vsplit 0.05'
# # quickly reverse the layout stack
# riverctl map resize None Tab send-layout-cmd bsp-layout '--reverse'
# without this, river starts with a crosshair that you need to specify as the first tiling focus area
riverctl focus-output 0
riverctl set-focused-tags 1
# -----------------
# autostart things
# -----------------
# network manager
nm-applet --indicator &
# clipboard saver
wl-paste -t text --watch cliphist store &
wl-paste -t image --watch cliphist store &
wl-paste --primary --watch cliphist store &
waybar -c ~/.config/waybar/river.jsonc & # status bar
# notification toasts
mako &
# -----------------------
# Device-specific config
# -----------------------
if [ "$(hostname)" = "zb13" ]; then
# Assign "Signal Beta" to workspace 3
riverctl spawn-on-tags class="Signal Beta" tags=0x4
# Configure outputs
way-displays -c ~/.config/way-displays/zb13.yml > /tmp/way-displays.${USER}.log 2>&1 &
else
way-displays &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment