power menu, redshift, polybar
This commit is contained in:
25
.config/polybar/scripts/system-usb-mount/README.md
Normal file
25
.config/polybar/scripts/system-usb-mount/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Script: system-usb-mount
|
||||
|
||||
A small script that shows your mounted and not mounted removable devices.
|
||||
|
||||
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'" &`
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `jq`
|
||||
* `udisks2`
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/system-usb-mount]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/system-usb-mount.sh
|
||||
interval = 5
|
||||
click-left = ~/polybar-scripts/system-usb-mount.sh --mount &
|
||||
click-right = ~/polybar-scripts/system-usb-mount.sh --unmount &
|
||||
```
|
||||
53
.config/polybar/scripts/system-usb-mount/system-usb-mount.sh
Normal file
53
.config/polybar/scripts/system-usb-mount/system-usb-mount.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR)
|
||||
|
||||
case "$1" in
|
||||
--mount)
|
||||
for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == "1") | 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
|
||||
;;
|
||||
--unmount)
|
||||
for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == "1") | select(.mountpoint != null) | .name'); do
|
||||
udisksctl unmount --no-user-interaction -b "$unmount"
|
||||
udisksctl power-off --no-user-interaction -b "$unmount"
|
||||
done
|
||||
;;
|
||||
*)
|
||||
output=""
|
||||
counter=0
|
||||
|
||||
for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == "1") | 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 == "1") | 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"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user