polybar-scripts
This commit is contained in:
parent
3ee447043d
commit
1f1a8dd5d4
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "$(light | cut -d. -f1)"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
#!/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
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. Aborting."; exit 1; }
|
||||
command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. Aborting."; exit 1; }
|
||||
|
||||
APIKEY="99e2d54517287c6de1e9db99db2fdc84"
|
||||
CITY_ID="659181" # customise this for your city
|
||||
URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}"
|
||||
|
||||
WEATHER_RESPONSE=$(wget -qO- "${URL}")
|
||||
|
||||
WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g')
|
||||
WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp')
|
||||
WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg')
|
||||
WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed')
|
||||
|
||||
#WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}")
|
||||
WIND_SPEED=$(awk "BEGIN {print $WIND_SPEED}")
|
||||
WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}")
|
||||
DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N )
|
||||
WIND_DIR=${DIR_ARRAY[WIND_DIR]}
|
||||
|
||||
case $WEATHER_CONDITION in
|
||||
'Clouds')
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
'Rain')
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
'Snow')
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
*)
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
esac
|
||||
|
||||
echo " ${WEATHER_ICON} ${WEATHER_CONDITION} ${WEATHER_TEMP}°C ${WIND_SPEED} m/s "
|
||||
#echo "${WEATHER_ICON} ${WEATHER_CONDITION}: ${WEATHER_TEMP}°C: ${WIND_SPEED} m/s ${WIND_DIR} "
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# finds the active sink for pulse audio and increments the volume. useful when you have multiple audio outputs and have a key bound to vol-up and down
|
||||
|
||||
osd='no'
|
||||
inc='2'
|
||||
capvol='no'
|
||||
maxvol='150'
|
||||
autosync='yes'
|
||||
|
||||
# Muted status
|
||||
# yes: muted
|
||||
# no : not muted
|
||||
curStatus="no"
|
||||
active_sink=""
|
||||
limit=$((100 - inc))
|
||||
maxlimit=$((maxvol - inc))
|
||||
|
||||
reloadSink() {
|
||||
active_sink=$(pacmd list-sinks | awk '/* index:/{print $3}')
|
||||
}
|
||||
|
||||
function volUp {
|
||||
|
||||
getCurVol
|
||||
|
||||
if [ "$capvol" = 'yes' ]
|
||||
then
|
||||
if [ "$curVol" -le 100 ] && [ "$curVol" -ge "$limit" ]
|
||||
then
|
||||
pactl set-sink-volume "$active_sink" -- 100%
|
||||
elif [ "$curVol" -lt "$limit" ]
|
||||
then
|
||||
pactl set-sink-volume "$active_sink" -- "+$inc%"
|
||||
fi
|
||||
elif [ "$curVol" -le "$maxvol" ] && [ "$curVol" -ge "$maxlimit" ]
|
||||
then
|
||||
pactl set-sink-volume "$active_sink" "$maxvol%"
|
||||
elif [ "$curVol" -lt "$maxlimit" ]
|
||||
then
|
||||
pactl set-sink-volume "$active_sink" "+$inc%"
|
||||
fi
|
||||
|
||||
getCurVol
|
||||
|
||||
if [ ${osd} = 'yes' ]
|
||||
then
|
||||
qdbus org.kde.kded /modules/kosd showVolume "$curVol" 0
|
||||
fi
|
||||
|
||||
if [ ${autosync} = 'yes' ]
|
||||
then
|
||||
volSync
|
||||
fi
|
||||
}
|
||||
|
||||
function volDown {
|
||||
|
||||
pactl set-sink-volume "$active_sink" "-$inc%"
|
||||
getCurVol
|
||||
|
||||
if [ ${osd} = 'yes' ]
|
||||
then
|
||||
qdbus org.kde.kded /modules/kosd showVolume "$curVol" 0
|
||||
fi
|
||||
|
||||
if [ ${autosync} = 'yes' ]
|
||||
then
|
||||
volSync
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function getSinkInputs {
|
||||
input_array=$(pacmd list-sink-inputs | grep -B 4 "sink: $1 " | awk '/index:/{print $2}')
|
||||
}
|
||||
|
||||
function volSync {
|
||||
getSinkInputs "$active_sink"
|
||||
getCurVol
|
||||
|
||||
for each in $input_array
|
||||
do
|
||||
pactl set-sink-input-volume "$each" "$curVol%"
|
||||
done
|
||||
}
|
||||
|
||||
function getCurVol {
|
||||
curVol=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | grep 'volume:' | grep -E -v 'base volume:' | awk -F : '{print $3}' | grep -o -P '.{0,3}%'| sed s/.$// | tr -d ' ')
|
||||
}
|
||||
|
||||
function volMute {
|
||||
case "$1" in
|
||||
mute)
|
||||
pactl set-sink-mute "$active_sink" 1
|
||||
curVol=0
|
||||
status=1
|
||||
;;
|
||||
unmute)
|
||||
pactl set-sink-mute "$active_sink" 0
|
||||
getCurVol
|
||||
status=0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ${osd} = 'yes' ]
|
||||
then
|
||||
qdbus org.kde.kded /modules/kosd showVolume ${curVol} ${status}
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function volMuteStatus {
|
||||
curStatus=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | awk '/muted/{ print $2}')
|
||||
}
|
||||
|
||||
# Prints output for bar
|
||||
# Listens for events for fast update speed
|
||||
function listen {
|
||||
firstrun=0
|
||||
|
||||
pactl subscribe 2>/dev/null | {
|
||||
while true; do
|
||||
{
|
||||
# If this is the first time just continue
|
||||
# and print the current state
|
||||
# Otherwise wait for events
|
||||
# This is to prevent the module being empty until
|
||||
# an event occurs
|
||||
if [ $firstrun -eq 0 ]
|
||||
then
|
||||
firstrun=1
|
||||
else
|
||||
read -r event || break
|
||||
if ! echo "$event" | grep -e "on card" -e "on sink"
|
||||
then
|
||||
# Avoid double events
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
} &>/dev/null
|
||||
output
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
function output() {
|
||||
reloadSink
|
||||
getCurVol
|
||||
volMuteStatus
|
||||
if [ "${curStatus}" = 'yes' ]
|
||||
then
|
||||
echo " $curVol%"
|
||||
else
|
||||
echo " $curVol%"
|
||||
fi
|
||||
} #}}}
|
||||
|
||||
reloadSink
|
||||
case "$1" in
|
||||
--up)
|
||||
volUp
|
||||
;;
|
||||
--down)
|
||||
volDown
|
||||
;;
|
||||
--togmute)
|
||||
volMuteStatus
|
||||
if [ "$curStatus" = 'yes' ]
|
||||
then
|
||||
volMute unmute
|
||||
else
|
||||
volMute mute
|
||||
fi
|
||||
;;
|
||||
--mute)
|
||||
volMute mute
|
||||
;;
|
||||
--unmute)
|
||||
volMute unmute
|
||||
;;
|
||||
--sync)
|
||||
volSync
|
||||
;;
|
||||
--listen)
|
||||
# Listen for changes and immediately create new output for the bar
|
||||
# This is faster than having the script on an interval
|
||||
listen
|
||||
;;
|
||||
*)
|
||||
# By default print output for bar
|
||||
output
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
BAR_HEIGHT=30 # polybar height
|
||||
BORDER_SIZE=1 # border size from your wm settings
|
||||
YAD_WIDTH=222 # 222 is minimum possible value
|
||||
YAD_HEIGHT=193 # 193 is minimum possible value
|
||||
DATE="$(date +"%d-%m-%y %H:%M")"
|
||||
|
||||
case "$1" in
|
||||
--popup)
|
||||
if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
eval "$(xdotool getmouselocation --shell)"
|
||||
eval "$(xdotool getdisplaygeometry --shell)"
|
||||
|
||||
# X
|
||||
if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side
|
||||
: $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE))
|
||||
elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side
|
||||
: $((pos_x = BORDER_SIZE))
|
||||
else #Center
|
||||
: $((pos_x = X - YAD_WIDTH / 2))
|
||||
fi
|
||||
|
||||
# Y
|
||||
if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom
|
||||
: $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE))
|
||||
else #Top
|
||||
: $((pos_y = BAR_HEIGHT + BORDER_SIZE))
|
||||
fi
|
||||
|
||||
yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
|
||||
--width=$YAD_WIDTH --height=$YAD_HEIGHT --posx=$pos_x --posy=$pos_y \
|
||||
--title="yad-calendar" --borders=0 >/dev/null &
|
||||
;;
|
||||
*)
|
||||
echo "$DATE"
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
rm ~/Hameenlinna_0qp.png
|
||||
wget wttr.in/Hameenlinna_0qp.png && feh Hameenlinna_0qp.png
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue