confix/home-manager/dots/river.nix
2024-01-14 22:07:28 -08:00

168 lines
7.9 KiB
Nix

{ pkgs, config, ... }:
{
xdg.configFile = {
"init" = {
enable = true;
executable = true;
target = "river/init";
text = ''
#!/usr/bin/env sh
# See the river(1), riverctl(1), and rivertile(1) man pages for complete
# documentation.
# Variables
TERMINAL="foot"
LOCKSCREEN="swaylock"
# Autostart
riverctl spawn "way-displays -c $HOME/.config/way-displays/cfg.yaml"
riverctl spawn "wallpaper.sh -r"
riverctl spawn "wl-paste --type text --watch cliphist store"
riverctl spawn "wl-paste --type image --watch cliphist store"
riverctl spawn "mako"
riverctl spawn "mullvad-gui"
# Theme
riverctl background-color 0x${config.colorScheme.colors.base00}
riverctl border-color-focused 0x${config.colorScheme.colors.base0D}
riverctl border-color-unfocused 0x${config.colorScheme.colors.base00}
# Launch Shortcuts
riverctl map normal Super Return spawn "$TERMINAL tmux.sh"
riverctl map normal Super+Shift Return spawn "$TERMINAL"
riverctl map normal Super Space spawn "wmenu.sh"
# Focus Controls
riverctl map normal Super H send-layout-cmd rivertile "main-count +1"
riverctl map normal Super J focus-view next
riverctl map normal Super K focus-view previous
riverctl map normal Super L send-layout-cmd rivertile "main-count -1"
riverctl map normal Alt Tab focus-view next
riverctl map normal Alt+Shift Tab focus-view previous
riverctl map normal Super Tab focus-output next
riverctl map normal Super Bracketright focus-output next
riverctl map normal Super Bracketleft focus-output previous
# Move Controls
riverctl map normal Super+Shift H zoom
riverctl map normal Super+Shift J swap next
riverctl map normal Super+Shift K swap previous
riverctl map normal Super+Shift L spawn $LOCKSCREEN
riverctl map normal Super+Shift Tab send-to-output next
riverctl map normal Super+Shift Bracketright send-to-output next
riverctl map normal Super+Shift Bracketleft send-to-output previous
# Layout Controls
riverctl map normal Super+Alt H send-layout-cmd rivertile "main-ratio -0.05"
riverctl map normal Super+Alt L send-layout-cmd rivertile "main-ratio +0.05"
riverctl map normal Super I send-layout-cmd rivertile "main-count +1"
riverctl map normal Super D send-layout-cmd rivertile "main-count -1"
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"
# Floating Controls
riverctl map normal Super F toggle-float
riverctl map normal Super+Control H move left 100
riverctl map normal Super+Control J move down 100
riverctl map normal Super+Control K move up 100
riverctl map normal Super+Control L move right 100
riverctl map normal Super+Shift+Control H snap left
riverctl map normal Super+Shift+Control J snap down
riverctl map normal Super+Shift+Control K snap up
riverctl map normal Super+Shift+Control L snap right
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
riverctl map-pointer normal Super BTN_LEFT move-view
riverctl map-pointer normal Super BTN_RIGHT resize-view
# Close focused view
riverctl map normal Super W close
riverctl map normal Super Q close
# Exit River
riverctl map normal Super+Shift Q exit
for i in $(seq 1 9)
do
tags=$((1 << ($i - 1)))
# Super+[1-9] to focus tag [0-8]
riverctl map normal Super $i spawn "riverctl set-focused-tags $tags; notify-send 'Tag $tags focus toggle';"
# Super+Shift+[1-9] to tag focused view with tag [0-8]
riverctl map normal Super+Shift $i spawn "riverctl set-view-tags $tags; riverctl set-focused-tags $tags; notify-send 'Tag $tags swap toggle';"
# Super+Control+[1-9] to toggle focus of tag [0-8]
riverctl map normal Super+Control $i spawn "riverctl toggle-focused-tags $tags; notify-send 'Tag $tags focus toggle';"
# Super+Shift+Control+[1-9] to toggle tag [0-8] of focused view
riverctl map normal Super+Shift+Control $i spawn "riverctl toggle-view-tags $tags; notiy-send 'Tag $tags assignment toggle';"
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 spawn "riverctl set-focused-tags $all_tags; notify-send 'All tags focus toggle';"
riverctl map normal Super+Shift 0 spawn "riverctl set-view-tags $all_tags; notify-send 'All tags assignment toggle';"
# Toggle fullscreen
riverctl map normal None F11 toggle-fullscreen
riverctl map normal Super Z toggle-fullscreen
# 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
# Various media key mapping examples for both normal and locked mode which do
# not have a modifier
for mode in normal locked
do
riverctl map $mode None XF86Eject spawn 'eject -T'
# Control pulse audio volume with pamixer (https://github.com/cdemoulins/pamixer)
riverctl map $mode None XF86AudioRaiseVolume spawn 'pamixer -i 5'
riverctl map $mode None XF86AudioLowerVolume spawn 'pamixer -d 5'
riverctl map $mode None XF86AudioMute spawn 'pamixer --toggle-mute'
# Control MPRIS aware media players with playerctl (https://github.com/altdesktop/playerctl)
riverctl map $mode None XF86AudioMedia spawn 'playerctl play-pause'
riverctl map $mode None XF86AudioPlay spawn 'playerctl play-pause'
riverctl map $mode None XF86AudioPrev spawn 'playerctl previous'
riverctl map $mode None XF86AudioNext spawn 'playerctl next'
# Control screen backlight brightness with light (https://github.com/haikarainen/light)
riverctl map $mode None XF86MonBrightnessUp spawn 'light -A 5'
riverctl map $mode None XF86MonBrightnessDown spawn 'light -U 5'
done
# Set keyboard repeat rate
riverctl set-repeat 50 300
# Make all views with an app-id that starts with "float" and title "foo" start floating.
riverctl rule-add -app-id 'float*' -title 'foo' float
# Make all views with app-id "bar" and any title use client-side decorations
riverctl rule-add -app-id "bar" csd
# Global Configuration Settings
riverctl default-layout rivertile
rivertile -view-padding 10 -outer-padding 10 &
riverctl attach-mode bottom
riverctl hide-cursor timeout 10000
riverctl hide-cursor when-typing enabled
riverctl set-cursor-warp on-focus-change
riverctl focus-follows-cursor always
'';
};
};
}