Fix issue with update checker script and minor other fixes

This commit is contained in:
natemaia 2018-07-19 18:52:19 -07:00
parent 4b6cab805c
commit b363ef013a
6 changed files with 40 additions and 51 deletions

View File

@ -24,7 +24,7 @@ setup_keyring() {
sudo pacman-key --populate archlabs sudo pacman-key --populate archlabs
} }
while ! (ping -c 1 archlabslinux.com &>/dev/null || ping -c 1 bitbucket.org &>/dev/null || ping -c 1 github.com &>/dev/null); do while ! (ping -c 1 archlabslinux.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 google.com) &>/dev/null; do
sleep 1 sleep 1
done done

View File

@ -354,7 +354,7 @@ menu-3-3-exec = systemctl -i poweroff
type = custom/script type = custom/script
tail = true tail = true
label = %output% label = %output%
click-left = toggle.sh -c -tg & click-left = toggle.sh -c -t &
exec = toggle.sh -c exec = toggle.sh -c
format = <label> format = <label>
@ -393,7 +393,7 @@ type = custom/script
tail = true tail = true
exec = toggle.sh -r exec = toggle.sh -r
label = %output% label = %output%
click-left = toggle.sh -r -tg & click-left = toggle.sh -r -t &
;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;

View File

@ -6,14 +6,10 @@ disconnected2="\\"
wireless_connected="" wireless_connected=""
ethernet_connected="" ethernet_connected=""
ID="$(ip link | awk '/state UP/ {print $2}')"
while true; do while true; do
if (ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then if (ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then
# avoid checking what type of interface it is every loop
if (( count < 1 )); then
ID="$(ip link | awk '/state UP/ {print $2}')"
((count++))
fi
if [[ $ID == e* ]]; then if [[ $ID == e* ]]; then
echo "$ethernet_connected" ; sleep 25 echo "$ethernet_connected" ; sleep 25
else else

View File

@ -26,7 +26,6 @@ usage() {
-l,--logout Session logout dialog -l,--logout Session logout dialog
Without any options -r,--run will be opened. Without any options -r,--run will be opened.
EOF EOF

View File

@ -1,30 +1,30 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Name=$(basename "$0") NAME=$(basename "$0")
Version="0.3" VER="0.3"
_usage() { usage() {
cat <<EOF cat <<EOF
USAGE: USAGE: $NAME [OPTIONS [ADDITIONAL]]
$Name [OPTIONS [ADDITIONAL]]
OPTIONS: OPTIONS:
-h,--help Display this message
-v,--version Display script version -h,--help Display this message
-p,--polybar Toggle the configured polybar session, NO additional options -v,--version Display script version
-c,--compton Toggle compton or daemon monitoring icon, can use toggle option -p,--polybar Toggle the configured polybar session, NO additional options
-r,--redshift Toggle redshift or daemon monitoring icon, can use toggle option -c,--compton Toggle compton or daemon monitoring icon, can use toggle option
-f,--caffeine Toggle caffeine or daemon monitoring icon, can use toggle option -r,--redshift Toggle redshift or daemon monitoring icon, can use toggle option
-f,--caffeine Toggle caffeine or daemon monitoring icon, can use toggle option
ADDITIONAL: ADDITIONAL:
-tg,--toggle Toggle the program off/on, without this flag a monitor process will be started -t,--toggle Toggle the program off/on, without this flag a monitor process will be started
EOF EOF
} }
@ -112,38 +112,29 @@ toggle_caffeine() {
# Catch command line options # Catch command line options
case $1 in case $1 in
-h|--help)
usage
;;
-v|--version)
echo -e "$NAME -- Version $VER"
;;
-p|--polybar) -p|--polybar)
toggle_polybar toggle_polybar
;; ;;
-c|--compton) -c|--compton)
case $2 in [[ $2 =~ (-t|--toggle) ]] && opt=1
-tg|--toggle)
opt=1
esac
toggle_compton toggle_compton
;; ;;
-r|--redshift) -r|--redshift)
case $2 in [[ $2 =~ (-t|--toggle) ]] && opt=1
-tg|--toggle)
opt=1
esac
toggle_redshift toggle_redshift
;; ;;
-f|--caffeine) -f|--caffeine)
case $2 in [[ $2 =~ (-t|--toggle) ]] && opt=1
-tg|--toggle)
opt=1
esac
toggle_caffeine toggle_caffeine
;; ;;
-h|--help)
_usage
;;
-v|--version)
echo -e "$Name -- Version $Version"
;;
*) *)
echo -e "Option does not exist: $1" && _usage && exit 1 echo -e "Option does not exist: $1" && usage && exit 1
esac esac
exit 0 exit 0

View File

@ -8,24 +8,27 @@ get_total_updates() { UPDATES=$(checkupdates 2>/dev/null | wc -l); }
while true; do while true; do
get_total_updates get_total_updates
# notify user with varying levels of urgency depending on amount of updates # notify user of updates
if hash notify-send &>/dev/null; then if hash notify-send &>/dev/null; then
if (( UPDATES > 50 )); then if (( UPDATES > 50 )); then
notify-send -u critical -i $NOTIFY_ICON "You really need to update!!" "$UPD New packages" notify-send -u critical -i $NOTIFY_ICON \
"You really need to update!!" "$UPDATES New packages"
elif (( UPDATES > 25 )); then elif (( UPDATES > 25 )); then
notify-send -u normal -i $NOTIFY_ICON "You should update soon" "$UPD New packages" notify-send -u normal -i $NOTIFY_ICON \
"You should update soon" "$UPDATES New packages"
elif (( UPDATES > 2 )); then elif (( UPDATES > 2 )); then
notify-send -u low -i $NOTIFY_ICON "$UPD New packages" notify-send -u low -i $NOTIFY_ICON \
"$UPDATES New packages"
fi fi
fi fi
# loop while updates are greater than zero # when there are updates available
# during which every 10 seconds another check for fresh updates is done # every 10 seconds another check for updates is done
while (( UPDATES > 0 )); do while (( UPDATES > 0 )); do
if (( UPDATES == 1 )); then if (( UPDATES == 1 )); then
echo "$UPD Update" echo "$UPDATES Update"
elif (( UPDATES > 1 )); then elif (( UPDATES > 1 )); then
echo "$UPD Updates" echo "$UPDATES Updates"
else else
echo $BAR_ICON echo $BAR_ICON
fi fi
@ -33,8 +36,8 @@ while true; do
get_total_updates get_total_updates
done done
# when no updates are available we go into a much longer loop to save cpu time # when no updates are available, use a longer loop, this saves on CPU
# and only check once every 30 min for new updates # and network uptime, only checking once every 30 min for new updates
while (( UPDATES == 0 )); do while (( UPDATES == 0 )); do
echo $BAR_ICON echo $BAR_ICON
sleep 1800 sleep 1800