Housekeeping

This commit is contained in:
LordMathis
2019-02-11 17:43:02 +01:00
parent 4fc2bcab0a
commit 3ee70aa4e7
14 changed files with 82 additions and 35 deletions

View File

@@ -0,0 +1,57 @@
#!/bin/sh
get_icon() {
case $1 in
01d) icon="";;
01n) icon="";;
02d) icon="";;
02n) icon="";;
03*) icon="";;
04*) icon="";;
09d) icon="";;
09n) icon="";;
10d) icon="";;
10n) icon="";;
11d) icon="";;
11n) icon="";;
13d) icon="";;
13n) icon="";;
50d) icon="";;
50n) icon="";;
*) icon="";
esac
echo $icon
}
KEY=`secret-tool lookup openweathermap api_key`
BRNO_CZ="3078610"
ZVOLEN_SK="3056459"
CITY=$BRNO_CZ
UNITS="metric"
SYMBOL="°"
if [ ! -z $CITY ]; then
weather=$(curl -sf "http://api.openweathermap.org/data/2.5/weather?APPID=$KEY&id=$CITY&units=$UNITS")
# weather=$(curl -sf "http://api.openweathermap.org/data/2.5/forecast?APPID=$KEY&id=$CITY&units=$UNITS&cnt=1")
else
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
if [ ! -z "$location" ]; then
location_lat="$(echo "$location" | jq '.location.lat')"
location_lon="$(echo "$location" | jq '.location.lng')"
weather=$(curl -sf "http://api.openweathermap.org/data/2.5/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
fi
fi
if [ ! -z "$weather" ]; then
weather_temp=$(echo "$weather" | jq ".main.temp" | cut -d "." -f 1)
weather_icon=$(echo "$weather" | jq -r ".weather[].icon")
echo "$(get_icon "$weather_icon")" "$weather_temp$SYMBOL"
fi

56
bin/polybar/pulseaudio-tail.sh Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/sh
sink=0
volume_up() {
pactl set-sink-volume $sink +1%
}
volume_down() {
pactl set-sink-volume $sink -1%
}
volume_mute() {
pactl set-sink-mute $sink toggle
}
volume_print() {
icon=""
muted=$(pamixer --sink $sink --get-mute)
if [ "$muted" = true ]; then
echo "$icon --"
else
echo "$icon $(pamixer --sink $sink --get-volume)"
fi
}
listen() {
volume_print
pactl subscribe | while read -r event; do
if echo "$event" | grep -q "#$sink"; then
volume_print
fi
done
}
case "$1" in
--up)
volume_up
;;
--down)
volume_down
;;
--mute)
volume_mute
;;
--show)
show_active
;;
*)
listen
;;
esac

88
bin/polybar/system-usb-udev.sh Executable file
View File

@@ -0,0 +1,88 @@
#!/bin/sh
usb_print() {
devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR)
output=""
counter=0
for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == "1") | select(.mountpoint == null) | .name'); do
unmounted=$(echo "$unmounted" | tr -d "[:digit:]")
unmounted=$(echo "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor')
unmounted=$(echo "$unmounted" | tr -d ' ')
if [ $counter -eq 0 ]; then
space=""
else
space=" "
fi
counter=$((counter + 1))
output="$output$space#1 $unmounted"
done
for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == "1") | select(.mountpoint != null) | .size'); do
if [ $counter -eq 0 ]; then
space=""
else
space=" "
fi
counter=$((counter + 1))
output="$output$space#2 $mounted"
done
echo "$output"
}
usb_update() {
pid=$(pgrep -xf "/bin/sh /home/matus/bin/system-usb-udev.sh")
if [ "$pid" != "" ]; then
kill -10 "$pid"
fi
}
case "$1" in
--update)
usb_update
;;
--mount)
devices=$(lsblk -Jplno NAME,TYPE,RM,MOUNTPOINT)
for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == "1") | select(.mountpoint == null) | .name'); do
# udisksctl mount --no-user-interaction -b "$mount"
# mountpoint=$(udisksctl mount --no-user-interaction -b $mount)
# mountpoint=$(echo $mountpoint | cut -d " " -f 4 | tr -d ".")
# terminal -e "bash -lc 'filemanager $mountpoint'"
mountpoint=$(udisksctl mount --no-user-interaction -b "$mount")
mountpoint=$(echo "$mountpoint" | cut -d " " -f 4 | tr -d ".")
termite -e "bash -lc 'mc $mountpoint'" &
done
usb_update
;;
--unmount)
devices=$(lsblk -Jplno NAME,TYPE,RM,MOUNTPOINT)
for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == "1") | select(.mountpoint != null) | .name'); do
udisksctl unmount --no-user-interaction -b "$unmount"
udisksctl power-off --no-user-interaction -b "$unmount"
done
usb_update
;;
*)
trap exit INT
trap "echo" USR1
while true; do
usb_print
sleep 60 &
wait
done
;;
esac

9
bin/polybar/updates.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
updates_arch=$(checkupdates | wc -l)
if [ "$updates_arch" -gt 0 ]; then
echo " $updates_arch"
else
echo ""
fi

7
bin/polybar/vpn_running.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
if [ "$(pgrep openvpn)" ]; then
echo ""
else
echo
fi