-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 43caa80
Showing
10 changed files
with
946 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
| shell scripts | comment | | ||
| :-------------------- | :-------------------------------------------------------------------------------------- | | ||
| polybar.sh | start polybar | | ||
| polybar_bluetooth.sh | enable/disable bluetooth, show bluetooth status for polybar | | ||
| polybar_firewall.sh | enable/disable firewall and show firewall status for polybar | | ||
| polybar_gestures.sh | enable/disable gestures and show gestures status for polybar | | ||
| polybar_polkit.sh | enable/disable gnome authentication agent and show agent status for polybar | | ||
| polybar_printer.sh | enable/disable printer and show printer status for polybar | | ||
| polybar_rss.sh | shows the quantity of new articles in newsboat for polybar | | ||
| polybar_vpn_hades.sh | enable/disable vpn and show vpn status for polybar | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:37:12+0100 | ||
|
||
pri=$(polybar -m | grep "(primary)" | sed -e 's/:.*$//g') | ||
sec=$(polybar -m | grep -v "(primary)" | sed -e 's/:.*$//g') | ||
|
||
# toggle the bars | ||
if [ -n "$1" ]; then | ||
bar_pri="$1" | ||
elif [ "$(pgrep -xf "polybar i3_sec")" ] \ | ||
|| [ "$(pgrep -xf "polybar i3_pri_btm")" ] \ | ||
|| [ "$(pgrep -xf "polybar i3_sec_top")" ]; then | ||
bar_pri="i3_pri" | ||
elif [ "$(pgrep -xf "polybar i3_pri")" ]; then | ||
bar_sec="i3_sec" | ||
bar_pri_btm="i3_pri_btm" | ||
bar_sec_top="i3_sec_top" | ||
else | ||
if [ "$(polybar -m | wc -l)" = 2 ]; then | ||
bar_sec="i3_sec" | ||
bar_pri_btm="i3_pri_btm" | ||
bar_sec_top="i3_sec_top" | ||
else | ||
bar_pri="i3_pri" | ||
fi | ||
fi | ||
|
||
# terminate already running bar instances | ||
killall -q polybar | ||
|
||
# wait until the processes have been shut down | ||
while pgrep -x polybar >/dev/null; do sleep 0.1; done | ||
|
||
# launch polybar and write errorlog to tmp | ||
if [ -z $bar_sec ]; then | ||
echo "---" | tee -a /tmp/polybar_$bar_pri.log | ||
MONITOR=$pri polybar $bar_pri >>/tmp/polybar_$bar_pri.log 2>&1 & | ||
else | ||
if [ "$(polybar -m | wc -l)" = 2 ]; then | ||
echo "---" | tee -a /tmp/polybar_$bar_sec.log /tmp/polybar_$bar_sec_top.log | ||
MONITOR=$pri polybar $bar_sec >>/tmp/polybar_$bar_sec.log 2>&1 & | ||
MONITOR=$sec polybar $bar_sec_top >>/tmp/polybar_$bar_sec_top.log 2>&1 & | ||
else | ||
echo "---" | tee -a /tmp/polybar_$bar_sec.log /tmp/polybar_$bar_pri_btm.log | ||
MONITOR=$pri polybar $bar_sec >>/tmp/polybar_$bar_sec.log 2>&1 & | ||
MONITOR=$pri polybar $bar_pri_btm >>/tmp/polybar_$bar_pri_btm.log 2>&1 & | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar_bluetooth.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:37:36+0100 | ||
|
||
grey=$(xrdb -query | grep Polybar.foreground1: | cut -f2) | ||
red=$(xrdb -query | grep color9: | cut -f2) | ||
|
||
case "$1" in | ||
--status) | ||
if [ "$(systemctl is-active bluetooth.service)" = "active" ] | ||
then | ||
echo "%{o$red}%{o-}" | ||
else | ||
echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
*) | ||
if [ "$(systemctl is-active bluetooth.service)" != "active" ] | ||
then | ||
sudo -A systemctl start bluetooth.service \ | ||
&& sudo -A systemctl start bluetooth.target \ | ||
&& sudo -A systemctl start ModemManager.service \ | ||
&& echo "%{o$red}%{o-}" | ||
else | ||
sudo -A systemctl stop bluetooth.service \ | ||
&& sudo -A systemctl stop bluetooth.target \ | ||
&& sudo -A systemctl stop ModemManager.service \ | ||
&& echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar_firewall.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:37:54+0100 | ||
|
||
grey=$(xrdb -query | grep Polybar.foreground1: | cut -f2) | ||
red=$(xrdb -query | grep color9: | cut -f2) | ||
|
||
case "$1" in | ||
--status) | ||
if [ "$(systemctl is-active ufw.service)" = "active" ] | ||
then | ||
echo "%{o$red}%{o-}" | ||
else | ||
echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
*) | ||
if [ "$(systemctl is-active ufw.service)" != "active" ] | ||
then | ||
sudo -A systemctl start ufw.service \ | ||
&& echo "%{o$red}%{o-}" | ||
else | ||
sudo -A systemctl stop ufw.service \ | ||
&& echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar_gestures.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:38:12+0100 | ||
|
||
grey=$(xrdb -query | grep Polybar.foreground1: | cut -f2) | ||
red=$(xrdb -query | grep color9: | cut -f2) | ||
|
||
case "$1" in | ||
--status) | ||
if [ "$(pgrep -f /usr/bin/libinput-gestures)" ] | ||
then | ||
echo "%{o$red}%{o-}" | ||
else | ||
echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
*) | ||
if [ "$(pgrep -f /usr/bin/libinput-gestures)" ] | ||
then | ||
libinput-gestures-setup stop \ | ||
&& echo "%{o$grey}%{o-}" | ||
else | ||
libinput-gestures-setup start >/dev/null 2>&1 \ | ||
&& echo "%{o$red}%{o-}" | ||
fi | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar_polkit.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:39:04+0100 | ||
|
||
grey=$(xrdb -query | grep Polybar.foreground1: | cut -f2) | ||
red=$(xrdb -query | grep color9: | cut -f2) | ||
|
||
case "$1" in | ||
--status) | ||
if [ "$(pgrep -f /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1)" ] | ||
then | ||
echo "%{o$red}%{o-}" | ||
else | ||
echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
*) | ||
if [ "$(pgrep -f /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1)" ] | ||
then | ||
killall /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 \ | ||
&& echo "%{o$grey}%{o-}" | ||
else | ||
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 >/dev/null 2>&1 \ | ||
& echo "%{o$red}%{o-}" | ||
fi | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar_printer.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:39:28+0100 | ||
|
||
grey=$(xrdb -query | grep Polybar.foreground1: | cut -f2) | ||
red=$(xrdb -query | grep color9: | cut -f2) | ||
|
||
case "$1" in | ||
--status) | ||
if [ "$(systemctl is-active org.cups.cupsd.service)" = "active" ] | ||
then | ||
echo "%{o$red}%{o-}" | ||
else | ||
echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
*) | ||
if [ "$(systemctl is-active org.cups.cupsd.service)" != "active" ] | ||
then | ||
sudo -A systemctl start org.cups.cupsd.service \ | ||
&& sudo -A systemctl start avahi-daemon.service \ | ||
&& sudo -A systemctl start avahi-daemon.socket \ | ||
&& echo "%{o$red}%{o-}" | ||
else | ||
sudo -A systemctl stop org.cups.cupsd.service \ | ||
&& sudo -A systemctl stop avahi-daemon.service \ | ||
&& sudo -A systemctl stop avahi-daemon.socket \ | ||
&& echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar_rss.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:39:50+0100 | ||
|
||
# exit if newsboat is running | ||
pgrep -x newsboat > /dev/null 2>&1 \ | ||
&& polybar-msg hook module/rss 2 > /dev/null 2>&1 \ | ||
&& exit | ||
|
||
if ping -c1 -W1 -q 1.1.1.1 > /dev/null 2>&1; then | ||
newsboat -x reload && newsboat -q -X > /dev/null 2>&1 \ | ||
&& polybar-msg hook module/rss 3 > /dev/null 2>&1 | ||
else | ||
polybar-msg hook module/rss 3 > /dev/null 2>&1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
# path: ~/projects/polybar/polybar_vpn_hades.sh | ||
# user: klassiker [mrdotx] | ||
# github: https://github.com/mrdotx/polybar | ||
# date: 2020-01-23T11:40:23+0100 | ||
|
||
vpn_name=hades | ||
grey=$(xrdb -query | grep Polybar.foreground1: | cut -f2) | ||
red=$(xrdb -query | grep color9: | cut -f2) | ||
|
||
case "$1" in | ||
--status) | ||
if [ "$(nmcli connection show --active $vpn_name)" ] | ||
then | ||
echo "%{o$red}%{o-}" | ||
else | ||
echo "%{o$grey}%{o-}" | ||
fi | ||
;; | ||
*) | ||
if [ "$(nmcli connection show --active $vpn_name)" ] | ||
then | ||
nmcli con down id $vpn_name \ | ||
&& echo "%{o$grey}%{o-}" | ||
else | ||
gpg -o "/tmp/$vpn_name.txt" "$HOME/cloud/webde/Keys/$vpn_name.txt.gpg" \ | ||
&& nmcli con up id $vpn_name passwd-file "/tmp/$vpn_name.txt" \ | ||
&& rm -f "/tmp/$vpn_name.txt" \ | ||
&& echo "%{o$red}%{o-}" | ||
fi | ||
;; | ||
esac |