dotfiles/desktop/.config/river/init
Marty Oehme 5dff1db3db
river: Add monocle mapping if running filtile layout
When using filtile layout it also gives the option of using 'monocle'
mode which is similar to fullscreen in that it only shows one window at
a time (which also occupies the full screen, except for the statusbar)
but you can cycle between the windows shown as you would usually between
the different views in a tag. You can imagine the windows 'stacked' on
top of each other and cycling which one is on top or on the bottom.

Toggled with `Mod+Shift+F`, shifting up from fullscreen mode.

TODO: Ideally, it would be accompanied by an indicator in the statusbar
but I have no time to create one currently. Without one, it is sometimes
hard to remember that other windows exist on the tag after a while.
2024-09-16 20:33:17 +02:00

322 lines
12 KiB
Bash
Executable file

#!/usr/bin/env sh
mod="Mod4"
modemod="Mod1"
term=${TERMINAL:-foot}
layout="filtile"
time_to_lockscreen=300
time_to_screendim=600
time_to_suspend=900
## OPTIONS
riverctl spawn "dbus-update-activation-environment SEATD_SOCK DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=river"
riverctl focus-follows-cursor normal
riverctl set-cursor-warp on-output-change
riverctl hide-cursor when-typing enabled
riverctl attach-mode bottom
# Set background and border color
riverctl background-color 0x000000
riverctl border-width 1
riverctl border-color-focused 0xffffff
riverctl border-color-unfocused 0x586e75
# Set repeat rate
riverctl set-repeat 75 300
# Make certain views start floating
riverctl rule-add -app-id float float
# riverctl rule-add -title "popup title with spaces" float
# # Set app-ids and titles of views which should use client side decorations
riverctl rule-add -app-id "gedit" csd
riverctl rule-add -app-id "org.pwmt.zathura" csd
## DEBUG
# Reload river configuration
riverctl map normal $mod+Shift F12 spawn "$HOME/.config/river/init"
## HOTKEYS
# close focused view
riverctl map normal $mod+Shift C close
# Open terminal
riverctl map normal $mod Return spawn "$term"
# Open floating terminal
riverctl map normal $mod+Control Return spawn "$term -e --class float"
# Open run menu
riverctl map normal $mod Space spawn "bemenu-run"
# Toggle status bar
riverctl map normal $mod F7 spawn "killall -SIGUSR1 waybar"
# Switch to lockscreen
riverctl map normal $mod X spawn "lockscreen"
# Open logout script
riverctl map normal $mod backspace spawn "powermenu"
# Open Bookmark search
riverctl map normal None XF86Search spawn "qutedmenu"
riverctl map normal $mod+Shift O spawn "qutedmenu"
# Clipboard history
riverctl map normal $mod+Shift Space spawn "clipman pick --tool=bemenu"
riverctl map normal $mod+Shift+Control Space spawn "clipman clear --all"
# Open floating calculator
riverctl map normal $mod+Shift R spawn "$term -e --class float qalc"
# Open emoji picker
riverctl map normal $mod+Shift E spawn "bemoji -nt"
# Open translation helper
riverctl map normal $mod+Shift T spawn "bemenu-translate"
# Open item from library
riverctl map normal $mod+Shift L spawn "papis -s picktool dmenu open"
# Desktop theming
# shellcheck disable=SC2016
riverctl map normal $mod+Shift S spawn 'flavourchoose'
# Password dropdown frontend
riverctl map normal $mod+Shift P spawn "pass-pick"
# File upload
riverctl map normal $mod+Shift U spawn "$term -e --class float sharefile | xargs notify-send"
# Open recent downloads
riverctl map normal $mod+Shift D spawn "recently-downloaded"
# # Screenshot
riverctl map normal None Print spawn "screenshot"
riverctl map normal Shift Print spawn "screenshot | sharefile -"
riverctl map normal $mod Print spawn "screenshot region"
riverctl map normal $mod+Shift Print spawn "screenshot region | sharefile -"
# control notification daemon
riverctl map normal $mod N spawn "makoctl dismiss"
riverctl map normal $mod+Shift N spawn "makoctl dismiss --all"
riverctl map normal $mod+Control N spawn "makoctl restore"
# MOVEMENT
# focus the next/previous view in the layout stack
riverctl map normal $mod J focus-view next
riverctl map normal $mod K focus-view previous
# swap the focused view with the next/previous view in the layout stack
riverctl map normal $mod+Shift J swap next
riverctl map normal $mod+Shift K swap previous
# bump the focused view to the top of the layout stack
riverctl map normal $mod+Shift Return zoom
# change layout orientation
riverctl map normal $mod Up send-layout-cmd $layout "main-location top"
riverctl map normal $mod Right send-layout-cmd $layout "main-location right"
riverctl map normal $mod Down send-layout-cmd $layout "main-location bottom"
riverctl map normal $mod Left send-layout-cmd $layout "main-location left"
# snap views to screen edges
riverctl map normal $mod+Control H snap left
riverctl map normal $mod+Control J snap down
riverctl map normal $mod+Control K snap up
riverctl map normal $mod+Control L snap right
# Mod+F to toggle fullscreen
riverctl map normal $mod F toggle-fullscreen
# if we are running filtile we also have access to monocle mode
if [ "$layout" = "filtile" ]; then
riverctl map normal $mod+Shift F spawn "riverctl send-layout-cmd $layout monocle"
fi
riverctl map normal $mod+Shift v toggle-float
# shellcheck disable=SC2016
# Make all connected outputs show the desktop and no windows at all
riverctl map normal $mod+Shift M spawn 'for i in $(wlopm | wc -l); do riverctl set-focused-tags $((1 << 10)); riverctl focus-output next; done; riverctl set-focused-tags $((1 << 10)); riverctl focus-output next'
riverctl map normal $mod+Shift F10 spawn "riverctl send-layout-cmd $layout '--tags all --output all view-padding 0'"
riverctl map normal $mod F10 spawn "riverctl send-layout-cmd $layout '--tags all --output all view-padding 6'"
# Mod + Left Mouse Button to move views
riverctl map-pointer normal $mod BTN_LEFT move-view
# Mod + Right Mouse Button to resize views
riverctl map-pointer normal $mod BTN_RIGHT resize-view
### Begin resize and moving mode, for floating windows
riverctl declare-mode interact_float
riverctl map normal $modemod R enter-mode interact_float
riverctl map interact_float $modemod R enter-mode normal
riverctl map interact_float None Escape enter-mode normal
# toggle float
riverctl map interact_float $mod+Shift v toggle-float
# move views around screen
riverctl map -repeat interact_float None H move left 100
riverctl map -repeat interact_float None J move down 100
riverctl map -repeat interact_float None K move up 100
riverctl map -repeat interact_float None L move right 100
# resize views on screen
riverctl map -repeat interact_float $mod H resize horizontal -100
riverctl map -repeat interact_float $mod J resize vertical 100
riverctl map -repeat interact_float $mod K resize vertical -100
riverctl map -repeat interact_float $mod L resize horizontal 100
# decrease/increase the main ratio of layout
riverctl map interact_float $mod+Shift H send-layout-cmd $layout "main-ratio -0.05"
riverctl map interact_float $mod+Shift L send-layout-cmd $layout "main-ratio +0.05"
# increment/decrement the main layout
riverctl map interact_float $mod+Shift J send-layout-cmd $layout "main-count +1"
riverctl map interact_float $mod+Shift K send-layout-cmd $layout "main-count -1"
# snap views to screen edges
riverctl map interact_float $mod+Control H snap left
riverctl map interact_float $mod+Control J snap down
riverctl map interact_float $mod+Control K snap up
riverctl map interact_float $mod+Control L snap right
### End resize and moving mode
## Passthrough mode which disables all other mappings and only retains the single
# mapping to return to normal mode. Useful for some full screen applications
# which should capture everything, or for testing nested wayland compositors.
riverctl declare-mode passthrough
riverctl map normal $mod F11 enter-mode passthrough
riverctl map passthrough $mod F11 enter-mode normal
# focus the next/previous output
riverctl map normal $mod Period focus-output next
riverctl map normal $mod Comma focus-output previous
# send the focused view to the next/previous output
riverctl map normal $mod+Shift Period send-to-output next
riverctl map normal $mod+Shift Comma send-to-output previous
# set up 10 tags (with '0' opening the 10th one)
for i in $(seq 0 9); do
tags="$((1 << (i - 1)))"
if [ "$i" -eq 0 ]; then tags="$((1 << 9))"; fi
# Mod+[1-9] to focus tag [0-8]
riverctl map normal $mod "$i" set-focused-tags $tags
# Mod+Shift+[1-9] to tag focused view with tag [0-8]
riverctl map normal $mod+Shift "$i" set-view-tags $tags
# Mod+Ctrl+[1-9] to toggle focus of tag [0-8]
riverctl map normal $mod+Control "$i" toggle-focused-tags $tags
# Mod+Shift+Ctrl+[1-9] to toggle tag [0-8] of focused view
riverctl map normal $mod+Shift+Control "$i" toggle-view-tags $tags
done
# focus all tags
all_tags=$(((1 << 32) - 1))
riverctl map normal $mod equal set-focused-tags $all_tags
# tag focused view with all tags
riverctl map normal $mod+Shift equal set-view-tags $all_tags
# Various media key mapping examples for both normal and locked mode which do
# not have a modifier
for mode in normal locked; do
# Eject the optical drive
riverctl map $mode None XF86Eject spawn 'eject -T'
riverctl map -repeat $mode None XF86AudioRaiseVolume spawn 'pactl set-sink-volume @DEFAULT_SINK@ +5%'
riverctl map -repeat $mode None XF86AudioLowerVolume spawn 'pactl set-sink-volume @DEFAULT_SINK@ -5%'
riverctl map $mode None XF86AudioMute spawn 'pactl set-sink-mute @DEFAULT_SINK@ toggle'
# 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'
# You can control screen backlight brighness with light (https://github.com/haikarainen/light); but we prefer brightnessctl
riverctl map -repeat $mode None XF86MonBrightnessUp spawn 'brightnessctl set 10%+'
riverctl map -repeat $mode None XF86MonBrightnessDown spawn 'brightnessctl set 10%-'
done
# The scratchpad will live on an unused tag. Which tags are used depends on your
# config, but rivers default uses the first 9 tags.
scratch_tag=$((1 << 20))
# Toggle showing the scratchpad
riverctl map normal $mod grave toggle-focused-tags ${scratch_tag}
# Send windows to the scratchpad
riverctl map normal $mod+Shift grave set-view-tags ${scratch_tag}
# Set spawn tagmask to ensure new windows don't have the scratchpad tag unless
# explicitly set.
all_but_scratch_tag=$((((1 << 32) - 1) ^ scratch_tag))
riverctl spawn-tagmask ${all_but_scratch_tag}
# set up scratch pad for todo and 'drop-down' terminal
# call scratchpads to current workspace -- scratchpads started on i3 starting (see end of file)
# bindsym $mod+t [class="scratchpad" title="dropdown-todo"] scratchpad show
# bindsym $mod+Shift+Return [class="scratchpad" title="dropdown-terminal"] scratchpad show
## INPUT
# device (touchscreen)
# enable touch clicking for touchpads
for pad in $(riverctl list-inputs | grep -i touchpad); do
riverctl input "$pad" events enabled
riverctl input "$pad" tap enabled
done
for pad in $(riverctl list-inputs | grep -i touchscreen); do
riverctl input "$pad" events enabled
riverctl input "$pad" tap enabled
riverctl input "$pad" drag enabled
riverctl input "$pad" pointer-accel 0.5
done
setxkbmap -option "compose:menu"
# start dynamic display configuration
[ "$(pidof kanshi)" -eq 0 ] || riverctl spawn kanshi
# set a nice wallpaper
if exist swww; then
riverctl spawn "swww init"
outputs=$(swww query | cut -d':' -f1)
if [ "$(echo "$outputs" | grep -c -e '^DP')" -eq 2 ] && [ -e "$HOME/pictures/wall_r.jpg" ]; then
swww img -o "$(echo "$outputs" | head -n1)" "$HOME/pictures/wall_l.jpg"
swww img -o "$(echo "$outputs" | tail -n1)" "$HOME/pictures/wall_r.jpg"
elif [ -e "$HOME/pictures/wall.jpg" ]; then
swww img "$HOME/pictures/wall.jpg"
fi
fi
# start status bar
killall waybar
riverctl spawn waybar
# start redshift-like sundown warming using current location or standard values
killall wlsunset
loc=$(curl ipinfo.io | grep -e '"loc": ' | sed -e 's/^.*"loc": "\(.*\)",$/\1/')
if [ -n "$loc" ]; then
riverctl spawn "wlsunset -l \"$(echo "$loc" | cut -d, -f1)\" -L \"$(echo "$loc" | cut -d, -f2)\""
else
riverctl spawn "wlsunset -S \"09:00\" -s \"21:00\" -d \"3600\""
fi
unset loc
# start screen idle locking/dimming/sleep tool
killall swayidle
riverctl spawn "swayidle \
timeout ${time_to_suspend} \"[ $(cat /sys/class/power_supply/AC/online) -eq 0 ] && systemctl suspend-then-hibernate\"
timeout ${time_to_screendim} \"wlopm --off '*'\" \
resume \"wlopm --on '*'\" \
timeout ${time_to_lockscreen} \"pidof waylock || lockscreen\" \
after-resume \"wlopm --on '*'\" \
before-sleep \"pidof waylock || lockscreen\" &"
killall clipman
riverctl spawn "wl-paste -t text --watch clipman store"
# bash ~/.config/bin/gtktheme # setting our gtk variables
# killall polkit-gnome-authentication-agent-1
# /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
# start layouting engine
killall $layout
riverctl spawn "$layout\
--tags all --output all main-ratio 0.65,\
--tags all --output all view-padding 6,\
--tags all --output all outer-padding 0,\
--tags all --output all smart-padding on,\
--tags all --output all smart-padding 0"
# River will send the process group of the init executable SIGTERM on exit.
riverctl default-layout $layout
brightnessctl set 70%