power menu, redshift, polybar
15
.config/polybar/scripts/battery-combined-shell/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Script: battery-combined-shell
|
||||
|
||||
A shell script that shows the battery status.
|
||||
|
||||
It supports two rechargeable batteries and changing icons. It works even if only one battery is used.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/battery-combined-shell]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/battery-combined-shell.sh
|
||||
interval = 10
|
||||
```
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
|
||||
PATH_AC="/sys/class/power_supply/AC"
|
||||
PATH_BATTERY_0="/sys/class/power_supply/BAT0"
|
||||
PATH_BATTERY_1="/sys/class/power_supply/BAT1"
|
||||
|
||||
ac=0
|
||||
battery_level_0=0
|
||||
battery_level_1=0
|
||||
battery_max_0=0
|
||||
battery_max_1=0
|
||||
|
||||
if [ -f "$PATH_AC/online" ]; then
|
||||
ac=$(cat "$PATH_AC/online")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_0/energy_now" ]; then
|
||||
battery_level_0=$(cat "$PATH_BATTERY_0/energy_now")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_0/energy_full" ]; then
|
||||
battery_max_0=$(cat "$PATH_BATTERY_0/energy_full")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_1/energy_now" ]; then
|
||||
battery_level_1=$(cat "$PATH_BATTERY_1/energy_now")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_1/energy_full" ]; then
|
||||
battery_max_1=$(cat "$PATH_BATTERY_1/energy_full")
|
||||
fi
|
||||
|
||||
battery_level=$(("$battery_level_0 + $battery_level_1"))
|
||||
battery_max=$(("$battery_max_0 + $battery_max_1"))
|
||||
|
||||
battery_percent=$(("$battery_level * 100"))
|
||||
battery_percent=$(("$battery_percent / $battery_max"))
|
||||
|
||||
if [ "$ac" -eq 1 ]; then
|
||||
icon="#1"
|
||||
|
||||
if [ "$battery_percent" -gt 97 ]; then
|
||||
echo "$icon"
|
||||
else
|
||||
echo "$icon $battery_percent %"
|
||||
fi
|
||||
else
|
||||
if [ "$battery_percent" -gt 85 ]; then
|
||||
icon="#21"
|
||||
elif [ "$battery_percent" -gt 60 ]; then
|
||||
icon="#22"
|
||||
elif [ "$battery_percent" -gt 35 ]; then
|
||||
icon="#23"
|
||||
elif [ "$battery_percent" -gt 10 ]; then
|
||||
icon="#24"
|
||||
else
|
||||
icon="#25"
|
||||
fi
|
||||
|
||||
echo "$icon $battery_percent %"
|
||||
fi
|
||||
31
.config/polybar/scripts/battery-combined-tlp/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Script: battery-combined-tlp
|
||||
|
||||
A shell script that shows the battery status.
|
||||
|
||||
It uses TLP and requires root privileges. Note that the icon doesn't change.
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `tlp`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You have to add the `tlp-stat` command to the `/etc/sudoers` NOPASSWD of your user:
|
||||
|
||||
```ini
|
||||
user ALL=(ALL) NOPASSWD: /usr/bin/tlp-stat
|
||||
```
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/battery-combined-tlp]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/battery-combined-tlp.sh
|
||||
interval = 10
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
battery=$(sudo tlp-stat -b | tac | grep -m 1 "Charge" | tr -d -c "[:digit:],.")
|
||||
|
||||
echo "# $battery %"
|
||||
BIN
.config/polybar/scripts/battery-combined-tlp/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 841 B |
@@ -0,0 +1,4 @@
|
||||
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", \
|
||||
RUN+="/home/user/.config/polybar/battery-combined-udev.sh --update"
|
||||
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", \
|
||||
RUN+="/home/user/.config/polybar/battery-combined-udev.sh --update"
|
||||
22
.config/polybar/scripts/battery-combined-udev/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Script: battery-combined-udev
|
||||
|
||||
A shell script that shows the battery status. This is an extended version of [battery-combined-shell](../battery-combined-shell).
|
||||
|
||||
It supports two rechargeable batteries and changing icons. It works even if only one battery is used.
|
||||
|
||||
This script is able to display power supply changes in real time. For this udev is being used.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Copy `95-battery.rules` to `/etc/udev/rules.d/95-battery.rules`. Make sure that the paths in the file have been modified properly.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/battery-combined-udev]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/battery-combined-udev.sh
|
||||
tail = true
|
||||
```
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
|
||||
battery_print() {
|
||||
PATH_AC="/sys/class/power_supply/AC"
|
||||
PATH_BATTERY_0="/sys/class/power_supply/BAT0"
|
||||
PATH_BATTERY_1="/sys/class/power_supply/BAT1"
|
||||
|
||||
ac=0
|
||||
battery_level_0=0
|
||||
battery_level_1=0
|
||||
battery_max_0=0
|
||||
battery_max_1=0
|
||||
|
||||
if [ -f "$PATH_AC/online" ]; then
|
||||
ac=$(cat "$PATH_AC/online")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_0/energy_now" ]; then
|
||||
battery_level_0=$(cat "$PATH_BATTERY_0/energy_now")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_0/energy_full" ]; then
|
||||
battery_max_0=$(cat "$PATH_BATTERY_0/energy_full")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_1/energy_now" ]; then
|
||||
battery_level_1=$(cat "$PATH_BATTERY_1/energy_now")
|
||||
fi
|
||||
|
||||
if [ -f "$PATH_BATTERY_1/energy_full" ]; then
|
||||
battery_max_1=$(cat "$PATH_BATTERY_1/energy_full")
|
||||
fi
|
||||
|
||||
battery_level=$(("$battery_level_0 + $battery_level_1"))
|
||||
battery_max=$(("$battery_max_0 + $battery_max_1"))
|
||||
|
||||
battery_percent=$(("$battery_level * 100"))
|
||||
battery_percent=$(("$battery_percent / $battery_max"))
|
||||
|
||||
if [ "$ac" -eq 1 ]; then
|
||||
icon="#1"
|
||||
|
||||
if [ "$battery_percent" -gt 97 ]; then
|
||||
echo "$icon"
|
||||
else
|
||||
echo "$icon $battery_percent %"
|
||||
fi
|
||||
else
|
||||
if [ "$battery_percent" -gt 85 ]; then
|
||||
icon="#21"
|
||||
elif [ "$battery_percent" -gt 60 ]; then
|
||||
icon="#22"
|
||||
elif [ "$battery_percent" -gt 35 ]; then
|
||||
icon="#23"
|
||||
elif [ "$battery_percent" -gt 10 ]; then
|
||||
icon="#24"
|
||||
else
|
||||
icon="#25"
|
||||
fi
|
||||
|
||||
echo "$icon $battery_percent %"
|
||||
fi
|
||||
}
|
||||
|
||||
path_pid="/tmp/polybar-battery-combined-udev.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
|
||||
battery_print
|
||||
|
||||
sleep 30 &
|
||||
wait
|
||||
done
|
||||
;;
|
||||
esac
|
||||
29
.config/polybar/scripts/battery-cyberpower/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Script: battery-cyberpower
|
||||
|
||||
A shell script that shows the battery status for CyberPower UPS devices.
|
||||
|
||||
This script is able to display power supply changes in real time.
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `pwrstat` from CyberPower's website
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You have to add the `pwrstat` command to the `/etc/sudoers` NOPASSWD of your user:
|
||||
|
||||
```ini
|
||||
user ALL=(ALL) NOPASSWD: /usr/bin/pwrstat
|
||||
```
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/battery-cyberpower]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/battery-cyberpower.sh
|
||||
tail = true
|
||||
```
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
|
||||
ICON_AC="#1"
|
||||
ICON_BATTERY_FULL="#21"
|
||||
ICON_BATTERY_GOOD="#22"
|
||||
ICON_BATTERY_LOW="#23"
|
||||
ICON_BATTERY_CAUTION="#24"
|
||||
ICON_BATTERY_EMPTY="#25"
|
||||
|
||||
SHOW_ESTIMATION=1
|
||||
|
||||
battery_print() {
|
||||
battery_info="$(sudo pwrstat -status)"
|
||||
battery_capacity="$(echo "$battery_info" | awk '/Capacity/{print $3}')"
|
||||
battery_ac="$(echo "$battery_info" | awk '/Power Supply by/{print $4,$5}')"
|
||||
battery_load="$(echo "$battery_info" | grep "Load" | cut -d \( -f 2 | tr -d ' %)')"
|
||||
battery_remaining="$(echo "$battery_info" | awk '/Remaining Runtime/{print $3}')"
|
||||
|
||||
output=""
|
||||
|
||||
if [ "$battery_ac" = "Utility Power" ]; then
|
||||
if [ "$battery_capacity" -gt 97 ]; then
|
||||
output="$ICON_AC"
|
||||
else
|
||||
output="$ICON_AC $battery_capacity %"
|
||||
fi
|
||||
else
|
||||
if [ "$battery_capacity" -gt 85 ]; then
|
||||
output="$ICON_BATTERY_FULL $battery_capacity %"
|
||||
elif [ "$battery_capacity" -gt 60 ]; then
|
||||
output="$ICON_BATTERY_GOOD $battery_capacity %"
|
||||
elif [ "$battery_capacity" -gt 35 ]; then
|
||||
output="$ICON_BATTERY_LOW $battery_capacity %"
|
||||
elif [ "$battery_capacity" -gt 10 ]; then
|
||||
output="$ICON_BATTERY_CAUTION $battery_capacity %"
|
||||
else
|
||||
output="$ICON_BATTERY_EMPTY $battery_capacity %"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$SHOW_ESTIMATION" -eq 1 ]; then
|
||||
output="$output ($battery_load % / $battery_remaining min)"
|
||||
fi
|
||||
|
||||
echo "$output"
|
||||
}
|
||||
|
||||
trap exit INT
|
||||
trap "echo" USR1
|
||||
|
||||
while true; do
|
||||
battery_print "$@"
|
||||
|
||||
sleep 30 &
|
||||
wait
|
||||
done
|
||||
16
.config/polybar/scripts/dunst-snooze/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Script: dunst-snooze
|
||||
|
||||
A script to disable/enable Dunst notifications. When disabled, notifications will still be created and saved by dunst until you enable it again.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Module
|
||||
```ini
|
||||
[module/dunst-snooze]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/dunst-snooze.sh
|
||||
interval = 10
|
||||
click-left = ~/polybar-scripts/dunst-snooze.sh --toggle &
|
||||
```
|
||||
14
.config/polybar/scripts/dunst-snooze/dunst-snooze.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
case "$1" in
|
||||
--toggle)
|
||||
dunstctl set-paused toggle
|
||||
;;
|
||||
*)
|
||||
if [ "$(dunstctl is-paused)" = "true" ]; then
|
||||
echo "#1"
|
||||
else
|
||||
echo "#2"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
BIN
.config/polybar/scripts/dunst-snooze/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 756 B |
BIN
.config/polybar/scripts/dunst-snooze/screenshots/2.png
Normal file
|
After Width: | Height: | Size: 955 B |
44
.config/polybar/scripts/easteregg-pornhub/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Script: easteregg-pornhub
|
||||
|
||||
A script that shows a button and opens a random video at a large porn website.
|
||||
|
||||

|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Set your browser at the `click-left` option in your module.
|
||||
|
||||
You should also enable the overline and underline option in your polybar.
|
||||
|
||||
```ini
|
||||
[bar/barname]
|
||||
|
||||
overline-size = 5
|
||||
underline-size = 4
|
||||
```
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/easteregg-pornhub]
|
||||
type = custom/script
|
||||
exec = echo " hub "
|
||||
interval = 3600
|
||||
click-left = "firefox --private-window https://pornhub.com/random" &
|
||||
|
||||
format = <label>
|
||||
format-prefix = " Porn "
|
||||
format-prefix-foreground = #ffffff
|
||||
format-prefix-background = #000000
|
||||
|
||||
format-overline = #000000
|
||||
format-underline = #000000
|
||||
format-foreground = #000000
|
||||
format-background = #ffa500
|
||||
|
||||
format-suffix = " "
|
||||
format-suffix-background = #000000
|
||||
format-suffix-foreground = #000000
|
||||
```
|
||||
BIN
.config/polybar/scripts/easteregg-pornhub/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
29
.config/polybar/scripts/inbox-imap-pythongpg/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Script: inbox-imap-pythongpg
|
||||
|
||||
A script that shows if there are unread mails in your IMAPs inbox. Passwords are encrypted with gpg.
|
||||
|
||||

|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You must have a gpg key to secure your password in configuration files. Encrypt your password using your gpg key like this.
|
||||
|
||||
```ini
|
||||
echo 'your password' > /tmp/imappass
|
||||
gpg -er 'your gpg keyid' /tmp/imappass
|
||||
mv /tmp/imappass.gpg ~/.imappass.gpg
|
||||
shred /tmp/imappass && rm /tmp/imappass
|
||||
```
|
||||
|
||||
For Gmail, you must allow [less secure apps](https://myaccount.google.com/security#connectedapps).
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/inbox-imap-pythongpg]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/inbox-imap-pythongpg.py
|
||||
interval = 60
|
||||
```
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import imaplib
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
completed_process = subprocess.run(['gpg', '-dq', os.path.join(os.getenv('HOME'), '.imappass.gpg')], check=True, stdout=subprocess.PIPE, encoding="utf-8");
|
||||
password = completed_process.stdout[:-1]
|
||||
obj = imaplib.IMAP4_SSL('imap.mail.net', 993)
|
||||
# Only put your email address below.
|
||||
obj.login('your email address', password)
|
||||
obj.select()
|
||||
|
||||
print(len(obj.search(None, 'unseen')[1][0].split()))
|
||||
BIN
.config/polybar/scripts/inbox-imap-pythongpg/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 542 B |
3
.config/polybar/scripts/inbox-imap-shellnetrc/.netrc
Normal file
@@ -0,0 +1,3 @@
|
||||
machine mail.server.tld
|
||||
login username
|
||||
password supersecretpw
|
||||
27
.config/polybar/scripts/inbox-imap-shellnetrc/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Script: inbox-imap-shellnetrc
|
||||
|
||||
A script that shows if there are unread mails in your IMAP inbox.
|
||||
|
||||
This script actually use IMAPs. `curl` can also handle unencrypted IMAP. You only need to change the protocol in the command.
|
||||
|
||||
The login data is stored in a `.netrc`. This is more secure because the password is not visible in the process list.
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `curl`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
For Gmail, you must allow [less secure apps](https://myaccount.google.com/security#connectedapps).
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/inbox-imap-shellnetrc]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/inbox-imap-shellnetrc.sh
|
||||
interval = 60
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
SERVER=""
|
||||
NETRC=".netrc"
|
||||
|
||||
inbox=$(curl -sf --netrc-file "$NETRC" -X "STATUS INBOX (UNSEEN)" imaps://"$SERVER"/INBOX | tr -d -c "[:digit:]")
|
||||
|
||||
if [ "$inbox" ] && [ "$inbox" -gt 0 ]; then
|
||||
echo "# $inbox"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
22
.config/polybar/scripts/inbox-imap-shellpass/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Script: inbox-imap-shellpass
|
||||
|
||||
A script that shows if there are unread mails in your IMAP inbox.
|
||||
|
||||
This script actually use IMAPs. `curl` can also handle unencrypted IMAP. You only need to change the protocol in the command.
|
||||
|
||||
The login data can be stored in your `pass` password manager.
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `curl`
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/inbox-imap-shellpass]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/inbox-imap-shellpass.sh
|
||||
interval = 60
|
||||
```
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
SERVER=""
|
||||
LOGIN=""
|
||||
PASS=""
|
||||
KEYGRIP=""
|
||||
|
||||
if [ "$(gpg-connect-agent 'keyinfo --list' /bye | grep "$KEYGRIP" | awk '{ print $7 }')" = 1 ]; then
|
||||
password=$(pass show "$PASS" | head -n 1)
|
||||
inbox=$(echo "user = \"$LOGIN:$password\"" | curl -sf -K- -X "STATUS INBOX (UNSEEN)" imaps://"$SERVER"/INBOX | tr -d -c "[:digit:]")
|
||||
|
||||
if [ "$inbox" ] && [ "$inbox" -gt 0 ]; then
|
||||
echo "# $inbox"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
3
.config/polybar/scripts/inbox-pop3-shellnetrc/.netrc
Normal file
@@ -0,0 +1,3 @@
|
||||
machine mail.server.tld
|
||||
login username
|
||||
password supersecretpw
|
||||
22
.config/polybar/scripts/inbox-pop3-shellnetrc/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Script: inbox-pop3-shellnetrc
|
||||
|
||||
A script that shows if there are unread mails in your POP3 inbox.
|
||||
|
||||
This script actually use POP3s. `curl` can also handle unencrypted POP3. You only need to change the protocol in the command.
|
||||
|
||||
The login data is stored in a `.netrc`. This is more secure because the password is not visible in the process list.
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `curl`
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/inbox-pop3-shellnetrc]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/inbox-pop3-shellnetrc.sh
|
||||
interval = 60
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
SERVER=""
|
||||
NETRC=".netrc"
|
||||
|
||||
inbox=$(curl -sf --netrc-file "$NETRC" pop3s://"$SERVER" | wc -l)
|
||||
|
||||
if [ "$inbox" -gt 0 ]; then
|
||||
echo "# $inbox"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
30
.config/polybar/scripts/info-airqualityindex/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Script: info-airqualityindex
|
||||
|
||||
A script that shows the local World Air Quality Index. It's an indicator for the air pollution.
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `curl`
|
||||
* `jq`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You need an API token. [Request one](https://aqicn.org/data-platform/token/).
|
||||
|
||||
Choose a city and make sure that the result is what you expect. `berlin` is a valid `CITY` here: http://aqicn.org/city/berlin/. Or use the [map](https://aqicn.org/map/) to find a monitoring station near you. `germany/berlin/friedrichshain-frankfurter-allee` works also as `CITY`.
|
||||
|
||||
If `CITY` is left empty, the location is retrieved via the Mozilla Location API.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-airqualityindex]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-airqualityindex.sh
|
||||
interval = 600
|
||||
```
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
TOKEN=""
|
||||
CITY=""
|
||||
|
||||
API="https://api.waqi.info/feed"
|
||||
|
||||
if [ -n "$CITY" ]; then
|
||||
aqi=$(curl -sf "$API/$CITY/?token=$TOKEN")
|
||||
else
|
||||
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
|
||||
|
||||
if [ -n "$location" ]; then
|
||||
location_lat="$(echo "$location" | jq '.location.lat')"
|
||||
location_lon="$(echo "$location" | jq '.location.lng')"
|
||||
|
||||
aqi=$(curl -sf "$API/geo:$location_lat;$location_lon/?token=$TOKEN")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$aqi" ]; then
|
||||
if [ "$(echo "$aqi" | jq -r '.status')" = "ok" ]; then
|
||||
aqi=$(echo "$aqi" | jq '.data.aqi')
|
||||
|
||||
if [ "$aqi" -lt 50 ]; then
|
||||
echo "%{F#009966}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 100 ]; then
|
||||
echo "%{F#ffde33}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 150 ]; then
|
||||
echo "%{F#ff9933}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 200 ]; then
|
||||
echo "%{F#cc0033}#%{F-} $aqi"
|
||||
elif [ "$aqi" -lt 300 ]; then
|
||||
echo "%{F#660099}#%{F-} $aqi"
|
||||
else
|
||||
echo "%{F#7e0023}#%{F-} $aqi"
|
||||
fi
|
||||
else
|
||||
echo "$aqi" | jq -r '.data'
|
||||
fi
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-airqualityindex/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
15
.config/polybar/scripts/info-camera-mic/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Script: info-camera-mic
|
||||
|
||||
A shell script for displaying an indicator of camera and microphone usage.
|
||||
|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-camera-mic]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-camera-mic.sh
|
||||
interval = 5
|
||||
```
|
||||
11
.config/polybar/scripts/info-camera-mic/info-camera-mic.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
if lsof /dev/video0 >/dev/null 2>&1; then
|
||||
camera="#1"
|
||||
fi
|
||||
|
||||
if pacmd list-sources 2>&1 | grep -q RUNNING; then
|
||||
mic="#2"
|
||||
fi
|
||||
|
||||
echo "$camera $mic"
|
||||
BIN
.config/polybar/scripts/info-camera-mic/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
29
.config/polybar/scripts/info-cava/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Script: info-cava
|
||||
|
||||
A simple script that runs a small audio visualizer using cava on your taskbar
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* [`cava`](https://github.com/karlstav/cava)
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Configuration can be made by providing the following command line arguments:
|
||||
* `-f`|`--framerate FRAMERATE` : Framerate to be used by cava, default is 60.
|
||||
* `-b`|`--bars BARS`: Amount of bars, default is 8.
|
||||
* `-e`|`--extra_colors EXTRA_COLORS`: Color gradient used on higher values, separated by commas, default is `fdd,fcc,fbb,faa`, spaces and #s are ignored.
|
||||
* `-c`|`--channels {stereo,left,right,average}`: Audio channels to be used, defaults to stereo.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-cava]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-cava.py -f 24 -b 12 -e fffdfc,fffafe,ffeafa,ffc3d2 -c average
|
||||
tail = true
|
||||
```
|
||||
75
.config/polybar/scripts/info-cava/info-cava.py
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/env python3
|
||||
import argparse
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == '--subproc':
|
||||
ramp_list = [' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█']
|
||||
ramp_list.extend(
|
||||
f'%{{F#{color.strip(" #")}}}█%{{F-}}'
|
||||
for color in sys.argv[2].split(',')
|
||||
if color
|
||||
)
|
||||
while True:
|
||||
cava_input = input().strip().split()
|
||||
cava_input = [int(i) for i in cava_input]
|
||||
output = ''
|
||||
for bar in cava_input:
|
||||
if bar < len(ramp_list):
|
||||
output += ramp_list[bar]
|
||||
|
||||
else:
|
||||
output += ramp_list[-1]
|
||||
|
||||
print(output)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-f', '--framerate', type=int, default=60,
|
||||
help='Framerate to be used by cava, default is 60')
|
||||
parser.add_argument('-b', '--bars', type=int, default=8,
|
||||
help='Amount of bars, default is 8')
|
||||
parser.add_argument('-e', '--extra_colors', default='fdd,fcc,fbb,faa',
|
||||
help='Color gradient used on higher values, separated by commas, default is')
|
||||
parser.add_argument('-c', '--channels', choices=['stereo', 'left', 'right', 'average'],
|
||||
help='Audio channels to be used, defaults to stereo')
|
||||
|
||||
opts = parser.parse_args()
|
||||
conf_channels = ''
|
||||
if opts.channels != 'stereo':
|
||||
conf_channels = (
|
||||
'channels=mono\n'
|
||||
f'mono_option={opts.channels}'
|
||||
)
|
||||
|
||||
conf_ascii_max_range = 12 + len([i for i in opts.extra_colors.split(',') if i])
|
||||
|
||||
cava_conf = tempfile.mkstemp('','polybar-cava-conf.')[1]
|
||||
with open(cava_conf, 'w') as cava_conf_file:
|
||||
cava_conf_file.write(
|
||||
'[general]\n'
|
||||
f'framerate={opts.framerate}\n'
|
||||
f'bars={opts.bars}\n'
|
||||
'[output]\n'
|
||||
'method=raw\n'
|
||||
'data_format=ascii\n'
|
||||
f'ascii_max_range={conf_ascii_max_range}\n'
|
||||
'bar_delimiter=32\n'
|
||||
+ conf_channels
|
||||
)
|
||||
|
||||
cava_proc = subprocess.Popen(['cava', '-p', cava_conf], stdout=subprocess.PIPE)
|
||||
self_proc = subprocess.Popen(['python3', __file__, '--subproc', opts.extra_colors], stdin=cava_proc.stdout)
|
||||
|
||||
def cleanup(sig, frame):
|
||||
os.remove(cava_conf)
|
||||
cava_proc.kill()
|
||||
self_proc.kill()
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, cleanup)
|
||||
signal.signal(signal.SIGINT, cleanup)
|
||||
|
||||
self_proc.wait()
|
||||
BIN
.config/polybar/scripts/info-cava/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
26
.config/polybar/scripts/info-docker/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Script: info-docker
|
||||
|
||||
Shows the number of Docker containers in one of the states: `created`, `restarting`, `running`, `removing`, `paused`, `exited`, `dead`
|
||||
|
||||

|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You have to add the `docker` command to the `/etc/sudoers` NOPASSWD of your user:
|
||||
|
||||
```ini
|
||||
user ALL=(ALL) NOPASSWD: /usr/bin/docker ps -qf status=running
|
||||
user ALL=(ALL) NOPASSWD: /usr/bin/docker ps -qf status=exited
|
||||
user ALL=(ALL) NOPASSWD: /usr/bin/docker ps -qf status=dead
|
||||
```
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-docker]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-docker.sh
|
||||
interval = 60
|
||||
```
|
||||
9
.config/polybar/scripts/info-docker/info-docker.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
STATUS="running exited dead"
|
||||
|
||||
for stat in $STATUS; do
|
||||
output="$output $(sudo docker ps -qf status="$stat" | wc -l) |"
|
||||
done
|
||||
|
||||
echo "|$output"
|
||||
BIN
.config/polybar/scripts/info-docker/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 626 B |
20
.config/polybar/scripts/info-dualshock4/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Script: info-dualshock4
|
||||
|
||||
A shell script that shows the battery level of a DualShock 4 Controller.
|
||||
|
||||

|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
The Icon is from [Font Awesome 5](https://fontawesome.com/icons/playstation?style=brands).
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/battery-dualshock4]
|
||||
type= custom/script
|
||||
exec = ~/polybar-scripts/info-dualshock4.sh
|
||||
interval = 10
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
for i in /sys/class/power_supply/sony_controller_battery_*/capacity; do
|
||||
echo "# $(cat /sys/class/power_supply/sony_controller_battery_"$i"/capacity)%"
|
||||
done
|
||||
BIN
.config/polybar/scripts/info-dualshock4/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
18
.config/polybar/scripts/info-ethermine/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Script: info-ethermine
|
||||
|
||||
This script reports the current hashrate (in MH/s) for your ethermine account.
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `python-requests`
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-ethermine]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-ethermine.sh
|
||||
interval = 60
|
||||
```
|
||||
12
.config/polybar/scripts/info-ethermine/info-ethermine.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
|
||||
miner = ""
|
||||
|
||||
data = requests.get(f"https://api.ethermine.org/miner/{miner}/dashboard").json()['data']['statistics']
|
||||
data = data[-1]
|
||||
current_hash_rate = data["currentHashrate"]
|
||||
currentMHs = round(current_hash_rate/1e6, 1)
|
||||
|
||||
print(f"{currentMHs}MH/s")
|
||||
15
.config/polybar/scripts/info-eyestrain/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Script: info-eyestrain
|
||||
|
||||
A script for avoiding digital eye strain.
|
||||
|
||||
It follows the 20-20-20 rule. The timer displays how long it is until the next break. You can add this to send a notification and play a sound when the time is up.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-eyestrain]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-eyestrain.sh
|
||||
interval = 60
|
||||
```
|
||||
10
.config/polybar/scripts/info-eyestrain/info-eyestrain.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
time=$((20 - $(date '+%-M') % 20))
|
||||
|
||||
#if [ $time -eq 20 ]; then
|
||||
# notify-send 'Break' &
|
||||
# ogg123 beep.ogg &> /dev/null &
|
||||
#fi
|
||||
|
||||
echo "$time"
|
||||
25
.config/polybar/scripts/info-gitlab-pipelines/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Script: info-gitlab-pipelines
|
||||
|
||||
Displays the number of succeeded, running and failed gitlab-pipelines triggered by a user.
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* jq
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Insert the specific server-url, username and your GitLab token (Settings -> Access Token).
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-gitlab-pipelines]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-gitlab-pipelines.sh
|
||||
interval = 30
|
||||
...
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
GITLAB_USERNAME=""
|
||||
GITLAB_SERVER="https://gitlab.com"
|
||||
GITLAB_ACCESS_TOKEN=""
|
||||
HOURS_AGO="6"
|
||||
|
||||
available_projects=$(curl -sH "Private-Token: $GITLAB_ACCESS_TOKEN" \
|
||||
"$GITLAB_SERVER/api/v4/projects?membership=true" | jq '.[] | .id')
|
||||
time=$(date -d "$HOURS_AGO hours ago" -Iseconds)
|
||||
|
||||
get_pipelines(){
|
||||
curl -sH "Private-Token: $GITLAB_ACCESS_TOKEN" \
|
||||
"$GITLAB_SERVER/api/v4/projects/$id/pipelines?username=$GITLAB_USERNAME&status=$1&updated_after=$time"| jq length
|
||||
}
|
||||
|
||||
for id in $available_projects; do
|
||||
success=$((success + $(get_pipelines "success")))
|
||||
running=$((running + $(get_pipelines "running")))
|
||||
failed=$((failed + $(get_pipelines "failed")))
|
||||
done
|
||||
|
||||
echo "|%{F#7cfc00}$success%{F-}|%{F#ffff00}$running%{F-}|%{F#f00}$failed%{F-}|"
|
||||
BIN
.config/polybar/scripts/info-gitlab-pipelines/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 602 B |
33
.config/polybar/scripts/info-hackspeed/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Script: info-hackspeed
|
||||
|
||||
A small script that shows your typing speed. Happy Hacking!
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `xorg-xinput`
|
||||
* `awk`
|
||||
* coreutils (`rm`, `stdbuf`, `mktemp`, `stat`, you probably have this)
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
* `KEYBOARD_ID`: name of your keyboard. See Setup above. Default: `AT Translated Set 2 keyboard`
|
||||
* `METRIC`: either `cpm` (characters per minute) of `wpm` ([words per minute, 1 word = 5 characters](https://en.wikipedia.org/wiki/Words_per_minute)). Default: `cpm`
|
||||
* `FORMAT`: format string according to which the metric will be output. Default: `# %d $METRIC`
|
||||
* `INTERVAL`: amount of seconds to gather data. Default: 20
|
||||
* `LAYOUT`: keyboard layout, to be able to only count letters and numbers. Currently supported are `qwerty`, `azerty`, `qwertz` and `dvorak`. If you have a different layout, please contribute a condition for it! See the script's source code. Use the special value `dontcare` to count all keys, not just letters and numbers. Default: `qwerty`
|
||||
|
||||
If after 20 seconds the value stays at 0 even though you're typing, you may have to configure the name of your keyboard. Change the setting `KEYBOARD_ID` (see Configuration below) in the script. You can find your keyboard description with `xinput list --short`.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-hackspeed]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-hackspeed.sh
|
||||
tail = true
|
||||
```
|
||||
64
.config/polybar/scripts/info-hackspeed/info-hackspeed.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2016,SC2059
|
||||
|
||||
KEYBOARD_ID="AT Translated Set 2 keyboard"
|
||||
|
||||
# cpm: characters per minute
|
||||
# wpm: words per minute (1 word = 5 characters)
|
||||
METRIC=cpm
|
||||
FORMAT="# %d $METRIC"
|
||||
|
||||
INTERVAL=20
|
||||
|
||||
# If you have a keyboard layout that is not listed here yet, create a condition
|
||||
# yourself. $3 is the key index. Use `xinput test "AT Translated Set 2 keyboard"`
|
||||
# to see key codes in real time. Be sure to open a pull request for your
|
||||
# layout's condition!
|
||||
LAYOUT=qwerty
|
||||
|
||||
case "$LAYOUT" in
|
||||
qwerty) CONDITION='($3 >= 10 && $3 <= 19) || ($3 >= 24 && $3 <= 33) || ($3 >= 37 && $3 <= 53) || ($3 >= 52 && $3 <= 58)'; ;;
|
||||
azerty) CONDITION='($3 >= 10 && $3 <= 19) || ($3 >= 24 && $3 <= 33) || ($3 >= 37 && $3 <= 54) || ($3 >= 52 && $3 <= 57)'; ;;
|
||||
qwertz) CONDITION='($3 >= 10 && $3 <= 20) || ($3 >= 24 && $3 <= 34) || ($3 == 36) || ($3 >= 38 && $3 <= 48) || ($3 >= 52 && $3 <= 58)'; ;;
|
||||
dvorak) CONDITION='($3 >= 10 && $3 <= 19) || ($3 >= 27 && $3 <= 33) || ($3 >= 38 && $3 <= 47) || ($3 >= 53 && $3 <= 61)'; ;;
|
||||
dontcare) CONDITION='1'; ;; # Just register all key presses, not only letters and numbers
|
||||
*) echo "Unsupported layout \"$LAYOUT\""; exit 1; ;;
|
||||
esac
|
||||
|
||||
# We have to account for the fact we're not listening a whole minute
|
||||
multiply_by=60
|
||||
divide_by=$INTERVAL
|
||||
|
||||
case "$METRIC" in
|
||||
wpm) divide_by=$((divide_by * 5)); ;;
|
||||
cpm) ;;
|
||||
*) echo "Unsupported metric \"$METRIC\""; exit 1; ;;
|
||||
esac
|
||||
|
||||
hackspeed_cache="$(mktemp -p '' hackspeed_cache.XXXXX)"
|
||||
trap 'rm "$hackspeed_cache"' EXIT
|
||||
|
||||
# Write a dot to our cache for each key press
|
||||
printf '' > "$hackspeed_cache"
|
||||
xinput test "$KEYBOARD_ID" | \
|
||||
stdbuf -o0 awk '$1 == "key" && $2 == "press" && ('"$CONDITION"') {printf "."}' >> "$hackspeed_cache" &
|
||||
|
||||
while true; do
|
||||
# Ask the kernel how big the file is with the command `stat`. The number we
|
||||
# get is the file size in bytes, which equals the amount of dots the file
|
||||
# contains, and hence how much keys were pressed since the file was last
|
||||
# cleared.
|
||||
lines=$(stat --format %s "$hackspeed_cache")
|
||||
|
||||
# Truncate the cache file so that in the next iteration, we count only new
|
||||
# keypresses
|
||||
printf '' > "$hackspeed_cache"
|
||||
|
||||
# The shell only does integer operations, so make sure to first multiply and
|
||||
# then divide
|
||||
value=$((lines * multiply_by / divide_by))
|
||||
|
||||
printf "$FORMAT\\n" "$value"
|
||||
|
||||
sleep $INTERVAL
|
||||
done
|
||||
BIN
.config/polybar/scripts/info-hackspeed/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 539 B |
31
.config/polybar/scripts/info-healthchecks.io/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Script: info-healthchecks.io
|
||||
|
||||
Shows the health of your services registered with [healthchecks.io](https://healthchecks.io).
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `jq`
|
||||
* `curl`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Modify any of the all-caps variables to configure the script:
|
||||
* `API_KEY`: Your [healthchecks.io](https://healthchecks.io) API key. These are project specific and can be generated on the project settings page.
|
||||
* `CHECK_ENDPOINT`: URL of the checks API endpoint. Change if self-hosting.
|
||||
* `STATES`: Array of states to monitor. Available options: `"up" "down" "new" "pending" "grace" "started" "paused"`
|
||||
* `COLORS`: Associative array that maps a color to each configured state. Defaults to white (#ffffff).
|
||||
* `SHOWN_TAGS`: Array of tags to show. Leave empty to disable filtering based on tags.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-healthchecks.io]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-healthchecks.io.sh
|
||||
interval = 60
|
||||
```
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Your API Key
|
||||
API_KEY=""
|
||||
# URL of the checks api endpoint. Change if self-hosting the service.
|
||||
CHECK_ENDPOINT="https://healthchecks.io/api/v1/checks/"
|
||||
|
||||
# States to track
|
||||
# Available options: up down new pending grace started paused
|
||||
STATES=("up" "down")
|
||||
# Color of each state. Defaults to white (#ffffff).
|
||||
declare -A COLORS=( [up]="#7cfc00" [down]="#ff0000" )
|
||||
# Leave empty to show all tags
|
||||
SHOWN_TAGS=()
|
||||
|
||||
function build_url {
|
||||
url=$CHECK_ENDPOINT
|
||||
next_sep="?"
|
||||
for tag in "${SHOWN_TAGS[@]}"; do
|
||||
url+="${next_sep}tag=${tag}"
|
||||
next_sep="&"
|
||||
done
|
||||
echo "$url"
|
||||
}
|
||||
|
||||
response=$(curl --silent --header "X-Api-Key: ${API_KEY}" "$(build_url)")
|
||||
|
||||
declare -A stati
|
||||
|
||||
for status in "up" "down"; do
|
||||
stati[$status]=0
|
||||
done
|
||||
|
||||
for status in $(echo "$response" | jq -r '.checks[].status'); do
|
||||
stati[$status]=$((stati[$status] + 1))
|
||||
done
|
||||
|
||||
output=""
|
||||
for status in "${STATES[@]}"; do
|
||||
count=${stati[$status]}
|
||||
if [ ${COLORS[$status]+_} ]; then
|
||||
color=${COLORS[$status]}
|
||||
else
|
||||
color="#ffffff"
|
||||
fi
|
||||
output+="|%{F${color}}${count}%{F-}"
|
||||
done
|
||||
|
||||
echo "${output:1}"
|
||||
BIN
.config/polybar/scripts/info-healthchecks.io/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 576 B |
15
.config/polybar/scripts/info-hexdate/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Script: info-hexdate
|
||||
|
||||
Print the current date in a hex format.
|
||||
|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-hexdate]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-hexdate.sh
|
||||
interval = 60
|
||||
```
|
||||
11
.config/polybar/scripts/info-hexdate/info-hexdate.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
day=$(timedatectl | grep "Local" | cut -d ":" -f2 | cut -d " " -f3 | cut -d "-" -f3)
|
||||
month=$(timedatectl | grep "Local" | cut -d ":" -f2 | cut -d " " -f3 | cut -d "-" -f2)
|
||||
year=$(timedatectl | grep "Local" | cut -d ":" -f2 | cut -d " " -f3 | cut -d "-" -f1)
|
||||
|
||||
day=$(echo "obase=16; $day" | bc)
|
||||
month=$(echo "obase=16; $month" | bc)
|
||||
year=$(echo "obase=16; $year" | bc)
|
||||
|
||||
echo "$day-$month-$year"
|
||||
BIN
.config/polybar/scripts/info-hexdate/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
27
.config/polybar/scripts/info-hlwm-workspaces/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Script: info-hlwm-workspaces
|
||||
|
||||
Displays all herbstluftwm workspaces with support for all workspace states (`focused`, `visible`, `occupied`, `empty`, `urgent`).
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `herbstluftwm` running as your WM
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
On its own the script is pretty plain as there are no colors. There are a bunch of <kbd>TODO</kbd> comments where you can `echo` [Formatting Tags](https://github.com/jaagr/polybar/wiki/Formatting#format-tags) for certain workspace state to make it more colorful and help you actually distinguish the different states.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-hlwm-workspaces]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-hlwm-workspaces.sh
|
||||
tail = true
|
||||
scroll-up = herbstclient use_index -1 --skip-visible &
|
||||
scroll-down = herbstclient use_index +1 --skip-visible &
|
||||
```
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Multi monitor support. Needs MONITOR environment variable to be set for each instance of polybar
|
||||
# If MONITOR environment variable is not set this will default to monitor 0
|
||||
# Check https://github.com/polybar/polybar/issues/763
|
||||
MON_IDX="0"
|
||||
mapfile -t MONITOR_LIST < <(polybar --list-monitors | cut -d":" -f1)
|
||||
for (( i=0; i<$((${#MONITOR_LIST[@]})); i++ )); do
|
||||
[[ ${MONITOR_LIST[${i}]} == "$MONITOR" ]] && MON_IDX="$i"
|
||||
done;
|
||||
|
||||
herbstclient --idle "tag_*" 2>/dev/null | {
|
||||
|
||||
while true; do
|
||||
# Read tags into $tags as array
|
||||
IFS=$'\t' read -ra tags <<< "$(herbstclient tag_status "${MON_IDX}")"
|
||||
{
|
||||
for i in "${tags[@]}" ; do
|
||||
# Read the prefix from each tag and render them according to that prefix
|
||||
case ${i:0:1} in
|
||||
'.')
|
||||
# the tag is empty
|
||||
# TODO Add your formatting tags
|
||||
;;
|
||||
':')
|
||||
# the tag is not empty
|
||||
# TODO Add your formatting tags
|
||||
;;
|
||||
'+')
|
||||
# the tag is viewed on the specified MONITOR, but this monitor is not focused.
|
||||
# TODO Add your formatting tags
|
||||
;;
|
||||
'#')
|
||||
# the tag is viewed on the specified MONITOR and it is focused.
|
||||
# TODO Add your formatting tags
|
||||
;;
|
||||
'-')
|
||||
# the tag is viewed on a different MONITOR, but this monitor is not focused.
|
||||
# TODO Add your formatting tags
|
||||
;;
|
||||
'%')
|
||||
# the tag is viewed on a different MONITOR and it is focused.
|
||||
# TODO Add your formatting tags
|
||||
;;
|
||||
'!')
|
||||
# the tag contains an urgent window
|
||||
# TODO Add your formatting tags
|
||||
;;
|
||||
esac
|
||||
|
||||
# focus the monitor of the current bar before switching tags
|
||||
echo "%{A1:herbstclient focus_monitor ${MON_IDX}; herbstclient use ${i:1}:} ${i:1} %{A -u -o F- B-}"
|
||||
done
|
||||
|
||||
# reset foreground and background color to default
|
||||
echo "%{F-}%{B-}"
|
||||
} | tr -d "\n"
|
||||
|
||||
echo
|
||||
|
||||
# wait for next event from herbstclient --idle
|
||||
read -r || break
|
||||
done
|
||||
} 2>/dev/null
|
||||
BIN
.config/polybar/scripts/info-hlwm-workspaces/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
13
.config/polybar/scripts/info-kernel/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Script: info-kernel
|
||||
|
||||
A script that shows the running kernel version.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-kernel]
|
||||
type = custom/script
|
||||
exec = uname -r
|
||||
interval = 1024
|
||||
```
|
||||
17
.config/polybar/scripts/info-pingrtt/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Script: info-pingrtt
|
||||
|
||||
A script that displays a ping result. It also shows a colored icon.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-pingrtt]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-pingrtt.sh
|
||||
interval = 10
|
||||
```
|
||||
19
.config/polybar/scripts/info-pingrtt/info-pingrtt.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
HOST=127.43.12.64
|
||||
|
||||
if ! ping=$(ping -n -c 1 -W 1 $HOST); then
|
||||
echo "# ping failed"
|
||||
else
|
||||
rtt=$(echo "$ping" | sed -rn 's/.*time=([0-9]{1,})\.?[0-9]{0,} ms.*/\1/p')
|
||||
|
||||
if [ "$rtt" -lt 50 ]; then
|
||||
icon="%{F#3cb703}#%{F-}"
|
||||
elif [ "$rtt" -lt 150 ]; then
|
||||
icon="%{F#f9dd04}#%{F-}"
|
||||
else
|
||||
icon="%{F#d60606}#%{F-}"
|
||||
fi
|
||||
|
||||
echo "$icon $rtt ms"
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-pingrtt/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 794 B |
BIN
.config/polybar/scripts/info-pingrtt/screenshots/2.png
Normal file
|
After Width: | Height: | Size: 878 B |
BIN
.config/polybar/scripts/info-pingrtt/screenshots/3.png
Normal file
|
After Width: | Height: | Size: 989 B |
19
.config/polybar/scripts/info-podman/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Script: info-podman
|
||||
|
||||
Shows the number of Podman containers in one of the states: `created`, `exited`, `paused`, `running`, `unknown`
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* [`podman`](https://github.com/containers/podman)
|
||||
|
||||
|
||||
## Module
|
||||
```ini
|
||||
[module/info-podman]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-podman.sh
|
||||
interval = 60
|
||||
```
|
||||
9
.config/polybar/scripts/info-podman/info-podman.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
STATUS="created exited paused running unknown"
|
||||
|
||||
for stat in $STATUS; do
|
||||
output="$output $(podman ps -qf status="$stat" | wc -l) |"
|
||||
done
|
||||
|
||||
echo "|$output"
|
||||
BIN
.config/polybar/scripts/info-podman/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 919 B |
15
.config/polybar/scripts/info-projecthamster/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Script: info-projecthamster
|
||||
|
||||
This script displays Hamster Time Tracker information.
|
||||
|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-projecthamster]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-projecthamster.sh
|
||||
interval = 5
|
||||
```
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
activity=$(hamster current 2> /dev/null | cut -d " " -f 3- | sed 's/@.* / - /')
|
||||
|
||||
if [ -n "$activity" ]; then
|
||||
echo "$activity"
|
||||
else
|
||||
echo "No Activity"
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-projecthamster/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
15
.config/polybar/scripts/info-redshift-temp/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Script: info-redshift-temp
|
||||
|
||||
This script displays the current color temperature.
|
||||
|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-redshift-temp]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-redshift-temp.sh
|
||||
interval = 5
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$(pgrep -x redshift)" ]; then
|
||||
temp=$(redshift -p 2> /dev/null | grep temp | cut -d ":" -f 2 | tr -dc "[:digit:]")
|
||||
|
||||
if [ -z "$temp" ]; then
|
||||
echo "%{F#65737E} #"
|
||||
elif [ "$temp" -ge 5000 ]; then
|
||||
echo "%{F#8FA1B3} #"
|
||||
elif [ "$temp" -ge 4000 ]; then
|
||||
echo "%{F#EBCB8B} #"
|
||||
else
|
||||
echo "%{F#D08770} #"
|
||||
fi
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-redshift-temp/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 589 B |
25
.config/polybar/scripts/info-softwarecounter/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Script: info-softwarecounter
|
||||
|
||||
A script that counts the number of specified running software including GUIs and processes.
|
||||
|
||||
Options to only monitor GUI applications or only processes exist. Users can add their own applications or processes they wish to watch simply by updating the existing dictionaries at the start of the script.
|
||||
|
||||
Arbitrary program counts can be combined, for example, the vim/nvim or chrome/chromium counts can be added together and the total displayed.
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `wmctrl`
|
||||
* `pgrep`
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```
|
||||
[module/info-softwarecounter]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-softwarecounter.py
|
||||
interval = 10
|
||||
```
|
||||
@@ -0,0 +1,223 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
from collections import Counter, OrderedDict
|
||||
import logging
|
||||
|
||||
|
||||
# update GUIs
|
||||
GUI = True
|
||||
|
||||
# update processes
|
||||
PROCESS = True
|
||||
|
||||
# Debugging feature
|
||||
DEBUG = False
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
if DEBUG:
|
||||
FORMAT = '%(asctime)s - %(levelname)s - %(funcName)s:%(lineno)d - %(message)s'
|
||||
logger.setLevel(logging.DEBUG)
|
||||
fh = logging.FileHandler(
|
||||
filename='./info-softwarecounter.log',
|
||||
encoding='utf-8'
|
||||
)
|
||||
fh.setLevel(logging.DEBUG)
|
||||
fh.setFormatter(logging.Formatter(FORMAT))
|
||||
logger.addHandler(fh)
|
||||
|
||||
|
||||
# _____ _ _ _____
|
||||
# / ____| | | |_ _|
|
||||
# | | __| | | | | |
|
||||
# | | |_ | | | | | |
|
||||
# | |__| | |__| |_| |_
|
||||
# \_____|\____/|_____|
|
||||
|
||||
|
||||
# program/process names and corresponding gylphs
|
||||
guis = OrderedDict({
|
||||
'terminals': '#',
|
||||
'chromes': '#',
|
||||
'firefox': '#',
|
||||
'skypeforlinux': '#',
|
||||
'filemanager': '#',
|
||||
'remote-desktop': '#',
|
||||
'pdfviewer': '#',
|
||||
'image': '#',
|
||||
})
|
||||
|
||||
# combine counts of program/process names in the tuple
|
||||
# the resulting glpyh used will be that of the corresponding key
|
||||
combine_guis = {
|
||||
'terminals': ('gnome-terminal-server', 'xfce4-terminal', 'alacritty', 'termite', 'terminator', 'urxvt'),
|
||||
'chromes': ('chromium', 'chrome'),
|
||||
'filemanager': ('nemo', 'thunar', 'dolphin', 'nautilus', 'pcmanfm'),
|
||||
'remote-desktop': ('TeamViewer', ),
|
||||
'pdfviewer': ('evince', 'okular', 'zathura'),
|
||||
'image': ('gthumb', 'shotwell', 'deepin-image-vi', 'eog', 'gimp-2.10'),
|
||||
}
|
||||
|
||||
|
||||
def get(cmd):
|
||||
return subprocess.check_output(cmd).decode("utf-8").strip()
|
||||
|
||||
|
||||
# def check_wtype(w_id):
|
||||
# # check the type of window, only list "NORMAL" windows
|
||||
# return "_NET_WM_WINDOW_TYPE_NORMAL" in get(["xprop", "-id", w_id])
|
||||
|
||||
|
||||
def get_process(w_id):
|
||||
# get the name of the process, owning the window
|
||||
proc = get(["ps", "-p", w_id, "-o", "cmd="])
|
||||
return proc.split()[0].split("/")[-1]
|
||||
|
||||
|
||||
def get_running_guis():
|
||||
|
||||
wlist = [
|
||||
line.split() for line in subprocess.check_output(
|
||||
["wmctrl", "-lp"]
|
||||
).decode("utf-8").splitlines()
|
||||
]
|
||||
|
||||
logger.debug("wlist after LC:")
|
||||
logger.debug("---------")
|
||||
for i in wlist:
|
||||
logger.debug(i)
|
||||
logger.debug("---------")
|
||||
|
||||
validprocs = [
|
||||
get_process(w[2]) for w in wlist if w[2] != '0' # and check_wtype(w[0])
|
||||
]
|
||||
|
||||
logger.debug(f"validprocs -> {validprocs}")
|
||||
return validprocs
|
||||
|
||||
|
||||
def GUI(gui_output=''):
|
||||
|
||||
# get list of running GUI programs
|
||||
gui_counts = Counter(get_running_guis())
|
||||
logger.debug(f"gui_counts -> {gui_counts}")
|
||||
|
||||
logger.debug("combine_guis items:")
|
||||
logger.debug("---------")
|
||||
# combine programs in program combine list
|
||||
for k, lst in combine_guis.items():
|
||||
logger.debug(f"{k} -> {lst}")
|
||||
count = 0
|
||||
for i in lst:
|
||||
try:
|
||||
count += gui_counts.pop(i)
|
||||
except KeyError:
|
||||
pass
|
||||
if count:
|
||||
gui_counts[k] += count
|
||||
logger.debug("---------")
|
||||
logger.debug(f"gui_counts after for loop -> {gui_counts}")
|
||||
|
||||
logger.debug("guis items:")
|
||||
logger.debug("---------")
|
||||
# generate program output
|
||||
for k, v in guis.items():
|
||||
logger.debug(f"{k} -> {v}")
|
||||
try:
|
||||
logger.debug(f"k, gui_counts[k] -> {k}, {gui_counts[k]}")
|
||||
c = gui_counts[k]
|
||||
if c:
|
||||
gui_output += '%s %i ' % (v, c)
|
||||
except Exception:
|
||||
pass
|
||||
logger.debug("---------")
|
||||
|
||||
logger.debug(f"gui_output -> {gui_output}")
|
||||
return gui_output
|
||||
|
||||
|
||||
# _____ _____ ____ _____ ______ _____ _____
|
||||
# | __ \| __ \ / __ \ / ____| ____|/ ____/ ____|
|
||||
# | |__) | |__) | | | | | | |__ | (___| (___
|
||||
# | ___/| _ /| | | | | | __| \___ \\___ \
|
||||
# | | | | \ \| |__| | |____| |____ ____) |___) |
|
||||
# |_| |_| \_\\____/ \_____|______|_____/_____/
|
||||
|
||||
|
||||
processes = OrderedDict({
|
||||
'vims': '#',
|
||||
'ssh': '#',
|
||||
'updater': '#',
|
||||
})
|
||||
|
||||
combine_proccesses = {
|
||||
'vims': ('nvim', 'vim', 'atom'),
|
||||
'updater': ('pacman', 'yay', 'trizen', 'yaourt', 'makepkg', 'auracle'),
|
||||
}
|
||||
|
||||
|
||||
def get_running_proc(process_name_list):
|
||||
counts = [None] * len(process_name_list)
|
||||
|
||||
for i, p in enumerate(process_name_list):
|
||||
try:
|
||||
count = int(
|
||||
subprocess.check_output(
|
||||
['pgrep', '-c', '-x', p]
|
||||
).decode('utf-8')
|
||||
)
|
||||
except subprocess.CalledProcessError:
|
||||
count = 0
|
||||
|
||||
counts[i] = (p, count)
|
||||
return dict(counts)
|
||||
|
||||
|
||||
def PROCESS(process_output=''):
|
||||
|
||||
# count running proccesses
|
||||
process_counts = get_running_proc(processes.keys())
|
||||
combine_counts = get_running_proc(
|
||||
list(sum(combine_proccesses.values(), ())))
|
||||
process_counts.update(combine_counts)
|
||||
|
||||
# combine processes in process combine list
|
||||
for k, lst in combine_proccesses.items():
|
||||
count = 0
|
||||
for i in lst:
|
||||
try:
|
||||
count += process_counts.pop(i)
|
||||
except KeyError:
|
||||
pass
|
||||
if count:
|
||||
process_counts[k] += count
|
||||
|
||||
# generate process output
|
||||
for k, v in processes.items():
|
||||
try:
|
||||
c = process_counts[k]
|
||||
if c:
|
||||
process_output += '%s %i ' % (v, c)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
logger.debug(f"process_output -> {process_output}")
|
||||
return process_output
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
if GUI:
|
||||
gui_output = GUI()
|
||||
|
||||
if PROCESS:
|
||||
process_output = PROCESS()
|
||||
|
||||
print(gui_output + process_output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.debug("------------ Script runs ------------")
|
||||
main()
|
||||
logger.debug("------------ Script stops ------------\n")
|
||||
BIN
.config/polybar/scripts/info-softwarecounter/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
20
.config/polybar/scripts/info-ssh-sessions/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Script: info-ssh-sessions
|
||||
|
||||
A script that displays the count of current ssh sessions as well as the public IP address of the fist session.
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `lsof`
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-ssh-sessions]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-ssh-sessions.sh
|
||||
interval = 5
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
sessions="$(lsof -Pi | grep ":22")"
|
||||
|
||||
if [ -n "$sessions" ]; then
|
||||
count=$(echo "$sessions" | wc -l)
|
||||
echo "# ($count): $(echo "$sessions" | cut -d ">" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 | tail -n 1)"
|
||||
else
|
||||
echo "# (0)"
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-ssh-sessions/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
28
.config/polybar/scripts/info-taskspooler/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Script: info-taskspooler
|
||||
|
||||
A small script that displays the number of queues/runtimes for one or more task spooler servers.
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `task-spooler`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
By default the script will output the count of the default task-spooler server.
|
||||
|
||||
Arguments can be passed to show custom task-spooler servers by using the `TS_SOCKET variable`. These custom servers will need to use a socket filename format like /tmp/ts-socket.SOCK_NAME or the script will be unable to find the server. Arguments are passed as `name,sock_name` with sock_name being optional, e.g. `default yt,youtube p,podcast`.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-taskspooler]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-task-spooler/info-taskspooler.sh
|
||||
# exec = ~/polybar-scripts/info-taskspooler/info-taskspooler.sh default yt,youtube p,podcast
|
||||
interval = 5
|
||||
```
|
||||
27
.config/polybar/scripts/info-taskspooler/info-taskspooler.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# USAGE:
|
||||
# No arguments: prints the job running/queued job count of the default tsp server
|
||||
# Arguments: name,sock_name - one or more arguments, e.g. tsp yt,youtube p,podcasts
|
||||
# sock_name is optional, will default to default tsp socket
|
||||
# custom socket names will be generated as /tmp/ts-socket.SOCK_NAME, your TS_SOCKET will need to match
|
||||
|
||||
get_tsp_count() {
|
||||
sock=/tmp/socket-ts.${1:-$(id -u)}
|
||||
|
||||
tsp_count=$(TS_SOCKET=$sock tsp|grep -E -c 'running|queued')
|
||||
echo "${tsp_count:-0}"
|
||||
}
|
||||
|
||||
# without argument, just show count of default socket
|
||||
if [ $# -lt 1 ]; then
|
||||
get_tsp_count
|
||||
else
|
||||
for t in "$@"; do
|
||||
IFS=, read -r name sock_name <<- EOF
|
||||
${t}
|
||||
EOF
|
||||
|
||||
echo "${name} $(get_tsp_count "${sock_name}")"
|
||||
done|sed 'N;s/\n/ /'
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-taskspooler/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
16
.config/polybar/scripts/info-timew/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Script: info-timew
|
||||
|
||||
This script displays the daily tracked time. You can click it, to start tracking, using timew.
|
||||
|
||||
You can use the `--weekday` toggle, to view daily or weekly time spend. (may take the `interval` time to update)
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-timew]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-timew.sh
|
||||
interval = 10
|
||||
click-left = ~/polybar-scripts/info-timew.sh --toggle
|
||||
click-right = ~/polybar-scripts/info-timew.sh --weekday
|
||||
```
|
||||
40
.config/polybar/scripts/info-timew/info-timew.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
MODE_FILE="$HOME/.config/polybar/info-timew.mode"
|
||||
|
||||
if [ ! -f "${MODE_FILE}" ]; then
|
||||
touch "${MODE_FILE}"
|
||||
echo "d" > "${MODE_FILE}"
|
||||
fi
|
||||
|
||||
ACTUAL_MODE=$(cat "${MODE_FILE}")
|
||||
|
||||
if timew > /dev/null 2>&1; then
|
||||
if [ "$ACTUAL_MODE" = "w" ]; then
|
||||
printf '%s/week' "$(timew summary :week | awk '{print $NF}' | tail -2 | head -1)"
|
||||
else
|
||||
printf '%s/day' "$(timew summary :day | awk '{print $NF}' | tail -2 | head -1)"
|
||||
fi
|
||||
else
|
||||
printf "no tracking"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ "${1}" = "--weekday" ]; then
|
||||
if [ "$ACTUAL_MODE" = "w" ]; then
|
||||
echo "d" > "${MODE_FILE}"
|
||||
else
|
||||
echo "w" > "${MODE_FILE}"
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "${1}" = "--toggle" ]; then
|
||||
if timew; then
|
||||
timew stop;
|
||||
else
|
||||
timew start;
|
||||
fi
|
||||
fi
|
||||
16
.config/polybar/scripts/info-timezone/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Script: info-timezone
|
||||
|
||||
A custom polybar script to switch the timezone of the date displayed.
|
||||
|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-timezone]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-timezone.sh
|
||||
tail = true
|
||||
click-left = kill -USR1 %pid%
|
||||
```
|
||||
35
.config/polybar/scripts/info-timezone/info-timezone.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Change format here. see `man date` for format controls.
|
||||
FORMAT="%I:%M %p"
|
||||
|
||||
# Add the timezones of your choice. see `timedatectl list-timezones`.
|
||||
set -- "UTC-0" "Australia/Sydney" "Asia/Kolkata" "America/Chicago"
|
||||
|
||||
TIMEZONES_LENGTH=$#
|
||||
current_idx=1
|
||||
|
||||
print_date() {
|
||||
TZ=${current_timezone:?} date +"${FORMAT}" | echo "${current_timezone:?}: $(cat -)"
|
||||
}
|
||||
|
||||
update_current_timezone() {
|
||||
current_idx=$(($((current_idx+1)) % $(("$TIMEZONES_LENGTH"+1))))
|
||||
if [ $current_idx -lt 1 ]; then
|
||||
current_idx=1
|
||||
fi
|
||||
}
|
||||
|
||||
click() {
|
||||
update_current_timezone
|
||||
print_date
|
||||
}
|
||||
|
||||
trap "click" USR1
|
||||
|
||||
while true; do
|
||||
eval "current_timezone=\${$current_idx}"
|
||||
print_date current_timezone
|
||||
sleep 5 &
|
||||
wait
|
||||
done
|
||||
BIN
.config/polybar/scripts/info-timezone/screenshots/1.gif
Normal file
|
After Width: | Height: | Size: 14 KiB |
16
.config/polybar/scripts/info-tmux-sessions/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Script: info-tmux-sessions
|
||||
|
||||
A simple script to show tmux sessions.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-tmux-sessions]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-tmux-sessions.sh
|
||||
interval = 5
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
#! /bin/sh
|
||||
|
||||
if sessionlist=$(tmux ls 2>/dev/null); then
|
||||
printf "# "
|
||||
|
||||
echo "$sessionlist" | while read -r line; do
|
||||
session=$(echo "$line" | cut -d ':' -f 1)
|
||||
|
||||
if echo "$line" | grep -q "(attached)"; then
|
||||
status="(a)"
|
||||
else
|
||||
status=""
|
||||
fi
|
||||
|
||||
printf "%s%s " "$session" "$status"
|
||||
done
|
||||
|
||||
printf "\n"
|
||||
else
|
||||
printf "# none\n"
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-tmux-sessions/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
.config/polybar/scripts/info-tmux-sessions/screenshots/2.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
15
.config/polybar/scripts/info-todotxt/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Script: info-todotxt
|
||||
|
||||
A script that shows todo.txt items due. The first column shows items due today, and the second column shows items due this week (including today).
|
||||
|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-todotxt]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-todotxt.sh
|
||||
interval = 60
|
||||
```
|
||||
16
.config/polybar/scripts/info-todotxt/info-todotxt.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
duetoday=$(grep "due:$(date -I)" ~/todo.txt | grep -c -v "x")
|
||||
dueweek=0
|
||||
weekday=0
|
||||
|
||||
while [ "$weekday" -le 7 ]; do
|
||||
dueweek=$((dueweek + $(grep "due:$(date -I --date="$weekday day")" ~/todo.txt | grep -c -v "x")))
|
||||
weekday=$(( weekday + 1 ))
|
||||
done
|
||||
|
||||
if [ "$dueweek" -gt 0 ]; then
|
||||
echo "#1 $duetoday $dueweek"
|
||||
else
|
||||
echo "#2"
|
||||
fi
|
||||
BIN
.config/polybar/scripts/info-todotxt/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 994 B |
16
.config/polybar/scripts/info-trash/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Script: info-trash
|
||||
|
||||
This script count the files in you trash directory.
|
||||
|
||||

|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-trash]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-trash.sh
|
||||
interval = 60
|
||||
click-left = ~/polybar-scripts/info-trash.sh --clean &
|
||||
```
|
||||
13
.config/polybar/scripts/info-trash/info-trash.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
case "$1" in
|
||||
--clean)
|
||||
rm -rf ~/.local/share/Trash/files
|
||||
rm -rf ~/.local/share/Trash/info
|
||||
mkdir ~/.local/share/Trash/files
|
||||
mkdir ~/.local/share/Trash/info
|
||||
;;
|
||||
*)
|
||||
find ~/.local/share/Trash/files/ -maxdepth 1 | wc -l
|
||||
;;
|
||||
esac
|
||||
BIN
.config/polybar/scripts/info-trash/screenshots/1.png
Normal file
|
After Width: | Height: | Size: 540 B |