aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-04-02 15:02:21 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-04-02 15:02:21 +0200
commit0fff22af6d22a60c0fbf982f596b9c103bb1c6d3 (patch)
tree6d49f2265ed0da68546736ebbb98a9f9136f0af6
parentbe4fdf85c759b8920608ec4ad828a0daefdce767 (diff)
more versatile dual monitor scripts
-rw-r--r--.gitignore2
-rwxr-xr-xbspwmrc5
-rwxr-xr-xinit_monitor.sh23
-rwxr-xr-xpolybar/normal/launch.sh18
-rwxr-xr-xpolybar/normal/scr2.sh26
-rw-r--r--polybar/normal/template.ini176
-rwxr-xr-xpolybar/normal/tray.sh27
-rwxr-xr-xpolybar/unsafe/launch.sh18
-rwxr-xr-xpolybar/unsafe/scr2.sh26
-rw-r--r--polybar/unsafe/template.ini176
-rwxr-xr-xpolybar/unsafe/tray.sh27
11 files changed, 495 insertions, 29 deletions
diff --git a/.gitignore b/.gitignore
index 21602ed..f6c7b4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
alacritty/alacritty.yml
+polybar/normal/config.ini
+polybar/unsafe/config.ini
diff --git a/bspwmrc b/bspwmrc
index d30d18c..c967f66 100755
--- a/bspwmrc
+++ b/bspwmrc
@@ -17,8 +17,7 @@
pgrep -x sxhkd > /dev/null || sxhkd &
-xrandr --output 'DP2' --auto
-xrandr --output 'DP2' --right-of 'eDP1'
+SCR1=$(xrandr -q | grep ' connected' | grep primary | awk '{print $1}')
xss-lock --transfer-sleep-lock -- i3lock-fancy-rapid 1 10 &
@@ -42,7 +41,7 @@ killall -qw dunst; dunst &
killall -qw polybar; ~/.config/polybar/launch.sh &
killall -qw init_monitor.sh; ~/.config/bspwm/init_monitor.sh &
-bspc monitor 'eDP1' -n 1 -d 1 2 3 4 5 6 7 8 9
+bspc monitor "${SCR1}" -n 1 -d 1 2 3 4 5 6 7 8 9
bspc config border_width 0
bspc config window_gap 10
diff --git a/init_monitor.sh b/init_monitor.sh
index e2ed676..c008461 100755
--- a/init_monitor.sh
+++ b/init_monitor.sh
@@ -15,9 +15,28 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+SCR1=$(xrandr -q | grep ' connected' | grep primary | awk '{print $1}')
+
while [ true ]; do
- if [ "$(xrandr -q | grep 'DP2' | awk '{print $2}')" == "connected" ]; then
- bspc monitor 'DP2' -n 2 -d 1 2 3 4 5 6 7 8 9
+ SCR2=$(xrandr -q | grep ' connected' | grep -v primary | awk '{print $1}')
+
+ if [ "$(xrandr -q | grep "${SCR2}" | awk '{print $2}')" == "connected" ]; then
+ xrandr --output "${SCR2}" --auto
+ xrandr --output "${SCR2}" --right-of "${SCR1}"
+
+ sleep 1
+
+ bspc monitor "${SCR2}" -n 2 -d 1 2 3 4 5 6 7 8 9
+
+ MODE=$(readlink ~/.config/polybar | sed 's/\//\n/g' | tail -n 1)
+ if [ "${MODE}" == "normal" ]; then
+ BG="wallpaper"
+ elif [ "${MODE}" == "unsafe" ]; then
+ BG="unsafe_wallpaper"
+ fi
+
+ feh --no-fehbg --bg-fill "${HOME}/.config/bspwm/${BG}"
+
exit 0
fi
diff --git a/polybar/normal/launch.sh b/polybar/normal/launch.sh
index 2bba345..aebe8a0 100755
--- a/polybar/normal/launch.sh
+++ b/polybar/normal/launch.sh
@@ -15,18 +15,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-sleep 1
+SCR1=$(xrandr -q | grep ' connected' | grep primary | awk '{print $1}')
-polybar --reload -q main -c "${HOME}/.config/polybar/config.ini" &
-polybar --reload -q opt -c "${HOME}/.config/polybar/config.ini" &
-
-polybar --reload -q tray -c "${HOME}/.config/polybar/config.ini" &
+cp -p ${HOME}/.config/polybar/template.ini ${HOME}/.config/polybar/config.ini
+sed -i "s/SCR1/${SCR1}/g" ${HOME}/.config/polybar/config.ini
-while [[ $(pgrep -x polybar | wc -l) -lt 3 ]]; do sleep 1; done
-sleep 2
-
-while [ -z "$(bspc query -N -n any.fullscreen)" ]; do sleep 1; done
-sleep 2
+polybar --reload -q main -c "${HOME}/.config/polybar/config.ini" &
-TRAYBAR=$(pgrep -x polybar | tail -n 1)
-xdo above -t $(bspc query -N -n any.fullscreen) $(xdo id -p ${TRAYBAR})
+${HOME}/.config/polybar/scr2.sh &
+${HOME}/.config/polybar/tray.sh &
diff --git a/polybar/normal/scr2.sh b/polybar/normal/scr2.sh
new file mode 100755
index 0000000..d3a4b49
--- /dev/null
+++ b/polybar/normal/scr2.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+# Copyright (C) 2022 HimbeerserverDE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+while [ -z "${SCR2}" ]; do
+ SCR2=$(xrandr -q | grep ' connected' | grep -v primary | awk '{print $1}')
+done
+
+sleep 12
+
+sed -i "s/SCR2/${SCR2}/g" ${HOME}/.config/polybar/config.ini
+
+polybar --reload -q opt -c "${HOME}/.config/polybar/config.ini" &
diff --git a/polybar/normal/template.ini b/polybar/normal/template.ini
new file mode 100644
index 0000000..44e9442
--- /dev/null
+++ b/polybar/normal/template.ini
@@ -0,0 +1,176 @@
+[bar/base]
+monitor-strict = true
+override-redirect = false
+fixed-center = true
+width = 100%
+height = 44
+background = #111111
+foreground = #d8d8d8
+radius = 10.0
+border-size = 4
+border-color = #00000000
+border-bottom-size = 0
+padding = 2
+module-margin-left = 1
+module-margin-right = 1
+font-0 = "Terminus:size=10;3"
+font-1 = "Noto Color Emoji:pixelsize=16:style=Regular:scale=10;3"
+
+modules-left = workspaces sep wireless sep wired
+modules-right = cpu sep memory sep volume sep battery sep brightness sep date
+
+wm-name = bspwm
+wm-restack = bspwm
+enable-ipc = true
+
+[bar/main]
+inherit = bar/base
+monitor = SCR1
+width = 90%
+border-right-size = 2
+
+[bar/opt]
+inherit = bar/base
+monitor = SCR2
+
+[bar/tray]
+inherit = bar/base
+monitor = SCR1
+override-reditect = true
+width = 10%
+offset-x = 90%
+border-left-size = 2
+
+modules-left =
+modules-center = dummy
+modules-right =
+
+tray-position = center
+tray-detached = true
+
+wm-restack =
+
+[settings]
+throttle-output = 5
+throttle-output-for = 10
+
+; @see: https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-operator-t
+compositing-background = source
+compositing-foreground = over
+compositing-overline = over
+compositing-underline = over
+compositing-border = over
+
+[module/workspaces]
+type = internal/xworkspaces
+pin-workspaces = true
+enable-click = true
+enable-scroll = true
+reverse-scroll = true
+
+icon-0 = 1;e
+icon-1 = 2;l
+icon-2 = 3;i
+icon-3 = 4;d
+icon-4 = 5;r
+icon-5 = 6;a
+icon-6 = 7;g
+icon-7 = 8;o
+icon-8 = 9;n
+
+format = <label-state>
+label-active = "%{F#3366ff}%icon%"
+label-occupied = "%{F#33ff33}%icon%"
+label-urgent = "%{F#ff3333}%icon%"
+label-empty = "%{F#d8d8d8}%icon%"
+label-active-padding = 1
+label-urgent-padding = 1
+label-occupied-padding = 1
+label-empty-padding = 1
+
+[module/sep]
+type = custom/text
+content = |
+content-foreground = #a5a5a5
+
+[module/dummy]
+type = custom/text
+content = |
+content-foreground = #00000000
+
+[module/memory]
+type = internal/memory
+interval = 1
+format = <label>
+label = "🐏 %{F#33dddd}%gb_free%"
+label-warn = "🐏 %{F#ff3333}%gb_free%"
+
+[module/cpu]
+type = internal/cpu
+interval = 1
+format = <label>
+label = "πŸ’» %{F#33dddd}%percentage-cores%"
+
+[module/battery]
+type = internal/battery
+full-at = 97
+low-at = 15
+battery = BAT0
+adapter = AC
+poll-interval = 20
+time-format = %H:%M
+format-charging = <label-charging>
+format-discharging = <label-discharging>
+format-full = <label-full>
+format-low = <label-low>
+label-charging = "⚑ %percentage%% %time%"
+label-discharging = "πŸ”‹ %percentage%% %time%"
+label-full = "πŸ”Œ %percentage%%"
+label-low = "πŸ”‹πŸš¨ %{F#ff3333}%percentage%% %time%"
+
+[module/brightness]
+type = internal/backlight
+card = intel_backlight
+enable-scroll = true
+format = <label>
+label = "πŸ’‘ %percentage%%"
+
+[module/wireless]
+type = internal/network
+interface-type = wireless
+interval = 1.0
+format-connected = <label-connected>
+format-disconnected = <label-disconnected>
+format-packetloss = <label-packetloss>
+label-connected = "πŸ“Ά %essid% %{F#33dddd}%signal%% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+label-disconnected = "πŸ“ΆπŸš«"
+label-packetloss = "πŸ“ΆπŸ“¦πŸš¨ %essid% %{F#33dddd}%signal%% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+
+[module/wired]
+type = internal/network
+interface-type = wired
+interval = 1.0
+format-connected = <label-connected>
+format-disconnected = <label-disconnected>
+format-packetloss = <label-packetloss>
+label-connected = "πŸ”— %linkspeed% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+label-disconnected = "πŸ”—πŸš«"
+label-packetloss = "πŸ”—πŸ“¦πŸš¨ %linkspeed% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+
+[module/date]
+type = internal/date
+date = %Y-%m-%d
+time = %H:%M:%S
+date-alt = %d. %b %Y
+time-alt = %H:%M:%S
+format = <label>
+label = %date% %time%
+
+[module/volume]
+type = internal/alsa
+master-soundcard = default
+format-volume = <ramp-volume> <label-volume>
+label-muted = "πŸ”‡%percentage%%"
+ramp-volume-0 = πŸ”ˆ
+ramp-volume-1 = πŸ”‰
+ramp-volume-2 = πŸ”Š
diff --git a/polybar/normal/tray.sh b/polybar/normal/tray.sh
new file mode 100755
index 0000000..2029414
--- /dev/null
+++ b/polybar/normal/tray.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Copyright (C) 2022 HimbeerserverDE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+polybar --reload -q tray -c "${HOME}/.config/polybar/config.ini" &
+
+while [[ $(pgrep -x polybar | wc -l) -lt 3 ]]; do sleep 1; done
+sleep 2
+
+while [ -z "$(bspc query -N -n any.fullscreen)" ]; do sleep 1; done
+sleep 2
+
+TRAYBAR=$(pgrep -x polybar | tail -n 1)
+xdo above -t $(bspc query -N -n any.fullscreen) $(xdo id -p ${TRAYBAR})
diff --git a/polybar/unsafe/launch.sh b/polybar/unsafe/launch.sh
index 2bba345..aebe8a0 100755
--- a/polybar/unsafe/launch.sh
+++ b/polybar/unsafe/launch.sh
@@ -15,18 +15,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-sleep 1
+SCR1=$(xrandr -q | grep ' connected' | grep primary | awk '{print $1}')
-polybar --reload -q main -c "${HOME}/.config/polybar/config.ini" &
-polybar --reload -q opt -c "${HOME}/.config/polybar/config.ini" &
-
-polybar --reload -q tray -c "${HOME}/.config/polybar/config.ini" &
+cp -p ${HOME}/.config/polybar/template.ini ${HOME}/.config/polybar/config.ini
+sed -i "s/SCR1/${SCR1}/g" ${HOME}/.config/polybar/config.ini
-while [[ $(pgrep -x polybar | wc -l) -lt 3 ]]; do sleep 1; done
-sleep 2
-
-while [ -z "$(bspc query -N -n any.fullscreen)" ]; do sleep 1; done
-sleep 2
+polybar --reload -q main -c "${HOME}/.config/polybar/config.ini" &
-TRAYBAR=$(pgrep -x polybar | tail -n 1)
-xdo above -t $(bspc query -N -n any.fullscreen) $(xdo id -p ${TRAYBAR})
+${HOME}/.config/polybar/scr2.sh &
+${HOME}/.config/polybar/tray.sh &
diff --git a/polybar/unsafe/scr2.sh b/polybar/unsafe/scr2.sh
new file mode 100755
index 0000000..d3a4b49
--- /dev/null
+++ b/polybar/unsafe/scr2.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+# Copyright (C) 2022 HimbeerserverDE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+while [ -z "${SCR2}" ]; do
+ SCR2=$(xrandr -q | grep ' connected' | grep -v primary | awk '{print $1}')
+done
+
+sleep 12
+
+sed -i "s/SCR2/${SCR2}/g" ${HOME}/.config/polybar/config.ini
+
+polybar --reload -q opt -c "${HOME}/.config/polybar/config.ini" &
diff --git a/polybar/unsafe/template.ini b/polybar/unsafe/template.ini
new file mode 100644
index 0000000..b25fcb8
--- /dev/null
+++ b/polybar/unsafe/template.ini
@@ -0,0 +1,176 @@
+[bar/base]
+monitor-strict = true
+override-redirect = false
+fixed-center = true
+width = 100%
+height = 44
+background = #55eeeeee
+foreground = #d8d8d8
+radius = 10.0
+border-size = 4
+border-color = #00000000
+border-bottom-size = 0
+padding = 2
+module-margin-left = 1
+module-margin-right = 1
+font-0 = "Terminus:size=10;3"
+font-1 = "Noto Color Emoji:pixelsize=16:style=Regular:scale=10;3"
+
+modules-left = workspaces sep wireless sep wired
+modules-right = cpu sep memory sep volume sep battery sep brightness sep date
+
+wm-name = bspwm
+wm-restack = bspwm
+enable-ipc = true
+
+[bar/main]
+inherit = bar/base
+monitor = SCR1
+width = 90%
+border-right-size = 2
+
+[bar/opt]
+inherit = bar/base
+monitor = SCR2
+
+[bar/tray]
+inherit = bar/base
+monitor = SCR1
+override-reditect = true
+width = 10%
+offset-x = 90%
+border-left-size = 2
+
+modules-left =
+modules-center = dummy
+modules-right =
+
+tray-position = center
+tray-detached = true
+
+wm-restack =
+
+[settings]
+throttle-output = 5
+throttle-output-for = 10
+
+; @see: https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-operator-t
+compositing-background = source
+compositing-foreground = over
+compositing-overline = over
+compositing-underline = over
+compositing-border = over
+
+[module/workspaces]
+type = internal/xworkspaces
+pin-workspaces = true
+enable-click = true
+enable-scroll = true
+reverse-scroll = true
+
+icon-0 = 1;e
+icon-1 = 2;l
+icon-2 = 3;i
+icon-3 = 4;d
+icon-4 = 5;r
+icon-5 = 6;a
+icon-6 = 7;g
+icon-7 = 8;o
+icon-8 = 9;n
+
+format = <label-state>
+label-active = "%{F#3366ff}%icon%"
+label-occupied = "%{F#33ff33}%icon%"
+label-urgent = "%{F#ff3333}%icon%"
+label-empty = "%{F#d8d8d8}%icon%"
+label-active-padding = 1
+label-urgent-padding = 1
+label-occupied-padding = 1
+label-empty-padding = 1
+
+[module/sep]
+type = custom/text
+content = |
+content-foreground = #a5a5a5
+
+[module/dummy]
+type = custom/text
+content = |
+content-foreground = #00000000
+
+[module/memory]
+type = internal/memory
+interval = 1
+format = <label>
+label = "🐏 %{F#33dddd}%gb_free%"
+label-warn = "🐏 %{F#ff3333}%gb_free%"
+
+[module/cpu]
+type = internal/cpu
+interval = 1
+format = <label>
+label = "πŸ’» %{F#33dddd}%percentage-cores%"
+
+[module/battery]
+type = internal/battery
+full-at = 97
+low-at = 15
+battery = BAT0
+adapter = AC
+poll-interval = 20
+time-format = %H:%M
+format-charging = <label-charging>
+format-discharging = <label-discharging>
+format-full = <label-full>
+format-low = <label-low>
+label-charging = "⚑ %percentage%% %time%"
+label-discharging = "πŸ”‹ %percentage%% %time%"
+label-full = "πŸ”Œ %percentage%%"
+label-low = "πŸ”‹πŸš¨ %{F#ff3333}%percentage%% %time%"
+
+[module/brightness]
+type = internal/backlight
+card = intel_backlight
+enable-scroll = true
+format = <label>
+label = "πŸ’‘ %percentage%%"
+
+[module/wireless]
+type = internal/network
+interface-type = wireless
+interval = 1.0
+format-connected = <label-connected>
+format-disconnected = <label-disconnected>
+format-packetloss = <label-packetloss>
+label-connected = "πŸ“Ά %essid% %{F#33dddd}%signal%% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+label-disconnected = "πŸ“ΆπŸš«"
+label-packetloss = "πŸ“ΆπŸ“¦πŸš¨ %essid% %{F#33dddd}%signal%% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+
+[module/wired]
+type = internal/network
+interface-type = wired
+interval = 1.0
+format-connected = <label-connected>
+format-disconnected = <label-disconnected>
+format-packetloss = <label-packetloss>
+label-connected = "πŸ”— %linkspeed% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+label-disconnected = "πŸ”—πŸš«"
+label-packetloss = "πŸ”—πŸ“¦πŸš¨ %linkspeed% %{F#11cc11}%upspeed%↑ %downspeed%↓"
+
+[module/date]
+type = internal/date
+date = %Y-%m-%d
+time = %H:%M:%S
+date-alt = %d. %b %Y
+time-alt = %H:%M:%S
+format = <label>
+label = %date% %time%
+
+[module/volume]
+type = internal/alsa
+master-soundcard = default
+format-volume = <ramp-volume> <label-volume>
+label-muted = "πŸ”‡%percentage%%"
+ramp-volume-0 = πŸ”ˆ
+ramp-volume-1 = πŸ”‰
+ramp-volume-2 = πŸ”Š
diff --git a/polybar/unsafe/tray.sh b/polybar/unsafe/tray.sh
new file mode 100755
index 0000000..2029414
--- /dev/null
+++ b/polybar/unsafe/tray.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Copyright (C) 2022 HimbeerserverDE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+polybar --reload -q tray -c "${HOME}/.config/polybar/config.ini" &
+
+while [[ $(pgrep -x polybar | wc -l) -lt 3 ]]; do sleep 1; done
+sleep 2
+
+while [ -z "$(bspc query -N -n any.fullscreen)" ]; do sleep 1; done
+sleep 2
+
+TRAYBAR=$(pgrep -x polybar | tail -n 1)
+xdo above -t $(bspc query -N -n any.fullscreen) $(xdo id -p ${TRAYBAR})