Compare commits
3 Commits
5c84263502
...
5857d4a0ed
| Author | SHA1 | Date | |
|---|---|---|---|
|
5857d4a0ed
|
|||
|
7f9b095859
|
|||
|
6d3b2e7445
|
@@ -150,6 +150,7 @@ misc {
|
|||||||
disable_splash_rendering = 1
|
disable_splash_rendering = 1
|
||||||
disable_hyprland_logo = 1
|
disable_hyprland_logo = 1
|
||||||
focus_on_activate = 0 # This breaks vdesks
|
focus_on_activate = 0 # This breaks vdesks
|
||||||
|
anr_missed_pings = 10
|
||||||
}
|
}
|
||||||
ecosystem {
|
ecosystem {
|
||||||
no_donation_nag = 1
|
no_donation_nag = 1
|
||||||
|
|||||||
@@ -34,19 +34,99 @@ background {
|
|||||||
# AUTO BACKGROUND
|
# AUTO BACKGROUND
|
||||||
# AUTO BACKGROUND END
|
# AUTO BACKGROUND END
|
||||||
|
|
||||||
# TIME
|
# Time-Hour
|
||||||
label {
|
label {
|
||||||
text = $TIME
|
monitor =
|
||||||
color = rgb(255, 255, 255)
|
text = cmd[update:1000] echo "<span>$(date +"%I")</span>"
|
||||||
font_size = 90
|
color = rgba(255, 255, 255, 1)
|
||||||
font_family = $font
|
font_size = 125
|
||||||
position = 75, 0
|
font_family = StretchPro
|
||||||
halign = left
|
position = -80, 290
|
||||||
valign = top
|
halign = center
|
||||||
|
valign = center
|
||||||
|
shadow_passes = 3
|
||||||
|
shadow_size = 3
|
||||||
|
shadow_color = rgba(0, 0, 0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Time-Minute
|
||||||
|
label {
|
||||||
|
monitor =
|
||||||
|
text = cmd[update:1000] echo "<span>$(date +"%M")</span>"
|
||||||
|
color = rgba(147, 196, 255, 1)
|
||||||
|
font_size = 125
|
||||||
|
font_family = StretchPro
|
||||||
|
position = 0, 170
|
||||||
|
halign = center
|
||||||
|
valign = center
|
||||||
|
shadow_passes = 3
|
||||||
|
shadow_size = 3
|
||||||
|
shadow_color = rgba(0, 0, 0,1)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Day-Month-Date
|
||||||
|
label {
|
||||||
|
monitor =
|
||||||
|
text = cmd[update:1000] echo -e "$(date +"%d %B")"
|
||||||
|
color = rgba(255, 255, 255, 1)
|
||||||
|
font_size = 22
|
||||||
|
font_family = Suisse Int'l Mono
|
||||||
|
position = 20, 92
|
||||||
|
halign = center
|
||||||
|
valign = center
|
||||||
|
shadow_passes = 3
|
||||||
|
shadow_size = 5
|
||||||
|
shadow_color = rgba(0, 0, 0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
# USER AVATAR
|
||||||
|
image {
|
||||||
|
monitor =
|
||||||
|
path = $HOME/.face
|
||||||
|
rounding = 25
|
||||||
|
size = 200
|
||||||
|
# border_color = rgb(0, 0, 0)
|
||||||
|
border_size = 0
|
||||||
|
position = 0, -100
|
||||||
|
halign = center
|
||||||
|
valign = center
|
||||||
|
}
|
||||||
|
|
||||||
|
# INPUT FIELD
|
||||||
|
input-field {
|
||||||
|
monitor =
|
||||||
|
size = 300, 60
|
||||||
|
outline_thickness = 2
|
||||||
|
dots_size = 0.2 # Scale of input-field height, 0.2 - 0.8
|
||||||
|
dots_spacing = 0.2 # Scale of dots' absolute size, 0.0 - 1.0
|
||||||
|
dots_center = true
|
||||||
|
outer_color = rgba(255, 255, 255, 1)
|
||||||
|
inner_color = rgba(0, 0, 0, 1)
|
||||||
|
font_color = rgb(200, 200, 200)
|
||||||
|
fade_on_empty = false
|
||||||
|
font_family = SF Pro Display Bold
|
||||||
|
placeholder_text = <i><span foreground="##ffffff99">Password...</span></i>
|
||||||
|
hide_input = false
|
||||||
|
position = 0, -290
|
||||||
|
halign = center
|
||||||
|
valign = center
|
||||||
|
}
|
||||||
|
|
||||||
|
# CURRENT SONG
|
||||||
|
label {
|
||||||
|
monitor = eDP-1
|
||||||
|
text = cmd[update:1000] echo "$(~/.config/hypr/scripts/songdetail.sh)"
|
||||||
|
color = rgba(147, 196, 255, 1)
|
||||||
|
font_size = 18
|
||||||
|
font_family = JetBrains Mono Nerd, SF Pro Display Bold
|
||||||
|
position = 0, 20
|
||||||
|
halign = center
|
||||||
|
valign = bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
# Battery
|
# Battery
|
||||||
label {
|
label {
|
||||||
|
monitor = eDP-1
|
||||||
text = cmd[update:1000] /home/nathan/.config/hypr/scripts/battery.sh
|
text = cmd[update:1000] /home/nathan/.config/hypr/scripts/battery.sh
|
||||||
color = rgb(255, 255, 255)
|
color = rgb(255, 255, 255)
|
||||||
font_size = 20
|
font_size = 20
|
||||||
@@ -56,62 +136,15 @@ label {
|
|||||||
valign = bottom
|
valign = bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
# DATE
|
|
||||||
# label {
|
|
||||||
# # monitor =
|
|
||||||
# text = cmd[update:43200000] date +"%A, %d %B %Y"
|
|
||||||
# color = rgb(255, 255, 255)
|
|
||||||
# font_size = 25
|
|
||||||
# font_family = $font
|
|
||||||
# position = 30, -150
|
|
||||||
# halign = left
|
|
||||||
# valign = top
|
|
||||||
# }
|
|
||||||
shape {
|
|
||||||
monitor =
|
|
||||||
size = 500, 100%
|
|
||||||
color = rgba(255, 255, 255, 0.18)
|
|
||||||
rounding = 25
|
|
||||||
# border_size = 4
|
|
||||||
# border_color = rgba(255, 255, 255, 1.0)
|
|
||||||
|
|
||||||
position = -25, 0
|
# Stats
|
||||||
|
label {
|
||||||
|
monitor = eDP-1
|
||||||
|
text = cmd[update:15000] /home/nathan/.config/hypr/scripts/stats.sh
|
||||||
|
color = rgb(255, 255, 255)
|
||||||
|
font_size = 10
|
||||||
|
font_family = Symbols Nerd Font Mono
|
||||||
|
position = 10, 10
|
||||||
halign = left
|
halign = left
|
||||||
valign = center
|
valign = bottom
|
||||||
}
|
|
||||||
|
|
||||||
# USER AVATAR
|
|
||||||
image {
|
|
||||||
# monitor =
|
|
||||||
path = $HOME/.face
|
|
||||||
rounding = 25
|
|
||||||
size = 200
|
|
||||||
# border_color = rgb(0, 0, 0)
|
|
||||||
border_size = 0
|
|
||||||
position = 150, 100
|
|
||||||
halign = left
|
|
||||||
valign = center
|
|
||||||
}
|
|
||||||
|
|
||||||
# INPUT FIELD
|
|
||||||
input-field {
|
|
||||||
# monitor =
|
|
||||||
size = 300, 60
|
|
||||||
position = 100, -47
|
|
||||||
outline_thickness = 4
|
|
||||||
dots_size = 0.2
|
|
||||||
dots_spacing = 0.2
|
|
||||||
dots_center = true
|
|
||||||
outer_color = rgb(0, 0, 0)
|
|
||||||
inner_color = rgb(255, 255, 255)
|
|
||||||
font_color = rgb(0, 0, 0)
|
|
||||||
fade_on_empty = false
|
|
||||||
placeholder_text = <span foreground="black"><i></i> Nathan</span>
|
|
||||||
hide_input = false
|
|
||||||
check_color = rgb(212, 130, 6)
|
|
||||||
fail_color = rgb(255, 0, 0)
|
|
||||||
fail_text = <i>$FAIL <b>($ATTEMPTS)</b></i>
|
|
||||||
capslock_color = rgb(255, 0, 0)
|
|
||||||
halign = left
|
|
||||||
valign = center
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ bindl=, XF86AudioNext, exec, playerctl next
|
|||||||
bindl=, XF86AudioPrev, exec, playerctl previous
|
bindl=, XF86AudioPrev, exec, playerctl previous
|
||||||
|
|
||||||
# Other FN keys
|
# Other FN keys
|
||||||
bindl= $mainMod CTRL, XF86TouchpadToggle, exec, hyprctl notify -1 2000 -1 "TODO Touchpad Toggle"
|
bind= $mainMod CTRL, XF86TouchpadToggle, exec, hyprctl notify -1 2000 -1 "TODO Touchpad Toggle"
|
||||||
bind = $mainMod, P, exec, hyprctl notify -1 2000 -1 "TODO Screen Settings"
|
bind = $mainMod, P, exec, hyprctl notify -1 2000 -1 "TODO Screen Settings"
|
||||||
bindl = , Print, exec, hyprshot -m output -m active
|
bindl = , Print, exec, hyprshot -m output -m active
|
||||||
bind = $mainMod, Print, exec, hyprshot -m window -m active
|
bind = $mainMod, Print, exec, hyprshot -m window -m active
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "Preparing hyprlock configuration..."
|
||||||
# Path to hyprlock configuration file
|
# Path to hyprlock configuration file
|
||||||
CONF="$HOME/.config/hypr/hyprlock.conf"
|
CONF="$HOME/.config/hypr/hyprlock.conf"
|
||||||
|
|
||||||
# Get the list of outputs
|
# Get the list of outputs
|
||||||
mapfile -t outputs < <(hyprctl -j monitors | jq -r '.[].name')
|
mapfile -t outputs < <(hyprctl -j monitors | jq -r '.[].name')
|
||||||
|
|
||||||
@@ -25,44 +25,29 @@ awk -v content="$block" '
|
|||||||
{ print }
|
{ print }
|
||||||
' "$CONF" > "${CONF}.tmp" && mv "${CONF}.tmp" "$CONF"
|
' "$CONF" > "${CONF}.tmp" && mv "${CONF}.tmp" "$CONF"
|
||||||
|
|
||||||
|
echo "Starting hyprlock..."
|
||||||
/home/nathan/Git/hyprlock/build/hyprlock &
|
/home/nathan/Git/hyprlock/build/hyprlock &
|
||||||
|
|
||||||
|
echo "Taking screenshots for lock screen..."
|
||||||
# Take a screenshot of each output before locking (!THIS IS SLOW!)
|
# Take a screenshot of each output before locking (!THIS IS SLOW!)
|
||||||
for output in "${outputs[@]}"; do
|
for output in "${outputs[@]}"; do
|
||||||
# grim -o "$output" "/tmp/${output}-lockscreen.png" &
|
# grim -o "$output" "/tmp/${output}-lockscreen.png" &
|
||||||
$HOME/.config/hypr/scripts/spots.sh -s 8 <(grim -o "$output" -) "/tmp/${output}-lockscreen.png" &
|
$HOME/.config/hypr/scripts/spots.sh -s 8 <(grim -o "$output" -) "/tmp/${output}-lockscreen.png" &
|
||||||
done
|
done
|
||||||
|
|
||||||
while pgrep -x grim >/dev/null; do
|
echo "Waiting for screenshots to complete..."
|
||||||
sleep 0.1
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Start hyprlock while we process the images
|
|
||||||
|
|
||||||
|
|
||||||
# Apply image effect to each screenshot
|
|
||||||
# for output in "${outputs[@]}"; do
|
|
||||||
# # Apply blur effect using spots.sh
|
|
||||||
# /home/nathan/.config/hypr/scripts/spots.sh -s 8 "/tmp/${output}-lockscreen.png" "/tmp/${output}-lockscreen.png" &
|
|
||||||
# done
|
|
||||||
# Wait for all image processing to complete
|
# Wait for all image processing to complete
|
||||||
while pgrep -x spots.sh >/dev/null; do
|
while pgrep -x spots.sh >/dev/null; do
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
|
|
||||||
# Notify hyprlock to reload backgrounds
|
# Notify hyprlock to reload backgrounds
|
||||||
echo "Reloading hyprlock backgrounds..."
|
echo "Reloading hyprlock backgrounds..."
|
||||||
pkill -USR2 hyprlock
|
pkill -USR2 hyprlock
|
||||||
|
|
||||||
# Wait for hyprlock to exit
|
echo "Waiting for hyprlock to exit..."
|
||||||
while pgrep -x hyprlock >/dev/null; do
|
wait
|
||||||
echo "Waiting for hyprlock to exit..."
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
|
echo "Hyprlock exited. Cleaning up..."
|
||||||
# Cleanup: Restore hyprlock.conf to original state
|
# Cleanup: Restore hyprlock.conf to original state
|
||||||
sed -i '/^# AUTO BACKGROUND$/,/^# AUTO BACKGROUND END$/{//!d}' "$CONF"
|
sed -i '/^# AUTO BACKGROUND$/,/^# AUTO BACKGROUND END$/{//!d}' "$CONF"
|
||||||
|
|
||||||
|
|||||||
5
.config/hypr/scripts/songdetail.sh
Executable file
5
.config/hypr/scripts/songdetail.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
song_info=$(playerctl metadata --format '{{title}} {{artist}}')
|
||||||
|
|
||||||
|
echo "$song_info"
|
||||||
@@ -291,25 +291,25 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# test input image
|
# test input image
|
||||||
convert -quiet "$infile" $bricon -clamp +repage "$tmpA1" ||
|
magick -quiet "$infile" $bricon -clamp +repage "$tmpA1" ||
|
||||||
errMsg "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"
|
errMsg "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"
|
||||||
|
|
||||||
# test spot file if exists
|
# test spot file if exists
|
||||||
if [ "$spotfile" != "" ]; then
|
if [ "$spotfile" != "" ]; then
|
||||||
convert -quiet "$spotfile" -alpha off +repage "$tmpA2" ||
|
magick -quiet "$spotfile" -alpha off +repage "$tmpA2" ||
|
||||||
errMsg "--- FILE $spotfile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"
|
errMsg "--- FILE $spotfile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get image width, height and aspect
|
# get image width, height and aspect
|
||||||
ww=`convert $tmpA1 -ping -format "%w" info:`
|
ww=`magick $tmpA1 -ping -format "%w" info:`
|
||||||
hh=`convert $tmpA1 -ping -format "%h" info:`
|
hh=`magick $tmpA1 -ping -format "%h" info:`
|
||||||
|
|
||||||
# get size of spot and center of spot and last pixel of spot and pad size
|
# get size of spot and center of spot and last pixel of spot and pad size
|
||||||
if [ "$spotfile" = "" ]; then
|
if [ "$spotfile" = "" ]; then
|
||||||
sw=`echo $size | cut -dx -f1`
|
sw=`echo $size | cut -dx -f1`
|
||||||
sh=`echo $size | cut -dx -f2`
|
sh=`echo $size | cut -dx -f2`
|
||||||
scx=`convert xc: -format "%[fx:($sw-1)/2]" info:`
|
scx=`magick xc: -format "%[fx:($sw-1)/2]" info:`
|
||||||
scy=`convert xc: -format "%[fx:($sh-1)/2]" info:`
|
scy=`magick xc: -format "%[fx:($sh-1)/2]" info:`
|
||||||
lx=$((sw-1))
|
lx=$((sw-1))
|
||||||
ly=$((sh-1))
|
ly=$((sh-1))
|
||||||
|
|
||||||
@@ -318,8 +318,8 @@ if [ "$spotfile" = "" ]; then
|
|||||||
ph=$((sh+2*pad))
|
ph=$((sh+2*pad))
|
||||||
|
|
||||||
else
|
else
|
||||||
pw=`convert $tmpA2 -ping -format "%w" info:`
|
pw=`magick $tmpA2 -ping -format "%w" info:`
|
||||||
ph=`convert $tmpA2 -ping -format "%h" info:`
|
ph=`magick $tmpA2 -ping -format "%h" info:`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -332,19 +332,19 @@ if [ "$spotfile" = "" ]; then
|
|||||||
|
|
||||||
# create spot template
|
# create spot template
|
||||||
if [ "$type" = "circle" ]; then
|
if [ "$type" = "circle" ]; then
|
||||||
convert -size ${sw}x${sh} xc:black \
|
magick -size ${sw}x${sh} xc:black \
|
||||||
+antialias -fill white -draw "ellipse $scx,$scy $scx,$scy 0,360" -alpha off \
|
+antialias -fill white -draw "ellipse $scx,$scy $scx,$scy 0,360" -alpha off \
|
||||||
$padding \
|
$padding \
|
||||||
$tmpA2
|
$tmpA2
|
||||||
|
|
||||||
elif [ "$type" = "square" ]; then
|
elif [ "$type" = "square" ]; then
|
||||||
convert -size ${sw}x${sh} xc:black \
|
magick -size ${sw}x${sh} xc:black \
|
||||||
+antialias -fill white -draw "rectangle 0,0 $lx,$ly" -alpha off \
|
+antialias -fill white -draw "rectangle 0,0 $lx,$ly" -alpha off \
|
||||||
$padding \
|
$padding \
|
||||||
$tmpA2
|
$tmpA2
|
||||||
|
|
||||||
elif [ "$type" = "diamond" ]; then
|
elif [ "$type" = "diamond" ]; then
|
||||||
convert -size ${sw}x${sh} xc:black \
|
magick -size ${sw}x${sh} xc:black \
|
||||||
+antialias -fill white -draw "polygon $scx,0 $lx,$scy $scx,$ly 0,$scy" -alpha off \
|
+antialias -fill white -draw "polygon $scx,0 $lx,$scy $scx,$ly 0,$scy" -alpha off \
|
||||||
$padding \
|
$padding \
|
||||||
$tmpA2
|
$tmpA2
|
||||||
@@ -352,22 +352,22 @@ if [ "$spotfile" = "" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# compute xmin and ymin and virtual canvas size
|
# compute xmin and ymin and virtual canvas size
|
||||||
xmin=`convert xc: -format "%[fx:ceil($ww/$pw)]" info:`
|
xmin=`magick xc: -format "%[fx:ceil($ww/$pw)]" info:`
|
||||||
ymin=`convert xc: -format "%[fx:ceil($hh/$ph)]" info:`
|
ymin=`magick xc: -format "%[fx:ceil($hh/$ph)]" info:`
|
||||||
www=`convert xc: -format "%[fx:$xmin*$pw]" info:`
|
www=`magick xc: -format "%[fx:$xmin*$pw]" info:`
|
||||||
hhh=`convert xc: -format "%[fx:$ymin*$ph]" info:`
|
hhh=`magick xc: -format "%[fx:$ymin*$ph]" info:`
|
||||||
|
|
||||||
|
|
||||||
# process image
|
# process image
|
||||||
if [ "$edge" = "0" ]; then
|
if [ "$edge" = "0" ]; then
|
||||||
convert \( $tmpA1 -define distort:viewport=${www}x${hhh}+0+0 -virtual-pixel mirror -distort SRT 0 \
|
magick \( $tmpA1 -define distort:viewport=${www}x${hhh}+0+0 -virtual-pixel mirror -distort SRT 0 \
|
||||||
-scale ${xmin}x${ymin}! -scale ${www}x${hhh}! -crop ${ww}x${hh}+0+0 +repage \) \
|
-scale ${xmin}x${ymin}! -scale ${www}x${hhh}! -crop ${ww}x${hh}+0+0 +repage \) \
|
||||||
\( $tmpA2 -write mpr:tile +delete -size ${ww}x${hh}! tile:mpr:tile \) \
|
\( $tmpA2 -write mpr:tile +delete -size ${ww}x${hh}! tile:mpr:tile \) \
|
||||||
-alpha off -compose copy_opacity -composite -compose over \
|
-alpha off -compose copy_opacity -composite -compose over \
|
||||||
-background $bgcolor -flatten \
|
-background $bgcolor -flatten \
|
||||||
"$outfile"
|
"$outfile"
|
||||||
else
|
else
|
||||||
convert \( $tmpA1 -define distort:viewport=${www}x${hhh}+0 -virtual-pixel mirror -distort SRT 0 \
|
magick \( $tmpA1 -define distort:viewport=${www}x${hhh}+0 -virtual-pixel mirror -distort SRT 0 \
|
||||||
-scale ${xmin}x${ymin}! -scale ${www}x${hhh}! -crop ${ww}x${hh}+0+0 +repage \) \
|
-scale ${xmin}x${ymin}! -scale ${www}x${hhh}! -crop ${ww}x${hh}+0+0 +repage \) \
|
||||||
\( $tmpA2 -write mpr:tile +delete -size ${ww}x${hh}! tile:mpr:tile \) \
|
\( $tmpA2 -write mpr:tile +delete -size ${ww}x${hh}! tile:mpr:tile \) \
|
||||||
\( -clone 1 -threshold 0 -edge $edge -clamp -fill $ecolor -opaque white -transparent black \) \
|
\( -clone 1 -threshold 0 -edge $edge -clamp -fill $ecolor -opaque white -transparent black \) \
|
||||||
|
|||||||
111
.config/hypr/scripts/stats.sh
Executable file
111
.config/hypr/scripts/stats.sh
Executable file
@@ -0,0 +1,111 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Get system statistics
|
||||||
|
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print 100 - $8}' | cut -d. -f1)
|
||||||
|
MEMORY_USAGE=$(free -m | awk 'NR==2{printf "%.0f", $3*100/$2 }')
|
||||||
|
|
||||||
|
CPU_TEMP=""
|
||||||
|
# Get temp info (CPU temp)
|
||||||
|
if [ -r /sys/class/thermal/thermal_zone0/temp ]; then
|
||||||
|
CPU_TEMP_RAW=$(cat /sys/class/thermal/thermal_zone0/temp)
|
||||||
|
CPU_TEMP_C=$((CPU_TEMP_RAW / 1000))
|
||||||
|
CPU_TEMP=" ${CPU_TEMP_C}°C"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo " ${CPU_USAGE}%${CPU_TEMP} ${MEMORY_USAGE}%"
|
||||||
|
|
||||||
|
# GPU info
|
||||||
|
GPU_USAGE=$(cat /sys/class/drm/card1/device/gpu_busy_percent)
|
||||||
|
GPU_VRAM_USED=$(cat /sys/class/drm/card1/device/mem_info_vram_used)
|
||||||
|
GPU_VRAM_TOTAL=$(cat /sys/class/drm/card1/device/mem_info_vram_total)
|
||||||
|
GPU_VRAM_USAGE=$((GPU_VRAM_USED * 100 / GPU_VRAM_TOTAL))
|
||||||
|
|
||||||
|
|
||||||
|
echo " ${GPU_USAGE}% ${GPU_VRAM_USAGE}%"
|
||||||
|
|
||||||
|
# Battery time: find battery device via upower and parse "time to full" / "time to empty"
|
||||||
|
# fallback to sysfs if upower not available
|
||||||
|
BAT_PATH=""
|
||||||
|
if command -v upower >/dev/null 2>&1; then
|
||||||
|
BAT_PATH=$(upower -e | grep -E "battery|BAT" | head -n1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$BAT_PATH" ]; then
|
||||||
|
# try linux sysfs battery status file
|
||||||
|
if [ -r /sys/class/power_supply/BAT0/status ]; then
|
||||||
|
BAT_STATUS_FILE="/sys/class/power_supply/BAT0/status"
|
||||||
|
else
|
||||||
|
BAT_STATUS_FILE=""
|
||||||
|
fi
|
||||||
|
BATTERY_STATUS=""
|
||||||
|
if [ -n "$BAT_STATUS_FILE" ]; then
|
||||||
|
BATTERY_STATUS=$(cat "$BAT_STATUS_FILE")
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# use upower to read battery properties
|
||||||
|
BATTERY_STATUS=$(upower -i "$BAT_PATH" | awk -F: '/state:/ {gsub(/^[ \t]+|[ \t]+$/,"",$2); print $2; exit}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BATTERY_STATUS" = "charging" ] || [ "$BATTERY_STATUS" = "Charging" ]; then
|
||||||
|
if [ -n "$BAT_PATH" ]; then
|
||||||
|
# get everything after the colon and trim
|
||||||
|
TIME_TO_FULL=$(upower -i "$BAT_PATH" | sed -n 's/^[ \t]*time to full:[ \t]*//Ip')
|
||||||
|
else
|
||||||
|
TIME_TO_FULL=""
|
||||||
|
fi
|
||||||
|
if [ -n "$TIME_TO_FULL" ]; then
|
||||||
|
echo " ${TIME_TO_FULL} to full"
|
||||||
|
else
|
||||||
|
echo " Charging"
|
||||||
|
fi
|
||||||
|
elif [ "$BATTERY_STATUS" = "discharging" ] || [ "$BATTERY_STATUS" = "Discharging" ]; then
|
||||||
|
if [ -n "$BAT_PATH" ]; then
|
||||||
|
TIME_TO_EMPTY=$(upower -i "$BAT_PATH" | sed -n 's/^[ \t]*time to empty:[ \t]*//Ip')
|
||||||
|
else
|
||||||
|
TIME_TO_EMPTY=""
|
||||||
|
fi
|
||||||
|
if [ -n "$TIME_TO_EMPTY" ]; then
|
||||||
|
echo " ${TIME_TO_EMPTY} to empty"
|
||||||
|
else
|
||||||
|
echo " Discharging"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if internet is up by pinging a reliable host
|
||||||
|
if ping -c 1 -W 1 woodburn.au > /dev/null 2>&1; then
|
||||||
|
INTERNET_STATUS="up"
|
||||||
|
else
|
||||||
|
INTERNET_STATUS="down"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get WIFI SSID if connected
|
||||||
|
WIFI_SSID=""
|
||||||
|
if command -v nmcli >/dev/null 2>&1; then
|
||||||
|
WIFI_SSID=$(nmcli -t -f active,ssid dev wifi | grep '^yes:' | cut -d: -f2)
|
||||||
|
fi
|
||||||
|
if [ -n "$WIFI_SSID" ]; then
|
||||||
|
echo " SSID: ${WIFI_SSID} (${INTERNET_STATUS})"
|
||||||
|
else
|
||||||
|
echo " Internet: ${INTERNET_STATUS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get network info for each active interface
|
||||||
|
for IFACE in $(ls /sys/class/net/ | grep -E '^(en|wl|wg|tailscale|tun)'); do
|
||||||
|
IFACE_STATE=""
|
||||||
|
# safe read operstate
|
||||||
|
if [ -r "/sys/class/net/$IFACE/operstate" ]; then
|
||||||
|
IFACE_STATE=$(cat "/sys/class/net/$IFACE/operstate")
|
||||||
|
fi
|
||||||
|
# show physical interfaces when up, and always show virtual interfaces (tailscale/wg/tun)
|
||||||
|
if [ "$IFACE_STATE" = "up" ] || [[ "$IFACE" == tailscale* ]] || [[ "$IFACE" == wg* ]] || [[ "$IFACE" == tun* ]]; then
|
||||||
|
RX_BYTES=$(cat "/sys/class/net/$IFACE/statistics/rx_bytes" 2>/dev/null || echo 0)
|
||||||
|
TX_BYTES=$(cat "/sys/class/net/$IFACE/statistics/tx_bytes" 2>/dev/null || echo 0)
|
||||||
|
RX_HR=$(numfmt --to=iec --suffix=B "$RX_BYTES")
|
||||||
|
TX_HR=$(numfmt --to=iec --suffix=B "$TX_BYTES")
|
||||||
|
|
||||||
|
echo " ${IFACE}: ${RX_HR} ${TX_HR}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
curl https://wttr.in/Canberra\?format\="%l:+%t+UV:+%u"
|
||||||
Reference in New Issue
Block a user