power menu, redshift, polybar

This commit is contained in:
azpsen
2024-01-28 16:37:10 -06:00
parent 89516a6ce1
commit 319b44ecbd
307 changed files with 7642 additions and 5 deletions

View File

@@ -0,0 +1,4 @@
KERNEL=="sd*", ACTION=="add", ATTR{removable}=="1", \
RUN+="/home/user/.config/polybar/system-usb-udev.sh --update"
KERNEL=="sd*", ACTION=="remove", \
RUN+="/home/user/.config/polybar/system-usb-udev.sh --update"

View File

@@ -0,0 +1,35 @@
# Script: system-usb-udev
A small script that shows your mounted and not mounted removable devices. This is an extended version of [system-usb-mount](../system-usb-mount).
Click left to mount all removable devices. Click right to unmount the devices. The removable devices are then turned off with `udisksctl power-off`.
The mount option has a feature: You can also start a file manager and open the device when you mount it. Look at the example in the code: `terminal -e "bash -lc 'filemanager $mountpoint'" &`
This script is able to display device changes in real time. For this udev is being used.
![system-usb-mount](screenshots/1.png)
![system-usb-mount](screenshots/2.png)
## Dependencies
* `jq`
* `udisks2`
## Configuration
Copy `95-usb.rules` to `/etc/udev/rules.d/95-usb.rules`. Make sure that the paths in the file have been modified properly.
## Module
```ini
[module/system-usb-udev]
type = custom/script
exec = ~/polybar-scripts/system-usb-udev.sh
tail = true
click-left = ~/polybar-scripts/system-usb-udev.sh --mount &
click-right = ~/polybar-scripts/system-usb-udev.sh --unmount &
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,87 @@
#!/bin/sh
usb_print() {
devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR)
output=""
counter=0
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 "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor')
unmounted=$(echo "$unmounted" | tr -d ' ')
if [ $counter -eq 0 ]; then
space=""
else
space=" "
fi
counter=$((counter + 1))
output="$output$space#1 $unmounted"
done
for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .size'); do
if [ $counter -eq 0 ]; then
space=""
else
space=" "
fi
counter=$((counter + 1))
output="$output$space#2 $mounted"
done
echo "$output"
}
usb_update() {
pid=$(cat "$path_pid")
if [ "$pid" != "" ]; then
kill -10 "$pid"
fi
}
path_pid="/tmp/polybar-system-usb-udev.pid"
case "$1" in
--update)
usb_update
;;
--mount)
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
udisksctl mount --no-user-interaction -b "$mount"
# mountpoint=$(udisksctl mount --no-user-interaction -b $mount)
# mountpoint=$(echo $mountpoint | cut -d " " -f 4- | tr -d ".")
# terminal -e "bash -lc 'filemanager $mountpoint'"
done
usb_update
;;
--unmount)
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
udisksctl unmount --no-user-interaction -b "$unmount"
udisksctl power-off --no-user-interaction -b "$unmount"
done
usb_update
;;
*)
echo $$ > $path_pid
trap exit INT
trap "echo" USR1
while true; do
usb_print
sleep 60 &
wait
done
;;
esac