Add scripts
This commit is contained in:
parent
75db2e7ed4
commit
aa7266e92c
3 changed files with 101 additions and 0 deletions
22
bin/backlight.sh
Executable file
22
bin/backlight.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Use brightnessctl to naturally adjust laptop screen brightness and send a notification
|
||||
|
||||
currentbrightness=$(brightnessctl -e4 -m | awk -F, '{print substr($4, 0, length($4)-1)}')
|
||||
if [ "$currentbrightness" -lt 30 ] && [ "$1" = "down" ]; then exit 1; fi
|
||||
|
||||
send_notification() {
|
||||
brightness=$(brightnessctl -e4 -m | awk -F, '{print substr($4, 0, length($4)-1)}')
|
||||
dunstify -a "Backlight" -u critical -h int:value:"$brightness" -i "brightness" "Brightness" -t 1000
|
||||
}
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
brightnessctl -e4 set 1%+
|
||||
send_notification "$1"
|
||||
;;
|
||||
down)
|
||||
brightnessctl -e4 set 1%-
|
||||
send_notification "$1"
|
||||
;;
|
||||
esac
|
24
bin/search.sh
Executable file
24
bin/search.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
ENGINE="$1"
|
||||
shift
|
||||
QUERY="$*"
|
||||
|
||||
ENCODED_QUERY=$(echo "$QUERY" | sed 's/ /+/g')
|
||||
|
||||
case "$ENGINE" in
|
||||
yt)
|
||||
xdg-open "https://www.youtube.com/results?search_query=$ENCODED_QUERY"
|
||||
;;
|
||||
wikipedia)
|
||||
xdg-open "https://en.wikipedia.org/wiki/Special:Search?search=$ENCODED_QUERY"
|
||||
;;
|
||||
duckduckgo)
|
||||
xdg-open "https://duckduckgo.com/?q=$ENCODED_QUERY"
|
||||
;;
|
||||
*)
|
||||
QUERY="$ENGINE $QUERY"
|
||||
ENCODED_QUERY=$(echo "$QUERY" | sed 's/ /+/g')
|
||||
xdg-open "https://www.google.com/search?q=$ENCODED_QUERY"
|
||||
;;
|
||||
esac
|
55
bin/volume.sh
Executable file
55
bin/volume.sh
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
|
||||
wpctl set-volume -l 2.0 @DEFAULT_AUDIO_SINK@ 2%+
|
||||
;;
|
||||
down)
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
|
||||
wpctl set-volume -l 2.0 @DEFAULT_AUDIO_SINK@ 2%-
|
||||
;;
|
||||
mute)
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {up|down|mute}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
VOLUME=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print int($2 * 100)}')
|
||||
|
||||
NORMALIZED_VOLUME=$((VOLUME / 2))
|
||||
|
||||
send_notification() {
|
||||
# if [ "$1" = "mute" ]; then
|
||||
# ICON='' # Mute icon
|
||||
# MSG="Muted"
|
||||
# elif [ "$NORMALIZED_VOLUME" -lt 50 ]; then
|
||||
# ICON='' # Low volume icon
|
||||
# MSG="Volume: $NORMALIZED_VOLUME%"
|
||||
# elif [ "$NORMALIZED_VOLUME" -lt 90 ]; then
|
||||
# ICON='' # Medium volume icon
|
||||
# MSG="Volume: $NORMALIZED_VOLUME%"
|
||||
# else
|
||||
# ICON='' # High volume icon
|
||||
# MSG="Volume: $NORMALIZED_VOLUME%"
|
||||
# fi
|
||||
|
||||
dunstify -u normal -h "int:value:$NORMALIZED_VOLUME" -a "Volume" "Volume" -t 2000
|
||||
}
|
||||
|
||||
case $1 in
|
||||
mute)
|
||||
if wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q "MUTED"; then
|
||||
send_notification mute
|
||||
else
|
||||
send_notification
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
send_notification
|
||||
;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue