polybar scripts relocation

This commit is contained in:
Harri Lahtinen 2020-04-07 15:40:54 +03:00
parent e87850317a
commit 3ee447043d
6 changed files with 123 additions and 98 deletions

View File

@ -1,60 +0,0 @@
#!/bin/sh
bluetooth_print() {
bluetoothctl | while read -r; do
if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then
printf '#1'
devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
counter=0
echo "$devices_paired" | while read -r line; do
device_info=$(bluetoothctl info "$line")
if echo "$device_info" | grep -q "Connected: yes"; then
device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-)
if [ $counter -gt 0 ]; then
printf ", %s" "$device_alias"
else
printf " %s" "$device_alias"
fi
counter=$((counter + 1))
fi
printf '\n'
done
else
echo "#2"
fi
done
}
bluetooth_toggle() {
if bluetoothctl show | grep -q "Powered: no"; then
bluetoothctl power on >> /dev/null
sleep 1
devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
bluetoothctl connect "$line" >> /dev/null
done
else
devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
bluetoothctl disconnect "$line" >> /dev/null
done
bluetoothctl power off >> /dev/null
fi
}
case "$1" in
--toggle)
bluetooth_toggle
;;
*)
bluetooth_print
;;
esac

View File

@ -1,19 +0,0 @@
#!/bin/sh
STATUS=$(expressvpn status | cut -d " " -f 1)
IP=$(ip route get 8.8.8.8 | head -1 | awk '{print $7}')
SSID=$(nmcli -f SSID | head -1 | cut -d " " -f 4)
if [ "$STATUS" != "Not" ]; then
echo "${IP} "
elif [ "$SSID" = "ASUS_5G" ] || [ "$SSID" = "ASUS" ]; then
echo "${IP} "
elif [ "$SSID" = "OP3T" ] || [ "$SSID" = "Samsung" ]; then
echo "${IP} "
elif [ "$SSID" != "ASUS_5G" ] || [ "$SSID" != "ASUS" ] || [ "$SSID" != "OP3T" ] || [ "$SSID" != "Samsung" ] ; then
echo "${IP} "
fi

View File

@ -118,16 +118,16 @@ content-background = #00000000
[module/bluetoothctl]
type = custom/script
exec = ~/.config/Scripts/bluetoothctl.sh
exec = ~/.config/polybar/scripts/bluetoothctl.sh
tail = true
click-left = ~/.config/Scripts/bluetoothctl.sh --toggle
click-left = ~/.config/polybar/scripts/bluetoothctl.sh --toggle
label = " %output% "
label-foreground = ${colors.color0}
label-background = ${colors.color6}
[module/expressvpn-status]
type = custom/script
exec = ~/.config/Scripts/expressvpn-status.sh
exec = ~/.config/polybar/scripts/expressvpn-status.sh
interval = 5
;format-foreground = #E5E9F0
;format-backgound = #5E81AC
@ -139,11 +139,11 @@ label-background = ${colors.color3}
type = custom/script
tail = true
label = " %output% "
exec = ~/.config/Scripts/pavolume.sh --listen
exec = ~/.config/polybar/scripts/pavolume.sh --listen
click-right = exec pavucontrol
click-left = ~/.config/Scripts/pavolume.sh --togmute
scroll-up = ~/.config/Scripts/pavolume.sh --up
scroll-down = ~/.config/Scripts/pavolume.sh --down
click-left = ~/.config/polybar/scripts/pavolume.sh --togmute
scroll-up = ~/.config/polybar/scripts/pavolume.sh --up
scroll-down = ~/.config/polybar/scripts/pavolume.sh --down
format-foreground = ${colors.color0}
format-background = ${colors.color6}
@ -164,10 +164,10 @@ label-unmounted-foreground = ${colors.foreground-alt}
[module/redshift]
type = custom/script
format-prefix = " "
exec = source ~/.config/Scripts/redshift/env.sh && ~/.config/Scripts/redshift/redshift.sh temperature
click-left = source ~/.config/Scripts/redshift/env.sh && ~/.config/Scripts/redshift/redshift.sh toggle
scroll-up = source ~/.config/Scripts/redshift/env.sh && ~/.config/Scripts/redshift/redshift.sh increase
scroll-down = source ~/.config/Scripts/redshift/env.sh && ~/.config/Scripts/redshift/redshift.sh decrease
exec = source ~/.config/polybar/scripts/redshift/env.sh && ~/.config/polybar/scripts/redshift/redshift.sh temperature
click-left = source ~/.config/polybar/scripts/redshift/env.sh && ~/.config/polybar/scripts/redshift/redshift.sh toggle
scroll-up = source ~/.config/polybar/scripts/redshift/env.sh && ~/.config/polybar/scripts/redshift/redshift.sh increase
scroll-down = source ~/.config/polybar/scripts/redshift/env.sh && ~/.config/polybar/scripts/redshift/redshift.sh decrease
interval=0.5
format-foreground = ${colors.color0}
format-background = ${colors.color6}
@ -175,7 +175,7 @@ format-background = ${colors.color6}
[module/backlight]
type = custom/script
interval = 0.2
exec = ~/.config/Scripts/backlight.sh
exec = ~/.config/polybar/scripts/backlight.sh
scroll-up = exec light -A 5
scroll-down = exec light -U 5
format-prefix = "  "
@ -187,9 +187,9 @@ label-background = ${colors.color3}
[module/popup-calendar]
type = custom/script
exec = ~/.config/Scripts/popup-calendar.sh
exec = ~/.config/polybar/scripts/popup-calendar.sh
interval = 5
click-left = ~/.config/Scripts/popup-calendar.sh --popup
click-left = ~/.config/polybar/scripts/popup-calendar.sh --popup
format-prefix = "  "
format-prefix-foreground = ${colors.color0}
format-prefix-background = ${colors.color15}
@ -242,7 +242,7 @@ ramp-foreground = ${colors.foreground}
[module/pkg]
type = custom/script
exec = "~/.config/Scripts/arch-updates.sh -s"
exec = "~/.config/polybar/scripts/arch/arch-updates.sh -s"
tail = true
format = "<label> "
format-prefix = "  "
@ -250,15 +250,15 @@ format-prefix-foreground = ${colors.color0}
format-foreground = ${colors.color0}
format-background = ${colors.color9}
click-left = st -e yay --noconfirm -Syu
click-right = "~/.config/Scripts/arch-updates.sh -c&"
click-middle = "~/.config/Scripts/arch-updates.sh -n"
click-right = "~/.config/polybar/scripts/arch/arch-updates.sh -c&"
click-middle = "~/.config/polybar/scripts/arch/arch-updates.sh -n"
[module/openweather]
type = custom/script
exec = ~/.config/Scripts/openweather.sh
exec = ~/.config/polybar/scripts/openweather.sh
tail = true
interval = 600
click-left = ~/.config/Scripts/wttr.sh
click-left = ~/.config/polybar/scripts/wttr.sh
format = <label>
format-foreground = ${colors.color0}
format-background = ${colors.color5}

View File

@ -0,0 +1,54 @@
#!/usr/bin/env bash
path=${HOME}/.config/polybar/scripts/arch
#trap 'exit' SIGINT
function main_loop {
while true; do
echo '' > ~/.config/polybar/scripts/arch/status
check_for_updates
sleep 600
done
}
function status {
echo $$ > ${path}polybar_updates.pid
while true; do
cat ~/.config/polybar/scripts/arch/status
sleep 1
done
}
function check_for_updates {
checkupdates | nl -w2 -s '. ' >| ${path}repo.pkgs
yay -Qu --aur | nl -w2 -s '. ' >| ${path}aur.pkgs
updates=$(cat ${path}*.pkgs | wc -l)
echo "0" >| ${path}status
[ $updates -gt 0 ] && echo "%{F#e60053}$updates" >| ${path}status
>| ${path}packages
[ -s ${path}repo.pkgs ] && cat ${path}repo.pkgs >> ${path}packages
[ -s ${path}repo.pkgs ] && [ -s ${path}aur.pkgs ] && printf "\n" >> ${path}packages
[ -s ${path}aur.pkgs ] && sed '1iAUR Updates' ${path}aur.pkgs >> ${path}packages
}
function notify {
if [[ $(cat ~/.config/polybar/scripts/arch/status) -eq 0 ]]
then
twmnc "Updates 0"
else
twmnc Updates "$(cat ~/.config/polybar/scripts/arch/packages)"
fi
}
function upgrade {
kitty -e yay --noconfirm -Syu
echo "0" > ~/.config/polybar/scripts/arch/status
}
[[ $# -eq 0 ]] && main_loop
[[ $1 == "-s" ]] && status
[[ $1 == "-c" ]] && echo '' > ~/.config/polybar/scripts/arch/status && check_for_updates
[[ $1 == "-n" ]] && notify

View File

@ -0,0 +1,2 @@
export REDSHIFT=off
export REDSHIFT_TEMP=3500

View File

@ -0,0 +1,48 @@
#!/bin/sh
envFile=~/.config/polybar/scripts/env.sh
changeValue=300
changeMode() {
sed -i "s/REDSHIFT=$1/REDSHIFT=$2/g" $envFile
REDSHIFT=$2
echo $REDSHIFT
}
changeTemp() {
if [ "$2" -gt 1000 ] && [ "$2" -lt 25000 ]
then
sed -i "s/REDSHIFT_TEMP=$1/REDSHIFT_TEMP=$2/g" $envFile
redshift -x
redshift -O $((REDSHIFT_TEMP+changeValue))
fi
}
case $1 in
toggle)
if [ "$REDSHIFT" = on ];
then
changeMode "$REDSHIFT" off
redshift -x
else
changeMode "$REDSHIFT" on
redshift -O "$REDSHIFT_TEMP"
fi
;;
increase)
changeTemp $((REDSHIFT_TEMP)) $((REDSHIFT_TEMP+changeValue))
;;
decrease)
changeTemp $((REDSHIFT_TEMP)) $((REDSHIFT_TEMP-changeValue));
;;
temperature)
case $REDSHIFT in
on)
printf "%dK" "$REDSHIFT_TEMP"
;;
off)
printf "off"
;;
esac
;;
esac