diff --git a/desktop/.config/river/init b/desktop/.config/river/init index f60427b..dcf40a2 100755 --- a/desktop/.config/river/init +++ b/desktop/.config/river/init @@ -8,6 +8,23 @@ time_to_lockscreen=300 time_to_screendim=600 time_to_suspend=900 +NO_RESTART="$1" +should_start() { # 1=program binary name + # not running, start + if ! pidof "$1"; then + return 0 + fi + + # only reload, no restarting + if [ "$NO_RESTART" = "no-restart" ]; then + return 1 + else + # kill then it can restart + killall "$1" + return 0 + fi +} + ## OPTIONS riverctl spawn "dbus-update-activation-environment SEATD_SOCK DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=river" riverctl focus-follows-cursor normal @@ -31,7 +48,8 @@ riverctl rule-add -app-id "org.pwmt.zathura" csd ## DEBUG # Reload river configuration -riverctl map normal $mod+Shift F12 spawn "$HOME/.config/river/init" +riverctl map normal $mod+Shift F12 spawn "$HOME/.config/river/init no-restart" +riverctl map normal $mod+Shift+Control F12 spawn "$HOME/.config/river/init" ## HOTKEYS # close focused view @@ -125,7 +143,7 @@ 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 +if [ "$layout" = "filtile" ]; then riverctl map normal $mod+Shift F spawn "riverctl send-layout-cmd $layout monocle" fi @@ -267,7 +285,7 @@ done setxkbmap -option "compose:menu" # start dynamic display configuration -[ "$(pidof kanshi)" -eq 0 ] || riverctl spawn kanshi +should_start kanshi && riverctl spawn kanshi # set a nice wallpaper if exist swaybg; then @@ -288,37 +306,36 @@ elif exist swww; then fi # start status bar -killall waybar -riverctl spawn waybar +should_start 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\"" +if should_start wlsunset; then + 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 fi -unset loc # start screen idle locking/dimming/sleep tool -killall swayidle -riverctl spawn "swayidle \ +should_start 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" + +should_start wl-paste && 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,\ +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,\