dotfiles/river/.config/river/init

191 lines
6.9 KiB
Bash
Executable file

#!/bin/sh
# Variables
term="foot"
term_client="footclient"
term_float="foot --app-id=float -w 1120x700"
browser="firefox"
email="thunderbird"
emacs="emacsclient --create-frame --alternate-editor='emacs'"
mod=Super
wobsock=$XDG_RUNTIME_DIR/wob.sock
rm -f $wobsock && mkfifo $wobsock && tail -f $wobsock | wob &
# Launch things
riverctl map normal $mod Return spawn footclient
riverctl map normal $mod+Shift Return spawn foot
riverctl map normal $mod Semicolon spawn fuzzel
riverctl map normal $mod BracketRight spawn "$browser"
riverctl map normal $mod T spawn "$email"
riverctl map normal $mod Z spawn "books.sh"
riverctl map normal $mod Y spawn "papers.sh"
riverctl map normal $mod E spawn "$emacs"
riverctl map normal $mod+Control O spawn "swaylock"
# Close windows & exit wm
riverctl map normal $mod+Shift C close
riverctl map normal $mod+Shift Q exit
# view stuff
riverctl map normal $mod J focus-view next
riverctl map normal $mod K focus-view previous
riverctl map normal $mod+Shift J swap next
riverctl map normal $mod+Shift K swap previous
riverctl map normal $mod+Shift Space zoom
# monitor stuff
riverctl map normal $mod Period focus-output next
riverctl map normal $mod Comma focus-output previous
riverctl map normal $mod+Shift Period send-to-output next
riverctl map normal $mod+Shift Comma send-to-output previous
# mess with main
riverctl map normal $mod H send-layout-cmd rivertile "main-ratio -0.05"
riverctl map normal $mod L send-layout-cmd rivertile "main-ratio +0.05"
riverctl map normal $mod+Shift H send-layout-cmd rivertile "main-count +1"
riverctl map normal $mod+Shift L send-layout-cmd rivertile "main-count -1"
# manipulate views
riverctl map normal $mod+Alt H move left 100
riverctl map normal $mod+Alt J move down 100
riverctl map normal $mod+Alt K move up 100
riverctl map normal $mod+Alt L move right 100
riverctl map normal $mod+Alt+Control H snap left
riverctl map normal $mod+Alt+Control J snap down
riverctl map normal $mod+Alt+Control K snap up
riverctl map normal $mod+Alt+Control L snap right
riverctl map normal $mod+Alt+Shift H resize horizontal -100
riverctl map normal $mod+Alt+Shift J resize vertical 100
riverctl map normal $mod+Alt+Shift K resize vertical -100
riverctl map normal $mod+Alt+Shift L resize horizontal 100
riverctl map-pointer normal $mod BTN_LEFT move-view
riverctl map-pointer normal $mod BTN_RIGHT resize-view
riverctl map-pointer normal $mod BTN_MIDDLE toggle-float
# tag stuff
for i in $(seq 1 9)
do
tags=$((1 << ($i - 1)))
riverctl map normal $mod $i set-focused-tags $tags
riverctl map normal $mod+Shift $i set-view-tags $tags
riverctl map normal $mod+Control $i toggle-focused-tags $tags
riverctl map normal $mod+Shift+Control $i toggle-view-tags $tags
done
all_tags=$(((1 << 32) - 1))
riverctl map normal $mod 0 set-focused-tags $all_tags
riverctl map normal $mod+Shift 0 set-view-tags $all_tags
# toggle
riverctl map normal $mod Space toggle-float
riverctl map normal $mod F toggle-fullscreen
# change layout orientation
riverctl map normal $mod+Control K send-layout-cmd rivertile "main-location top"
riverctl map normal $mod+Control L send-layout-cmd rivertile "main-location right"
riverctl map normal $mod+Control J send-layout-cmd rivertile "main-location bottom"
riverctl map normal $mod+Control H send-layout-cmd rivertile "main-location left"
# passthrough mode
riverctl declare-mode passthrough
riverctl map normal $mod F11 enter-mode passthrough
riverctl map passthrough $mod F11 enter-mode normal
# media key bindings
for mode in normal locked
do
riverctl map $mode None XF86Eject spawn 'eject -T'
riverctl map $mode None XF86AudioRaiseVolume spawn "amixer sset Master 5%+ | sed -En 's/.*\[([0-9]+)%\].*/\1/p' | head -1 > $wobsock"
riverctl map $mode None XF86AudioLowerVolume spawn "amixer sset Master 5%- | sed -En 's/.*\[([0-9]+)%\].*/\1/p' | head -1 > $wobsock"
riverctl map $mode None XF86AudioMute exec spawn "sset Master toggle | sed -En '/\[on\]/ s/.*\[([0-9]+)%\].*/\1/ p; /\[off\]/ s/.*/0/p' | head -1 > $wobsock"
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'
riverctl map $mode $mod+Control+Shift K spawn "brightnessctl set +5% | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > $wobsock"
riverctl map $mode $mod+Control+Shift J spawn "brightnessctl set 5%- | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > $wobsock"
done
# colors
riverctl background-color 0x1e1e2e
riverctl border-color-focused 0xf5c2e7
riverctl border-color-unfocused 0x586e75
riverctl border-width 2
# options
riverctl set-repeat 50 300
riverctl keyboard-layout -options "altwin:swap_lalt_lwin" us
riverctl focus-follows-cursor normal
riverctl hide-cursor timeout 10000
riverctl hide-cursor when-typing enabled
riverctl xcursor-theme Adwaita
touchpad=$(riverctl list-inputs | grep -i touchpad)
riverctl input $touchpad disable-while-typing enabled
riverctl input $touchpad natural-scroll enabled
riverctl input $touchpad tap enabled
# Make certain views start floating
riverctl float-filter-add app-id float
riverctl float-filter-add title "popup title with spaces"
riverctl float-filter-add app-id blueman-manager
# "Scratchpad"
scratch_tag=$((1 << 20))
riverctl map normal $mod Slash toggle-focused-tags $scratch_tag
riverctl map normal $mod+Shift Slash set-view-tags $scratch_tag
riverctl map normal $mod+Control Slash toggle-view-tags $scratch_tag
riverctl map normal $mod S spawn 'foot --app-id=float -w 1120x700'
riverctl rule-add -app-id float float
# SSD (so GTK apps show border)
riverctl rule-add -app-id firefox ssd
riverctl rule-add -app-id thunderbird ssd
riverctl rule-add -app-id emacs ssd
riverctl rule-add -app-id gnucash ssd
riverctl rule-add -app-id pcmanfm ssd
riverctl rule-add -app-id steam ssd
riverctl rule-add -app-id drracket ssd
riverctl rule-add -app-id org.pwmt.zathura ssd
riverctl rule-add -app-id org.gnome.Boxes ssd
riverctl rule-add -app-id com.github.xournalpp.xournalpp ssd
# spawn stuff
pgrep wbg || wbg ~/.config/wallpaper.png &
# pgrep swaybg || swaybg --image ~/.config/wallpaper.png &
wlr-randr --output eDP-1 --scale 1.25
pgrep yambar || yambar &
# mako stuff
pgrep mako || mako &
riverctl map normal $mod D spawn 'makoctl dismiss'
riverctl map normal $mod+Shift D spawn 'makoctl dismiss --all'
# foot server
foot --server & # TODO: figure out systemd service
# pianobar
riverctl map normal $mod+Shift S spawn '~/.config/pianobar/change_station.sh'
riverctl map normal $mod P spawn 'echo "p" > ~/.config/pianobar/ctl'
riverctl map normal $mod C spawn '~/.config/pianobar/display_info.sh'
riverctl map normal $mod N spawn 'echo "n" > ~/.config/pianobar/ctl'
# swayidle
pgrep swayidle || swayidle -w \
timeout 300 'swaylock -f -c 000000' \
before-sleep 'swaylock -f -c 000000' &
# start rivertile
riverctl default-layout rivertile
rivertile -view-padding 6 -outer-padding 6 -main-ratio 0.55 &