Improve few polybar scripts

This commit is contained in:
Thomas Dehaeze 2020-04-03 11:34:21 +02:00
parent 4359a365f6
commit 354ab6e8b0

View File

@ -359,7 +359,7 @@
click-right = ~/.config/polybar/scripts/mail-refresh.sh click-right = ~/.config/polybar/scripts/mail-refresh.sh
format = <label> format = <label>
exec = ~/.config/polybar/scripts/mail-status.sh exec = ~/.config/polybar/scripts/mail-status.sh
interval = 1 interval = 2
#+END_SRC #+END_SRC
** Unread Mail Scripts ** Unread Mail Scripts
@ -410,7 +410,7 @@
format-underline = ${colors.bg} format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/news-open.sh click-left = ~/.config/polybar/scripts/news-open.sh
click-right = ~/.config/polybar/scripts/news-refresh.sh click-right = ~/.config/polybar/scripts/news-refresh.sh &
format = <label> format = <label>
exec = ~/.config/polybar/scripts/news-status.sh exec = ~/.config/polybar/scripts/news-status.sh
interval = 60 interval = 60
@ -439,11 +439,15 @@
:header-args+: :shebang "#!/usr/bin/env bash" :header-args+: :shebang "#!/usr/bin/env bash"
:END: :END:
#+begin_src bash #+begin_src bash
if pgrep -x "newsboat" >/dev/null; then
dunstify --replace=38492 "Newsboat " "Already running";
else
dunstify --replace=38492 "Newsboat " "Reloading..."; dunstify --replace=38492 "Newsboat " "Reloading...";
newsboat -x reload && / newsboat -x reload && /
news_nb=`newsboat -x print-unread | cut -d " " -f1` && \ news_nb=`newsboat -x print-unread | cut -d " " -f1` && \
dunstify --replace=38492 "Newsboat " "$news_nb Unread News"; dunstify --replace=38492 "Newsboat " "$news_nb Unread News";
fi
#+end_src #+end_src
** Open Newsboat ** Open Newsboat
@ -468,7 +472,7 @@
interval = 2 interval = 2
#+END_SRC #+END_SRC
** Redshift Scripts ** Redshift - Status
:PROPERTIES: :PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/redshift-status.sh :header-args: :tangle ~/.config/polybar/scripts/redshift-status.sh
:header-args+: :comments both :mkdirp yes :header-args+: :comments both :mkdirp yes
@ -490,9 +494,11 @@
:END: :END:
#+begin_src bash #+begin_src bash
if pgrep -x "redshift" >/dev/null; then if pgrep -x "redshift" >/dev/null; then
killall redshift; killall redshift && \
dunstify --replace=36492 "Redshift 望" "Turned off";
else else
nohup redshift > /dev/null 2>&1 & nohup redshift > /dev/null 2>&1 &
dunstify --replace=36492 "Redshift 望" "Starting...";
fi fi
#+end_src #+end_src
@ -535,11 +541,15 @@
tmpfile="/tmp/vpnstatus"; tmpfile="/tmp/vpnstatus";
if [ -f $tmpfile ] && grep -q "on" $tmpfile; then if [ -f $tmpfile ] && grep -q "on" $tmpfile; then
nordvpn disconnect && dunstify --replace=23198 "VPN" "Disconnected" && echo "off" > $tmpfile; nordvpn disconnect && \
dunstify --replace=23198 "VPN" "Disconnected" && \
echo "off" > $tmpfile;
else else
country=`cat ~/bin/nordvpn_countries.txt | sed 's/\s*\t\s*/ /g ; s/\s/\n/g ; s/_/ /g ; /^[a-zA-Z]/!d ; s/\(.*\)/\L\1/' | rofi -i -dmenu | sed 's/\s/_/g'`; country=`cat ~/bin/nordvpn_countries.txt | sed 's/\s*\t\s*/ /g ; s/\s/\n/g ; s/_/ /g ; /^[a-zA-Z]/!d ; s/\(.*\)/\L\1/' | rofi -i -dmenu | sed 's/\s/_/g'`;
dunstify --replace=23198 "VPN" "Connecting to $country..."; dunstify --replace=23198 "VPN" "Connecting to $country...";
nordvpn connect $country && dunstify --replace=23198 "VPN" "Connected to $country" && echo "on" > $tmpfile; nordvpn connect $country && \
dunstify --replace=23198 "VPN" "Connected to $country" && \
echo "on" > $tmpfile;
fi fi
#+END_SRC #+END_SRC
@ -581,6 +591,7 @@
:END: :END:
#+BEGIN_SRC bash #+BEGIN_SRC bash
dunstify --replace=64654 'Packages ' "Refreshing..." dunstify --replace=64654 'Packages ' "Refreshing..."
yay -Sy > /dev/null 2>&1 && \ yay -Sy > /dev/null 2>&1 && \
package_nb=`yay -Qu 2> /dev/null | wc -l`; package_nb=`yay -Qu 2> /dev/null | wc -l`;
@ -642,15 +653,15 @@
#+BEGIN_SRC bash #+BEGIN_SRC bash
tmpfile="/tmp/dunststatus"; tmpfile="/tmp/dunststatus";
if [ -f $tmpfile ]; then if [ -f $tmpfile ] && grep -q "off" $tmpfile ; then
if grep -q "on" $tmpfile; then killall -SIGUSR2 dunst && \
killall -SIGUSR1 dunst && echo "off" > $tmpfile; echo "on" > $tmpfile;
elif grep -q "off" $tmpfile; then dunstify --replace=16549 "Notifications " "Activated";
killall -SIGUSR2 dunst && echo "on" > $tmpfile;
dunstify --replace=16549 "Dunst" "Activated";
fi
else else
killall -SIGUSR1 dunst && echo "off" > $tmpfile; dunstify --replace=16549 "Notifications " "Deactivated";
sleep 1 && \
killall -SIGUSR1 dunst && \
echo "off" > $tmpfile;
fi fi
#+END_SRC #+END_SRC
@ -691,13 +702,12 @@
:END: :END:
#+begin_src bash #+begin_src bash
if pgrep -x "xautolock" >/dev/null if pgrep -x "xautolock" >/dev/null ; then
then pkill xautolock && \
pkill xautolock; dunstify --replace=13602 'Lock Screen ' 'Desactivated'
dunstify --replace=13602 'Lock Screen' 'Desactivated'
else else
xautolock -locker "~/scripts/lockscreen.sh" -detectsleep -time 30 -notify 60 -notifier "dunstify --replace=31846 -u critical -t 10000 -- 'Locking Screen' '60 seconds'" & xautolock -locker "~/scripts/lockscreen.sh" -detectsleep -time 30 -notify 60 -notifier "dunstify --replace=31846 -u critical -t 10000 -- 'Locking Screen' '60 seconds'" &
dunstify --replace=13602 'Lock Screen' 'Activated' dunstify --replace=13602 'Lock Screen' 'Activated'
fi fi
#+end_src #+end_src
@ -779,9 +789,11 @@
connection=$(sudo wg show "$config" 2>/dev/null | head -n 1 | awk '{print $NF }') connection=$(sudo wg show "$config" 2>/dev/null | head -n 1 | awk '{print $NF }')
if [ "$connection" = "$config" ]; then if [ "$connection" = "$config" ]; then
sudo wg-quick down "$config" && dunstify --replace=83244 "Wireguard" "Disconnected from $config" sudo wg-quick down "$config" && \
dunstify --replace=83244 "Wireguard" "Disconnected from $config"
else else
sudo wg-quick up "$config" && dunstify --replace=83244 "Wireguard" "Connected to $config" sudo wg-quick up "$config" && \
dunstify --replace=83244 "Wireguard" "Connected to $config"
fi fi
#+end_src #+end_src