From f79e4ac0ff81b0c5a9cb92355addb6437784ecde Mon Sep 17 00:00:00 2001
From: Tobias Reisinger <tobias@msrg.cc>
Date: Sun, 30 Jan 2022 21:29:23 +0100
Subject: [PATCH] Add bspwm modes

---
 .config/aliasrc       |  4 +++-
 .config/bspwm/bspwmrc | 42 +++++++++++++++++++++++++++++++++---------
 .xprofile             | 10 ++--------
 3 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/.config/aliasrc b/.config/aliasrc
index cb838bd..09d8a7f 100644
--- a/.config/aliasrc
+++ b/.config/aliasrc
@@ -12,7 +12,9 @@ alias aliases.local='$EDITOR ~/.config/aliasrc.local && . ~/.config/aliasrc'
 alias artisan='./artisan'
 
 alias bfg='java -jar ~/tools/bfg-1.13.0.jar'
-alias bspwm-present='pkill xcompmgr; bspc monitor "$MONITOR_PRIMARY" -d web terminal 3 4 5 6 7 8 9 presenter1; bspc monitor "$MONITOR_SECONDARY" -d presenter2'
+alias bspwm-default='echo "default" > /tmp/bspwm_mode; bspc wm -r'
+alias bspwm-present='echo "presenter" > /tmp/bspwm_mode; bspc wm -r'
+alias bspwm-single='echo "single" > /tmp/bspwm_mode; bspc wm -r'
 
 alias clip='xclip -selection clipboard'
 alias cp='cp -iv'
diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc
index 271271d..d51b968 100755
--- a/.config/bspwm/bspwmrc
+++ b/.config/bspwm/bspwmrc
@@ -2,18 +2,39 @@
 
 . "$HOME/.config/environment"
 
+pgrep -x sxhkd > /dev/null || sxhkd &
+pgrep -x xcompmgr > /dev/null || xcompmgr -cnfFn -D3 &
+
+
+bspc config remove_disabled_monitors true
+bspc config remove_unplugged_monitors true
+
 bspc config normal_border_color "#44475a"
 bspc config active_border_color "#bd93f9"
 bspc config focused_border_color "#ff79c6"
 bspc config presel_feedback_color "#6272a4"
 
 host_name=$(cat /proc/sys/kernel/hostname)
-if [ "$host_name" = "portalo" ]; then
-    xrandr --output "$MONITOR_PRIMARY" --mode 2560x1440 --refresh 144
-    xrandr --output "$MONITOR_SECONDARY" --left-of "$MONITOR_PRIMARY"
+mode=$(cat /tmp/bspwm_mode)
 
-    bspc monitor "$MONITOR_PRIMARY" -d web terminal 3 4 5 6 focus
-    bspc monitor "$MONITOR_SECONDARY" -d side-view voip messenger
+if [ "$host_name" = "portalo" ]; then
+    if [ "$mode" = "presenter" ]; then
+        xrandr --output "$MONITOR_PRIMARY" --mode 2560x1440 --refresh 144
+        xrandr --output "$MONITOR_SECONDARY" --auto --left-of "$MONITOR_PRIMARY"
+
+        pkill xcompmgr;
+        bspc monitor "$MONITOR_PRIMARY" -d web terminal 3 4 5 6 focus voip messenger presenter1
+        bspc monitor "$MONITOR_SECONDARY" -d presenter2
+    elif [ "$mode" = "single" ]; then
+        xrandr --output "$MONITOR_SECONDARY" --off
+        bspc monitor "$MONITOR_PRIMARY" -d web terminal 3 4 5 6 focus side-view voip messenger
+    else 
+        xrandr --output "$MONITOR_PRIMARY" --mode 2560x1440 --refresh 144
+        xrandr --output "$MONITOR_SECONDARY" --auto --left-of "$MONITOR_PRIMARY"
+
+        bspc monitor "$MONITOR_PRIMARY" -d web terminal 3 4 5 6 focus
+        bspc monitor "$MONITOR_SECONDARY" -d side-view voip messenger
+    fi
 
     bspc wm -O "$MONITOR_PRIMARY" "$MONITOR_SECONDARY"
     sleep 1
@@ -85,11 +106,14 @@ bspc rule -a 'Signal' desktop='messenger'
 bspc rule -a 'Thunderbird:Mail' desktop='messenger' locked='true'
 
 
-pgrep -x sxhkd > /dev/null || sxhkd &
-pgrep -x xcompmgr > /dev/null || xcompmgr -cnfFn -D3 &
-
-
 "$HOME/.config/polybar/launch.sh" &
 
 "$HOME/.config/bspwm/swallow.py" &
 "$HOME/.config/bspwm/focus-voip.py" &
+
+feh --bg-fill "$XDG_PICTURES_DIR/wallpaper/active_wallpaper"
+
+killall conky
+conky --daemonize --config="$HOME/.config/conky/clock.conf"
+conky --daemonize --config="$HOME/.config/conky/system.conf"
+conky --daemonize --config="$HOME/.config/conky/archlinux-updates.conf"
diff --git a/.xprofile b/.xprofile
index d7c7a0a..0b2ed49 100644
--- a/.xprofile
+++ b/.xprofile
@@ -54,7 +54,6 @@ _autostart_apps()
     conky --daemonize --config="$HOME/.config/conky/clock.conf"
     conky --daemonize --config="$HOME/.config/conky/system.conf"
     conky --daemonize --config="$HOME/.config/conky/archlinux-updates.conf"
-    feh --bg-fill "$XDG_PICTURES_DIR/wallpaper/active_wallpaper"
 
     #actkbd --grab --config ~/.config/actkbd/actkbd.conf --device /dev/input/by-id/usb-Dell_Dell_USB_Keyboard-event-kbd &
 
@@ -72,6 +71,8 @@ _autostart_apps()
     qutebrowser &
 
     mopidy &
+
+    /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
 }
 
 _autostart()
@@ -90,13 +91,6 @@ _autostart()
     _autostart_workspace_messenger &
 }
 
-#host_name=$(cat /proc/sys/kernel/hostname)
-#if [[ $host_name == "portalo" ]]; then
-#    _autostart_portalo &
-#elif [[ $host_name == *"laptop"* ]]; then
-#    _autostart_laptop &
-#fi
-
 _autostart &
 
 # vim: ft=sh