From 1536c752418d99b23888d22eba5d757c28c88b0c Mon Sep 17 00:00:00 2001 From: tiago Date: Fri, 19 May 2023 11:52:47 +0100 Subject: [PATCH] launch script fixed for laptop desktop and multimonitor laptop --- .config/polybar/config.ini | 11 +++++------ .config/polybar/launch.sh | 27 +++++++++++++++------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index 274fe82..2ac381d 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -25,8 +25,9 @@ pseudo-transparency = true [section/base] monitor = ${env:MONITOR:eDP1} +tray-position = ${env:TRAY_POS:right} -[bar/main] +[bar/laptop] inherit = section/base width = 99.4% height = 24pt @@ -50,8 +51,6 @@ font-2 = Inter:size=10:weight=regular;2 cursor-click = pointer enable-ipc = true -tray-position = right - override-redirect = true wm-restack = i3 @@ -83,7 +82,7 @@ enable-ipc = true override-redirect = true wm-restack = i3 -[bar/laptop] +[bar/desktop] inherit = section/base width = 99.4% height = 24pt @@ -91,9 +90,9 @@ offset-x = 0.3% offset-y = 0.7% ;radius = 8 -modules-left = i3 +modules-left = i3 sep title modules-center = date dot time -modules-right = cpu dot memory dot pulseaudio sep filesystem +modules-right = cpu dot gpu dot memory dot pulseaudio sep filesystem background = ${colors.base} foreground = ${colors.text} diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh index f885385..ba5593b 100755 --- a/.config/polybar/launch.sh +++ b/.config/polybar/launch.sh @@ -8,17 +8,20 @@ while pgrep -x polybar >/dev/null; do sleep 1; done screens=$(xrandr --listactivemonitors | grep -v "Monitors" | cut -d" " -f6) -if [[ $(xrandr --listactivemonitors | grep -v "Monitors" | cut -d" " -f4 | cut -d"+" -f2- | uniq | wc -l) == 1 ]]; then - MONITOR=$(polybar --list-monitors | cut -d":" -f1) TRAY_POS=right polybar main & +if [[ $(hostnamectl | grep Chassis | awk '{print $2}') == "laptop" ]]; then + if [[ $(xrandr --listactivemonitors | grep -v "Monitors" | cut -d" " -f4 | cut -d"+" -f2- | uniq | wc -l) == 1 ]]; then + MONITOR=$(polybar --list-monitors | cut -d":" -f1) TRAY_POS=right polybar laptop & + else + primary=$(xrandr --query | grep primary | cut -d" " -f1) + + for m in $screens; do + if [[ $primary == "$m" ]]; then + MONITOR=$m TRAY_POS=right polybar laptop & + else + MONITOR=$m TRAY_POS=none polybar secondary & + fi + done + fi else - primary=$(xrandr --query | grep primary | cut -d" " -f1) - - for m in $screens; do - if [[ $primary == "$m" ]]; then - MONITOR=$m TRAY_POS=right polybar main & - else - MONITOR=$m TRAY_POS=none polybar secondary & - fi - done + MONITOR=$(polybar --list-monitors | cut -d":" -f1) TRAY_POS=right polybar desktop & fi -