power menu, redshift, polybar
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
ACTION=="add", SUBSYSTEM=="tty"
|
||||
RUN+="/home/user/.config/polybar/info-usbtoserial.sh --update"
|
||||
ACTION=="remove", SUBSYSTEM=="tty"
|
||||
RUN+="/home/user/.config/polybar/info-usbtoserial.sh --update"
|
||||
20
.config/polybar/scripts/info-usbtoserial/README.md
Normal file
20
.config/polybar/scripts/info-usbtoserial/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Script: info-usbtoserial
|
||||
|
||||
A small script which shows the USB-to-Serial converters that are connected.
|
||||
|
||||
This script is able to display device changes in real time. For this udev is being used.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Copy `95-usbtoserial.rules` to `/etc/udev/rules.d/95-usbtoserial.rules`. Make sure that the paths in the file have been modified properly.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-usbtoserial]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-usbtoserial.sh
|
||||
tail = true
|
||||
```
|
||||
44
.config/polybar/scripts/info-usbtoserial/info-usbtoserial.sh
Normal file
44
.config/polybar/scripts/info-usbtoserial/info-usbtoserial.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
usbtoserial_print() {
|
||||
devices=$(find /dev/ -name "ttyUSB*")
|
||||
|
||||
counter=0
|
||||
for device in $devices; do
|
||||
device_name=$(udevadm info --query=property --export --name "$device" | grep ID_MODEL_FROM_DATABASE | cut -d "'" -f 2 | cut -d ' ' -f 1)
|
||||
|
||||
if [ $counter -gt 0 ]; then
|
||||
printf ", %s" "$device_name"
|
||||
else
|
||||
printf "#1 %s" "$device_name"
|
||||
fi
|
||||
|
||||
counter=$((counter + 1))
|
||||
done
|
||||
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
path_pid="/tmp/polybar-usbtoserial.pid"
|
||||
|
||||
case "$1" in
|
||||
--update)
|
||||
pid=$(cat $path_pid)
|
||||
|
||||
if [ "$pid" != "" ]; then
|
||||
kill -10 "$pid"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $$ > $path_pid
|
||||
|
||||
trap exit INT
|
||||
trap "echo" USR1
|
||||
|
||||
while true; do
|
||||
usbtoserial_print
|
||||
|
||||
sleep 30 &
|
||||
wait
|
||||
done
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user