Working on dwlb
This commit is contained in:
60
home/.local/usr/bin/dwlb-status.sh
Executable file
60
home/.local/usr/bin/dwlb-status.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
# dwlb status script for system information
|
||||
# This script runs in a loop and updates the dwlb status bar
|
||||
|
||||
# Get all available outputs
|
||||
get_outputs() {
|
||||
wlr-randr | grep '^[^ ]' | cut -d' ' -f1
|
||||
}
|
||||
|
||||
while true; do
|
||||
# Get current time
|
||||
TIME=$(date '+%H:%M:%S')
|
||||
DATE=$(date '+%a %b %d')
|
||||
|
||||
# Get battery info if available
|
||||
BATTERY=""
|
||||
if [ -f /sys/class/power_supply/BAT*/capacity ]; then
|
||||
BAT_LEVEL=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null | head -1)
|
||||
BAT_STATUS=$(cat /sys/class/power_supply/BAT*/status 2>/dev/null | head -1)
|
||||
if [ -n "$BAT_LEVEL" ]; then
|
||||
case "$BAT_STATUS" in
|
||||
"Charging") BAT_ICON="🔌" ;;
|
||||
"Discharging") BAT_ICON="🔋" ;;
|
||||
"Full") BAT_ICON="🔋" ;;
|
||||
*) BAT_ICON="🔋" ;;
|
||||
esac
|
||||
BATTERY=" ${BAT_ICON}${BAT_LEVEL}%"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get CPU usage
|
||||
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}' 2>/dev/null || echo "")
|
||||
if [ -n "$CPU_USAGE" ]; then
|
||||
CPU=" 💻${CPU_USAGE}"
|
||||
else
|
||||
CPU=""
|
||||
fi
|
||||
|
||||
# Get memory usage
|
||||
MEM_INFO=$(free | grep Mem)
|
||||
if [ -n "$MEM_INFO" ]; then
|
||||
MEM_USED=$(echo $MEM_INFO | awk '{printf "%.1f", $3/1024/1024}')
|
||||
MEM_TOTAL=$(echo $MEM_INFO | awk '{printf "%.1f", $2/1024/1024}')
|
||||
MEMORY=" 🧠${MEM_USED}/${MEM_TOTAL}GB"
|
||||
else
|
||||
MEMORY=""
|
||||
fi
|
||||
|
||||
# Combine status
|
||||
STATUS="${BATTERY}${CPU}${MEMORY} 📅 ${DATE} 🕒 ${TIME}"
|
||||
|
||||
# Send to dwlb for all outputs
|
||||
for output in $(get_outputs); do
|
||||
dwlb -status "$output" "$STATUS" 2>/dev/null
|
||||
done
|
||||
|
||||
# Update every 5 seconds
|
||||
sleep 5
|
||||
done
|
||||
8
home/.local/usr/bin/dwlb.sh
Executable file
8
home/.local/usr/bin/dwlb.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
for output in $(wlr-randr | grep '^[^ ]' | cut -d' ' -f1); do
|
||||
dwlb -middle-bg-color '#16181a' -active-fg-color '#ffffff' \
|
||||
-active-bg-color '#5ea1ff' -inactive-fg-color '#ffffff' \
|
||||
-inactive-bg-color '#3c4048' -urgent-fg-color '#ffffff' \
|
||||
-urgent-bg-color '#ff6e5e' -font 'FiraCode Nerd Font Mono:size=10' &
|
||||
done
|
||||
Reference in New Issue
Block a user