mirror of
https://codeberg.org/frosty/dotfiles.git
synced 2024-09-19 03:37:10 -04:00
script changes hell
This commit is contained in:
parent
c42ba15500
commit
0beda2cf99
16
.local/bin/batmon
Executable file
16
.local/bin/batmon
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
FULL_THRESHOLD=80
|
||||
FULL_COLOR="#31f53e"
|
||||
|
||||
read -r capacity </sys/class/power_supply/BAT1/capacity
|
||||
read -r status </sys/class/power_supply/BAT1/status
|
||||
|
||||
if [ "$capacity" -ge "$FULL_THRESHOLD" ] && [ "$status" = "Not charging" ]; then
|
||||
status="Full"
|
||||
fi
|
||||
if [ "$status" = "Full" ]; then
|
||||
printf '<fc=%s>%s%%</fc> (%s)\n' "$FULL_COLOR" "$capacity" "$status"
|
||||
else
|
||||
printf '%s%% (%s)\n' "$capacity" "$status"
|
||||
fi
|
|
@ -1,14 +1,29 @@
|
|||
#!/bin/sh
|
||||
|
||||
initial_values=$(awk '/cpu /{print $2+$4,$2+$4+$5}' /proc/stat)
|
||||
sleep 2
|
||||
current_values=$(awk '/cpu /{print $2+$4,$2+$4+$5}' /proc/stat)
|
||||
while read -r _ user _ system idle _; do
|
||||
initial_user_sys=$((user + system))
|
||||
initial_total=$((user + system + idle))
|
||||
break
|
||||
done </proc/stat
|
||||
|
||||
set -- $initial_values
|
||||
initial_user_sys=$1
|
||||
initial_total=$2
|
||||
set -- $current_values
|
||||
current_user_sys=$1
|
||||
current_total=$2
|
||||
sleep 1
|
||||
|
||||
awk "BEGIN {print ($current_user_sys - $initial_user_sys) / ($current_total - $initial_total) * 100}"
|
||||
while read -r _ user _ system idle _; do
|
||||
current_user_sys=$((user + system))
|
||||
current_total=$((user + system + idle))
|
||||
break
|
||||
done </proc/stat
|
||||
|
||||
while read -r line; do
|
||||
case $line in
|
||||
*Package\ id\ 0:*) temp=$line ;;
|
||||
esac
|
||||
done <<EOF
|
||||
$(sensors)
|
||||
EOF
|
||||
|
||||
temp=${temp#Package id 0:*+}
|
||||
temp=${temp%%°*}
|
||||
temp=${temp%.*}
|
||||
|
||||
printf '%s°C (%.*f%%)\n' "$temp" 0 $(((current_user_sys - initial_user_sys) * 100 / (current_total - initial_total)))
|
||||
|
|
|
@ -74,14 +74,20 @@ version() {
|
|||
}
|
||||
|
||||
while getopts :hVqcos opt; do
|
||||
case "$opt" in
|
||||
h) usage; exit 0 ;;
|
||||
V) version; exit 0 ;;
|
||||
q) QUIET=1 ;;
|
||||
c) COPY=1 ;;
|
||||
o) OVERLAY=1 ;;
|
||||
s) SAVE=1 ;;
|
||||
*) die "invalid option: -$OPTARG" ;;
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
V)
|
||||
version
|
||||
exit 0
|
||||
;;
|
||||
q) QUIET=1 ;;
|
||||
c) COPY=1 ;;
|
||||
o) OVERLAY=1 ;;
|
||||
s) SAVE=1 ;;
|
||||
*) die "invalid option: -$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -91,8 +97,11 @@ SCREENSHOT_TYPE=${1:-select}
|
|||
FILE_PATH=${2:-}
|
||||
|
||||
case "$SCREENSHOT_TYPE" in
|
||||
select|full) ;;
|
||||
*) usage; exit 1 ;;
|
||||
select | full) ;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$SAVE" ]; then
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOW_USED_COLOR="#b8bb26"
|
||||
MEDIUM_USED_COLOR="#fabd2f"
|
||||
HIGH_USED_COLOR="#fb4934"
|
||||
DEFAULT_USED_COLOR="#d5c4a1"
|
||||
UNUSED_COLOR="#a88984"
|
||||
LOW_USED_COLOR="#a3be8c"
|
||||
MEDIUM_USED_COLOR="#ebcb8b"
|
||||
HIGH_USED_COLOR="#bf616a"
|
||||
DEFAULT_USED_COLOR="#81a1c1"
|
||||
UNUSED_COLOR="#5e81ac"
|
||||
|
||||
usage=$1
|
||||
width=$2
|
||||
|
@ -14,26 +14,43 @@ command -v "$1" >/dev/null && usage=$($1)
|
|||
|
||||
low_used=$((width * 30 / 100))
|
||||
medium_used=$((width * 60 / 100))
|
||||
num_used_chars=$(echo "scale=0; ($usage * $width) / 100" | bc -l)
|
||||
num_used_chars=$(printf 'scale=0; (%s * %s) / 100\n' "$usage" "$width" | bc -l)
|
||||
|
||||
if [ -n "$usage_color" ]; then
|
||||
case "$num_used_chars" in
|
||||
[0-$low_used]) used_color="$LOW_USED_COLOR" ;;
|
||||
[$low_used-$medium_used]) used_color="$MEDIUM_USED_COLOR" ;;
|
||||
*) used_color="$HIGH_USED_COLOR" ;;
|
||||
[0-$low_used]) used_color="$LOW_USED_COLOR" ;;
|
||||
[$low_used-$medium_used]) used_color="$MEDIUM_USED_COLOR" ;;
|
||||
*) used_color="$HIGH_USED_COLOR" ;;
|
||||
esac
|
||||
else
|
||||
used_color="$DEFAULT_USED_COLOR"
|
||||
fi
|
||||
|
||||
prev_opened=0
|
||||
any_used_width=0
|
||||
i=1
|
||||
while [ "$i" -le "$width" ]; do
|
||||
if [ "$i" -le "$num_used_chars" ]; then
|
||||
bar="$bar<fc=$used_color>#</fc>"
|
||||
if [ "$prev_opened" -eq 0 ]; then
|
||||
bar="$bar<fc=$used_color>"
|
||||
prev_opened=1
|
||||
any_used_width=1
|
||||
fi
|
||||
bar="$bar#"
|
||||
else
|
||||
bar="$bar<fc=$UNUSED_COLOR>:</fc>"
|
||||
if [ "$any_used_width" -eq 1 ]; then
|
||||
bar="$bar</fc>"
|
||||
prev_opened=0
|
||||
any_used_width=0
|
||||
fi
|
||||
if [ "$prev_opened" -eq 0 ]; then
|
||||
bar="$bar<fc=$UNUSED_COLOR>"
|
||||
prev_opened=1
|
||||
fi
|
||||
bar="$bar:"
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
bar="$bar</fc>"
|
||||
|
||||
echo "$bar"
|
||||
printf '%s\n' "$bar"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
PIPES="nowplaying volume"
|
||||
PIPES="volume"
|
||||
|
||||
for pipe in $PIPES; do
|
||||
echo "" >"/tmp/pipe-$pipe"
|
||||
|
|
7
.local/bin/ipmon
Executable file
7
.local/bin/ipmon
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
address=$(ip route get 1)
|
||||
address=${address#* via * dev * src }
|
||||
address=${address% uid *}
|
||||
|
||||
printf '%s\n' "$address"
|
9
.local/bin/loadmon
Executable file
9
.local/bin/loadmon
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
while read -r one five fifteen _; do
|
||||
load_one=$one
|
||||
load_five=$five
|
||||
load_fifteen=$fifteen
|
||||
done </proc/loadavg
|
||||
|
||||
printf '%s %s %s\n' "$load_one" "$load_five" "$load_fifteen"
|
|
@ -1,8 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
total_mem=$(($(grep MemTotal /proc/meminfo | awk '{print $2}') / 1024))
|
||||
free_mem=$(($(grep MemAvailable /proc/meminfo | awk '{print $2}') / 1024))
|
||||
|
||||
convert_to_human_readable() {
|
||||
if [ "$1" -lt 1024 ]; then
|
||||
printf "%.1fK\n" "$1"
|
||||
elif [ "$1" -lt 1048576 ]; then
|
||||
printf "%.1fM\n" $(($1 / 1024))
|
||||
else
|
||||
printf "%.1fG\n" $(($1 / 1048576))
|
||||
fi
|
||||
}
|
||||
|
||||
while read -r label size _; do
|
||||
case $label in
|
||||
MemTotal:) total_mem=$size ;;
|
||||
MemAvailable:) free_mem=$size ;;
|
||||
esac
|
||||
done </proc/meminfo
|
||||
used_mem=$((total_mem - free_mem))
|
||||
|
||||
awk "BEGIN {print ($used_mem / $total_mem) * 100}"
|
||||
printf '%s (%s%%)\n' "$(convert_to_human_readable "$used_mem")" $((used_mem * 100 / total_mem))
|
||||
|
|
|
@ -5,4 +5,4 @@ TEXT_COLOR="#fe8019"
|
|||
PIPE_FILE="/tmp/pipe-nowplaying"
|
||||
[ -p "$PIPE_FILE" ] || mkfifo "$PIPE_FILE"
|
||||
|
||||
playerctl metadata --format "<fc=$TEXT_COLOR>{{artist}} - {{title}}</fc>" >"$PIPE_FILE"
|
||||
echo "<fc=$TEXT_COLOR>$(mpc | head -n1)</fc>" >"$PIPE_FILE"
|
||||
|
|
|
@ -3,5 +3,4 @@
|
|||
PIPE_FILE="/tmp/pipe-volume"
|
||||
[ -p "$PIPE_FILE" ] || mkfifo "$PIPE_FILE"
|
||||
|
||||
volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '/Volume/ { print int($NF * 100) }')
|
||||
genbar "$volume" 10 1 >"$PIPE_FILE"
|
||||
volmon >"$PIPE_FILE"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
xrandr \
|
||||
--output eDP-1 --off \
|
||||
--output HDMI-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal
|
||||
--output eDP1 --off \
|
||||
--output HDMI2 --primary --mode 1920x1080 --pos 0x0 --rotate normal
|
||||
|
|
17
.local/bin/ssidmon
Executable file
17
.local/bin/ssidmon
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
ADAPTER="wlan0"
|
||||
|
||||
ssid=
|
||||
while read -r line; do
|
||||
case $line in
|
||||
*Connected\ network*)
|
||||
ssid=${line##*Connected network}
|
||||
ssid="${ssid#"${ssid%%[![:space:]]*}"}"
|
||||
;;
|
||||
esac
|
||||
done <<EOF
|
||||
$(iwctl station "$ADAPTER" show)
|
||||
EOF
|
||||
|
||||
printf '%s\n' "$ssid"
|
15
.local/bin/tempmon
Executable file
15
.local/bin/tempmon
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
while read -r line; do
|
||||
case $line in
|
||||
*Package\ id\ 0:*) temp=$line ;;
|
||||
esac
|
||||
done <<EOF
|
||||
$(sensors)
|
||||
EOF
|
||||
|
||||
temp=${temp#Package id 0:*+}
|
||||
temp=${temp%%°*}
|
||||
temp=${temp%.*}
|
||||
|
||||
printf '%s°C\n' "$temp"
|
|
@ -1,3 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '/Volume/ { print int($NF * 100) }'
|
||||
volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
|
||||
volume=${volume% \[MUTED\]}
|
||||
volume=${volume#Volume: }
|
||||
volume=${volume%.*}${volume#*.}
|
||||
volume=${volume#0}
|
||||
|
||||
printf '%s%%\n' "$volume"
|
||||
|
|
|
@ -39,8 +39,8 @@ restore() {
|
|||
|
||||
previous="$(readlink -f "$XDG_DATA_HOME/wallpaper")"
|
||||
case "${previous##*.}" in
|
||||
png|jpg|jpeg) ;;
|
||||
*) die "$previous: unsupported file type" ;;
|
||||
png | jpg | jpeg) ;;
|
||||
*) die "$previous: unsupported file type" ;;
|
||||
esac
|
||||
|
||||
cmp -s "$previous" "$XDG_CACHE_HOME/lock.png" || convert_lock "$previous" &
|
||||
|
@ -51,24 +51,24 @@ restore() {
|
|||
|
||||
while getopts ":hqre:u:" opt; do
|
||||
case $opt in
|
||||
h) usage ;;
|
||||
q) QUIET=1 ;;
|
||||
r) restore ;;
|
||||
e) LOCK_RESOLUTION="$OPTARG" ;;
|
||||
u) LOCK_QUALITY="$OPTARG" ;;
|
||||
\?) usage "invalid option -- '$OPTARG'" ;;
|
||||
:) usage "option requires an argument -- '$OPTARG'" ;;
|
||||
h) usage ;;
|
||||
q) QUIET=1 ;;
|
||||
r) restore ;;
|
||||
e) LOCK_RESOLUTION=$OPTARG ;;
|
||||
u) LOCK_QUALITY=$OPTARG ;;
|
||||
\?) usage "invalid option -- '$OPTARG'" ;;
|
||||
:) usage "option requires an argument -- '$OPTARG'" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
if [ "$1" = "-" ]; then
|
||||
while IFS= read -r line; do
|
||||
image="$line"
|
||||
done
|
||||
while read -r line; do
|
||||
image=$line
|
||||
done
|
||||
else
|
||||
image="$1"
|
||||
image=$1
|
||||
fi
|
||||
|
||||
[ -n "$image" ] || usage "IMAGE was not provided"
|
||||
|
@ -76,8 +76,8 @@ fi
|
|||
[ -f "$image" ] || die "$image: no such file"
|
||||
|
||||
case "${image##*.}" in
|
||||
png|jpg|jpeg) ;;
|
||||
*) die "$image: unsupported file type" ;;
|
||||
png | jpg | jpeg) ;;
|
||||
*) die "$image: unsupported file type" ;;
|
||||
esac
|
||||
|
||||
cmp -s "$image" "$XDG_CACHE_HOME/lock.png" || convert_lock "$image" &
|
||||
|
|
Loading…
Reference in a new issue