1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00

feat(polybar): new arch config

This commit is contained in:
Ryan Kes 2021-03-13 15:33:38 +01:00
parent 3a13c57afd
commit 173bf78d1b
2 changed files with 66 additions and 64 deletions

View File

@ -1,90 +1,90 @@
#!/bin/sh #!/bin/sh
usb_print() { usb_print() {
devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR) devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR)
output="" output=""
counter=0 counter=0
for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do
unmounted=$(echo "$unmounted" | tr -d "[:digit:]") unmounted=$(echo "$unmounted" | tr -d "[:digit:]")
unmounted=$(echo "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor') unmounted=$(echo "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor')
unmounted=$(echo "$unmounted" | tr -d ' ') unmounted=$(echo "$unmounted" | tr -d ' ')
if [ $counter -eq 0 ]; then if [ $counter -eq 0 ]; then
space="" space=""
else else
space=" " space=" "
fi fi
counter=$((counter + 1)) counter=$((counter + 1))
output="$output$space $unmounted" output="$output$space $unmounted"
done done
for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .size'); do for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .size'); do
if [ $counter -eq 0 ]; then if [ $counter -eq 0 ]; then
space="" space=""
else else
space=" " space=" "
fi fi
counter=$((counter + 1)) counter=$((counter + 1))
output="$output$space $mounted" output="$output$space $mounted"
done done
if [ "$output" ]; then if [ "$output" ]; then
notify-send.py "USB" "$output" \ notify-send.py "USB" "$output" \
-i drive-removable-media-usb \ -i drive-removable-media-usb \
--replaces-process "usb-mount" & --replaces-process "usb-mount" &
fi fi
echo "$output" echo "$output"
} }
usb_update() { usb_update() {
pid=$(cat "$path_pid") pid=$(cat "$path_pid")
if [ "$pid" != "" ]; then if [ "$pid" != "" ]; then
kill -10 "$pid" kill -10 "$pid"
fi fi
} }
path_pid="/tmp/polybar-system-usb-udev.pid" path_pid="/tmp/polybar-system-usb-udev.pid"
case "$1" in case "$1" in
--update) --update)
usb_update usb_update
;; ;;
--mount) --mount)
devices=$(lsblk -Jplno NAME,TYPE,RM,MOUNTPOINT) devices=$(lsblk -Jplno NAME,TYPE,RM,MOUNTPOINT)
for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do
mountpoint=$(udisksctl mount --no-user-interaction -b "$mount") mountpoint=$(udisksctl mount --no-user-interaction -b "$mount")
mountpoint=$(echo "$mountpoint" | cut -d " " -f 4 | tr -d ".") mountpoint=$(echo "$mountpoint" | cut -d " " -f 4 | tr -d ".")
alacritty --class lf,lf -e lf "$mountpoint" & alacritty --class lf,lf -e lf "$mountpoint" &
done done
usb_update usb_update
;; ;;
--unmount) --unmount)
devices=$(lsblk -Jplno NAME,TYPE,RM,MOUNTPOINT) devices=$(lsblk -Jplno NAME,TYPE,RM,MOUNTPOINT)
for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .name'); do for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .name'); do
udisksctl unmount --no-user-interaction -b "$unmount" udisksctl unmount --no-user-interaction -b "$unmount"
udisksctl power-off --no-user-interaction -b "$unmount" udisksctl power-off --no-user-interaction -b "$unmount"
done done
usb_update usb_update
;; ;;
*) *)
echo $$ >$path_pid echo $$ >$path_pid
trap exit INT trap exit INT
trap "echo" USR1 trap "echo" USR1
while true; do while true; do
usb_print usb_print
sleep 60 & sleep 60 &
wait wait
done done
;; ;;
esac esac

View File

@ -57,7 +57,7 @@ inherit = bar/base-laptop
bottom = true bottom = true
monitor = ${env:MONITOR:eDP1} monitor = ${env:MONITOR:eDP1}
modules-right = system-usb-udev corona #modules-right = system-usb-udev corona
modules-left = mpd player-mpris-tail modules-left = mpd player-mpris-tail
[bar/laptop-top] [bar/laptop-top]
@ -72,17 +72,18 @@ tray-position = right
[bar/monitor1] [bar/monitor1]
inherit = bar/base-desktop inherit = bar/base-desktop
monitor = ${env:MONITOR:DP-1} monitor = ${env:MONITOR:DP-3}
modules-left = bspwm modules-left = bspwm
modules-center = mpd player-mpris-tail modules-center = mpd player-mpris-tail
modules-right = seperator corona seperator eth bluetooth seperator volume seperator docker memory cpu temperature seperator system-usb-udev filesystem-root filesystem-home seperator updates-arch-combined mail reddit github rss seperator weather seperator date seperator #modules-right = seperator corona seperator eth bluetooth seperator volume seperator docker memory cpu temperature seperator system-usb-udev filesystem-root filesystem-home seperator updates-arch-combined mail reddit github rss seperator weather seperator date seperator
modules-right = seperator corona seperator eth bluetooth seperator volume seperator docker memory cpu temperature seperator filesystem-root seperator updates-arch-combined mail reddit github rss seperator weather seperator date seperator
tray-position = right tray-position = right
[bar/monitor2] [bar/monitor2]
inherit = bar/base-desktop inherit = bar/base-desktop
monitor = ${env:MONITOR:HDMI-2} monitor = ${env:MONITOR:DP-2}
modules-left = bspwm modules-left = bspwm
;== Modules ======================================================== ;== Modules ========================================================
@ -180,6 +181,7 @@ ramp-load-4 = ▅
ramp-load-5 = ▆ ramp-load-5 = ▆
ramp-load-6 = ▇ ramp-load-6 = ▇
ramp-load-7 = █ ramp-load-7 = █
[module/cpu] [module/cpu]
type = internal/cpu type = internal/cpu