init util-scripts repo
This commit is contained in:
commit
96d01820c1
7 changed files with 127 additions and 0 deletions
2
batman.sh
Executable file
2
batman.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
echo $(wcalc -q "round($(cat /sys/class/power_supply/BAT1/charge_now)/$(cat /sys/class/power_supply/BAT1/charge_full) * 100)")%
|
||||||
2
docked-setup.sh
Executable file
2
docked-setup.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
||||||
|
sleep 5
|
||||||
|
wlr-randr --output "HDMI-A-1" --on --mode "2560x1440@144.001007" --scale 1
|
||||||
1
mem.sh
Executable file
1
mem.sh
Executable file
|
|
@ -0,0 +1 @@
|
||||||
|
free -g | awk 'NR==2 {printf "%dG/%dG\n", $3, $2}'
|
||||||
5
screenshot-file.sh
Executable file
5
screenshot-file.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/sh
|
||||||
|
IFS=""
|
||||||
|
file="$HOME/Screenshots/$(date '+%Y-%m-%d-%H-%M-%S.png')"
|
||||||
|
echo $file
|
||||||
|
slurp | grim -g - $file
|
||||||
1
screenshot.sh
Executable file
1
screenshot.sh
Executable file
|
|
@ -0,0 +1 @@
|
||||||
|
slurp | grim -g - - | wl-copy
|
||||||
1
stats.sh
Executable file
1
stats.sh
Executable file
|
|
@ -0,0 +1 @@
|
||||||
|
echo "<$(hostname)@$(uname -r)> [BAT: $(batman)] [MEM: $(mem)]"
|
||||||
115
vol.sh
Executable file
115
vol.sh
Executable file
|
|
@ -0,0 +1,115 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# volume-notify.sh — adjust volume via wpctl + show notification via dunstify
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# volume-notify.sh up → raise volume
|
||||||
|
# volume-notify.sh down → lower volume
|
||||||
|
# volume-notify.sh mute → toggle mute
|
||||||
|
#
|
||||||
|
# Adjust the step size and icons as desired.
|
||||||
|
|
||||||
|
# Which sink to use — default audio sink
|
||||||
|
SINK="@DEFAULT_SINK@"
|
||||||
|
|
||||||
|
# Step percent (use percentage step)
|
||||||
|
STEP="5%"
|
||||||
|
|
||||||
|
# Notification stack tag (so dunst replaces same notification)
|
||||||
|
STACK_TAG="volume-notify"
|
||||||
|
|
||||||
|
# Icons (set your paths or icon names)
|
||||||
|
ICON_HIGH="audio-volume-high"
|
||||||
|
ICON_MED="audio-volume-medium"
|
||||||
|
ICON_LOW="audio-volume-low"
|
||||||
|
ICON_MUTED="audio-volume-muted"
|
||||||
|
|
||||||
|
# Increase volume
|
||||||
|
vol_up() {
|
||||||
|
wpctl set-volume $SINK $STEP+ -l 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Decrease volume
|
||||||
|
vol_down() {
|
||||||
|
wpctl set-volume $SINK $STEP- -l 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Toggle mute
|
||||||
|
vol_mute() {
|
||||||
|
wpctl set-mute $SINK toggle
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get current volume (floating between 0.0-∞, where 1.0 = 100%) and compute percent
|
||||||
|
get_volume_percent() {
|
||||||
|
# Example output: “Volume: 0.50” or “Volume: 0.50 [50%]”
|
||||||
|
local raw
|
||||||
|
raw=$(wpctl get-volume $SINK 2>/dev/null | awk '/Volume:/ {print $2}')
|
||||||
|
# convert to percent
|
||||||
|
# float *100
|
||||||
|
local pct
|
||||||
|
pct=$(awk "BEGIN { printf \"%d\", ($raw * 100) }")
|
||||||
|
echo "$pct"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get mute state (yes/no)
|
||||||
|
get_mute_state() {
|
||||||
|
local m
|
||||||
|
m=$(wpctl get-volume $SINK 2>/dev/null | awk '/Mute:/ {print $2}')
|
||||||
|
echo "$m"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the notification
|
||||||
|
send_notification() {
|
||||||
|
local pct mute icon bar
|
||||||
|
pct=$(get_volume_percent)
|
||||||
|
mute=$(get_mute_state)
|
||||||
|
|
||||||
|
if [[ "$mute" == "yes" ]]; then
|
||||||
|
icon="$ICON_MUTED"
|
||||||
|
# we can treat volume as 0
|
||||||
|
pct=0
|
||||||
|
else
|
||||||
|
# pick icon based on level
|
||||||
|
if (( pct >= 66 )); then
|
||||||
|
icon="$ICON_HIGH"
|
||||||
|
elif (( pct >= 33 )); then
|
||||||
|
icon="$ICON_MED"
|
||||||
|
else
|
||||||
|
icon="$ICON_LOW"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Optional: build a simple textual bar (e.g., █ or ░)
|
||||||
|
# e.g., length 20, filled proportionally
|
||||||
|
local barlen=20
|
||||||
|
local filled=$(( (pct * barlen) / 100 ))
|
||||||
|
bar=$(printf '%*s' "$filled" '' | tr ' ' '█')
|
||||||
|
bar+=$(printf '%*s' "$((barlen - filled))" '' | tr ' ' '░')
|
||||||
|
|
||||||
|
# Send notification: use value hint for progress bar
|
||||||
|
dunstify -i "$icon" \
|
||||||
|
-u normal \
|
||||||
|
-h string:x-dunst-stack-tag:$STACK_TAG \
|
||||||
|
-h int:value:$pct "Volume: ${pct}%"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main logic
|
||||||
|
case "$1" in
|
||||||
|
up)
|
||||||
|
vol_up
|
||||||
|
send_notification
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
vol_down
|
||||||
|
send_notification
|
||||||
|
;;
|
||||||
|
mute)
|
||||||
|
vol_mute
|
||||||
|
send_notification
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {up|down|mute}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue