diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-04-02 15:02:21 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-04-02 15:02:21 +0200 |
commit | 0fff22af6d22a60c0fbf982f596b9c103bb1c6d3 (patch) | |
tree | 6d49f2265ed0da68546736ebbb98a9f9136f0af6 | |
parent | be4fdf85c759b8920608ec4ad828a0daefdce767 (diff) |
more versatile dual monitor scripts
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | bspwmrc | 5 | ||||
-rwxr-xr-x | init_monitor.sh | 23 | ||||
-rwxr-xr-x | polybar/normal/launch.sh | 18 | ||||
-rwxr-xr-x | polybar/normal/scr2.sh | 26 | ||||
-rw-r--r-- | polybar/normal/template.ini | 176 | ||||
-rwxr-xr-x | polybar/normal/tray.sh | 27 | ||||
-rwxr-xr-x | polybar/unsafe/launch.sh | 18 | ||||
-rwxr-xr-x | polybar/unsafe/scr2.sh | 26 | ||||
-rw-r--r-- | polybar/unsafe/template.ini | 176 | ||||
-rwxr-xr-x | polybar/unsafe/tray.sh | 27 |
11 files changed, 495 insertions, 29 deletions
@@ -1 +1,3 @@ alacritty/alacritty.yml +polybar/normal/config.ini +polybar/unsafe/config.ini @@ -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}) |