Move polybar scripts into polybar package

This commit is contained in:
natemaia 2018-12-14 15:53:11 -08:00
parent a9c34d0956
commit ad0db3c96d
5 changed files with 19 additions and 232 deletions

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
disconnect1="/"
disconnect2="\\"
wconnected=""
econnected=""
id="$(ip link | awk '/state UP/ {print $2}')"
while true; do
if ping -c 1 archlabslinux.com >/dev/null 2>&1 || ping -c 1 archlinux.org >/dev/null 2>&1; then
[[ $id == e* ]] && echo "$econnected" || echo "$wconnected"
sleep 25
else
echo "$disconnect1" # /
sleep 0.6
echo "$disconnect2" # \
sleep 0.6
fi
done

View File

@ -1,26 +0,0 @@
#!/usr/bin/env bash
TRASH_DIRECTORY="$BLOCK_INSTANCE"
if [[ $TRASH_DIRECTORY = "" ]]; then
TRASH_DIRECTORY="${XDG_DATA_HOME:-$HOME/.local/share}/Trash"
fi
if [[ $BLOCK_BUTTON -eq 1 ]]; then
xdg-open "$TRASH_DIRECTORY/files"
elif [[ $BLOCK_BUTTON -eq 3 ]]; then
rm -r "$TRASH_DIRECTORY/files"
rm -r "$TRASH_DIRECTORY/info"
mkdir "$TRASH_DIRECTORY/files"
mkdir "$TRASH_DIRECTORY/info"
fi
TRASH_COUNT=$(ls -U -1 "$TRASH_DIRECTORY/files" | wc -l)
URGENT_VALUE=30
echo "$TRASH_COUNT"
echo "$TRASH_COUNT"
echo ""
if [[ $TRASH_COUNT -ge $URGENT_VALUE ]]; then
exit 31
fi

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
NAME=$(basename "$0")
VER="0.4"
VER="0.5"
usage()
{
@ -15,18 +15,18 @@ usage()
-v,--version Display script version
-w,--window Switch between open windows
-r,--run Application launcher
-r,--run Program launcher & run dialog
-w,--window Switch between windows
-l,--logout System logout dialog
-b,--browser Browser search by keyword (requires surfraw)
-q,--qalculate Persistant calculator dialog (requires libqalculate)
-c,--clipboard Select previous clipboard entries (requires greenclip)
-b,--browser Browser search by keyword (requires surfraw)
-l,--logout Session logout dialog
Without any options the run dialog will be opened.
@ -74,21 +74,25 @@ for arg in "$@"; do
-padding 50 -line-padding 4)"
;;
-l|--logout)
ANS="$(rofi -sep "|" -dmenu -i -p 'System' -width 20 \
-hide-scrollbar -line-padding 4 -padding 20 \
-lines 4 <<< " Lock| Logout| Reboot| Shutdown")"
if grep -q 'exec startx'; then
ANS="$(rofi -sep "|" -dmenu -i -p 'System' -width 20 \
-hide-scrollbar -line-padding 4 -padding 20 \
-lines 4 <<< " Lock| Reboot| Shutdown")"
else
ANS="$(rofi -sep "|" -dmenu -i -p 'System' -width 20 \
-hide-scrollbar -line-padding 4 -padding 20 \
-lines 4 <<< " Lock| Logout| Reboot| Shutdown")"
fi
case "$ANS" in
*Lock) i3lock-fancy ;;
*Logout) session-logout || pkill -15 -t tty"$XDG_VTNR" Xorg ;;
*Reboot) systemctl reboot ;;
*Shutdown) systemctl -i poweroff
*Shutdown) systemctl -i poweroff ;;
*Logout) session-logout || pkill -15 -t tty"$XDG_VTNR" Xorg ;;
esac
;;
*)
echo
echo "Option does not exist: $arg"
echo
printf "\nOption does not exist: %s\n\n" "$arg"
exit 2
esac
done

View File

@ -1,129 +0,0 @@
#!/usr/bin/env bash
NAME=$(basename "$0")
VER="0.4"
usage()
{
cat <<- EOF
USAGE: $NAME [OPTIONS [ADDITIONAL]]
OPTIONS:
-h,--help Display this message
-v,--version Display script version
-p,--polybar Toggle the configured polybar session, NO additional options
-c,--compton Toggle compton 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:
-t,--toggle Toggle the program off/on, without this flag a monitor process will be started
EOF
}
toggle_polybar()
{
if [[ $(pidof polybar) ]]; then
pkill polybar
else
al-polybar-session
fi
}
toggle_compton()
{
if (( opt == 1 )); then
if [[ $(pidof compton) ]]; then
al-compositor --stop
else
al-compositor --start
fi
exit 0
fi
on=""
off=""
while true; do
if [[ $(pidof compton) ]]; then
echo "$on"
else
echo "%{F#888888}$off"
fi
sleep 2
done
}
toggle_redshift()
{
if (( opt == 1 )); then
if [[ $(pidof redshift) ]]; then
pkill redshift
else
redshift &
fi
exit 0
fi
icon=""
while true; do
if [[ $(pidof redshift) ]]; then
temp=$(sed 's/K//g' <<< "$(grep -o '[0-9].*K' <<< "$(redshift -p 2>/dev/null)")")
fi
if [[ -z $temp ]]; then
echo " $icon " # Greyed out (not running)
elif [[ $temp -ge 5000 ]]; then
echo "%{F#8039A0} $icon " # Blue
elif [[ $temp -ge 4000 ]]; then
echo "%{F#F203F0} $icon " # Yellow
else
echo "%{F#FF5B6C} $icon " # Orange
fi
sleep 2
done
}
toggle_caffeine()
{
if (( opt == 1 )); then
if [[ $(pidof caffeine) ]]; then
killall caffeine
else
caffeine &
fi
exit 0
fi
on=""
off=""
while true; do
[[ $(pidof caffeine) ]] && echo "%{F#0000FF}$on" || echo "%{F#FF0000}$off"
sleep 2
done
}
# Catch command line options
case $1 in
-h|--help) usage ;;
-v|--version) echo -e "$NAME -- Version $VER" ;;
-p|--polybar) toggle_polybar ;;
-c|--compton)
[[ $2 =~ (-t|--toggle) ]] && opt=1
toggle_compton
;;
-r|--redshift)
[[ $2 =~ (-t|--toggle) ]] && opt=1
toggle_redshift
;;
-f|--caffeine)
[[ $2 =~ (-t|--toggle) ]] && opt=1
toggle_caffeine
;;
*) echo -e "Option does not exist: $1" && usage && exit 1
esac

View File

@ -1,42 +0,0 @@
#!/usr/bin/env bash
BAR_ICON=""
NOTIFY_ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
get_total_updates()
{
UPDATES=$(checkupdates 2>/dev/null | wc -l)
}
while true; do
# print the icon first to avoid gibberish in polybar
echo $BAR_ICON
get_total_updates
# notify user of updates
if hash notify-send >/dev/null 2>&1; then
if (( UPDATES > 50 )); then
notify-send -u critical -i $NOTIFY_ICON "Updates Available" "$UPDATES packages"
elif (( UPDATES > 25 )); then
notify-send -u normal -i $NOTIFY_ICON "Updates Available" "$UPDATES packages"
elif (( UPDATES > 2 )); then
notify-send -u low -i $NOTIFY_ICON "Updates Available" "$UPDATES packages"
fi
fi
# when there are updates available
# every 10 seconds another check for updates is done
while (( UPDATES > 0 )); do
(( UPDATES == 1 )) && echo "$UPDATES Update" || { (( UPDATES > 1 )) && echo "$UPDATES Updates"; }
sleep 10
get_total_updates
done
# when no updates are available, use a longer loop, this saves on CPU
# and network uptime, only checking once every 30 min for new updates
while (( UPDATES == 0 )); do
sleep 1800
get_total_updates
done
done