initial commit
This commit is contained in:
11
aarch64statusbar/colorvars.sh
Normal file
11
aarch64statusbar/colorvars.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#Colors for status bar, allows for various theme Colors
|
||||
|
||||
## Default Colors
|
||||
|
||||
black="#000000"
|
||||
white="#ffffff"
|
||||
grey="#555555"
|
||||
green="#00ff00"
|
||||
yellow="#ffff00"
|
||||
red="#ff0000"
|
||||
|
||||
55
aarch64statusbar/install.sh
Executable file
55
aarch64statusbar/install.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Function to check if a command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# DWM dependency check (uncomment if necessary)
|
||||
# if ! pgrep -x "dwm" > /dev/null; then
|
||||
# echo "DWM is not running. Please ensure that DWM is installed and is your window manager."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# Check for the status2D dependency
|
||||
if command_exists dwm; then
|
||||
echo "DWM is installed. Make sure you have the status2D patch applied for proper rendering."
|
||||
fi
|
||||
|
||||
# Required packages list
|
||||
required_packages=("grep" "gawk" "procps" "coreutils" "lm-sensors" "network-manager" "x11-xserver-utils")
|
||||
|
||||
# Install required packages
|
||||
for pkg in "${required_packages[@]}"; do
|
||||
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
|
||||
echo "Package $pkg is not installed. Installing..."
|
||||
sudo apt update
|
||||
sudo apt install -y "$pkg"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to install $pkg. Please install it manually, or its equivalent, and edit the source code."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Package $pkg is already installed."
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy statusbar.sh to /usr/local/bin and make it executable
|
||||
sudo cp statusbar.sh /usr/local/bin/statusbar
|
||||
sudo chmod +x /usr/local/bin/statusbar
|
||||
|
||||
# Create the directory and copy colorvars.sh
|
||||
PREFIX="$HOME/.local/share/statusbar"
|
||||
mkdir -p "$PREFIX"
|
||||
cp colorvars.sh "$PREFIX"
|
||||
|
||||
# Setup the systemd service
|
||||
SERVICE_DIR="$HOME/.config/systemd/user"
|
||||
mkdir -p "$SERVICE_DIR"
|
||||
cp statusbar.service "$SERVICE_DIR"
|
||||
|
||||
# Enable and restart the service
|
||||
systemctl --user enable statusbar.service
|
||||
systemctl --user restart statusbar.service
|
||||
|
||||
echo "Installation completed successfully. The statusbar is installed and the service has been enabled and restarted."
|
||||
14
aarch64statusbar/statusbar.service
Normal file
14
aarch64statusbar/statusbar.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
[Unit]
|
||||
Description=SystemBar for DWM from suckless
|
||||
After=default.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/statusbar
|
||||
Restart=on-failure
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/klein/.Xauthority
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
234
aarch64statusbar/statusbar.sh
Executable file
234
aarch64statusbar/statusbar.sh
Executable file
@@ -0,0 +1,234 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source color vars
|
||||
source "$HOME/.local/share/statusbar/colorvars.sh"
|
||||
|
||||
# Define Basic Dimentions
|
||||
base_x=0
|
||||
base_y=2
|
||||
max_height=15
|
||||
bar_width=3
|
||||
gap=1
|
||||
|
||||
cpu() {
|
||||
local cpu_line1=$(grep '^cpu ' /proc/stat)
|
||||
sleep 2
|
||||
local cpu_line2=$(grep '^cpu ' /proc/stat)
|
||||
local -a cpu1=(${cpu_line1//cpu/})
|
||||
local -a cpu2=(${cpu_line2//cpu/})
|
||||
local total1=0
|
||||
local total2=0
|
||||
local idle1=${cpu1[3]}
|
||||
local idle2=${cpu2[3]}
|
||||
for i in "${cpu1[@]}"; do
|
||||
total1=$((total1 + i))
|
||||
done
|
||||
for i in "${cpu2[@]}"; do
|
||||
total2=$((total2 + i))
|
||||
done
|
||||
local total_delta=$((total2 - total1))
|
||||
local idle_delta=$((idle2 - idle1))
|
||||
|
||||
local usage=$((100 * (total_delta - idle_delta) / total_delta))
|
||||
|
||||
local usage_height=$(( (max_height * usage) / 100 ))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
local color=$white
|
||||
if [ $usage -gt 50 ]; then
|
||||
color=$red
|
||||
fi
|
||||
local status_line=""
|
||||
status_line+="^c${grey}^^r${base_x},${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c${color}^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
status_line+="^d^^f4^" # buffer of 1
|
||||
# local topcon=$( ps -eo %cpu,comm --sort=-%cpu | head -n 2 | tail -n 1 | awk '{print $2}')
|
||||
# topcon="${topcon:0:5}" # trunkate output
|
||||
echo "{CPU:${status_line}${usage}%"
|
||||
}
|
||||
|
||||
ram() {
|
||||
local m_mem=$(free -m)
|
||||
local t_mem=$(echo "$m_mem" | awk '/^Mem:/ {print $2}')
|
||||
local u_mem=$(echo "$m_mem" | awk '/^Mem:/ {print $3}')
|
||||
local p_mem=$(awk "BEGIN {printf \"%.0f\", ($u_mem/$t_mem)*100}")
|
||||
local usage_height=$((max_height * p_mem / 100))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
local status_line=""
|
||||
status_line+="^c$grey^^r$base_x,${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c$white^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
status_line+="^d^^f4^" # buffer of 1
|
||||
status_line+="${p_mem}%"
|
||||
echo "M:$status_line"
|
||||
}
|
||||
|
||||
swap() {
|
||||
local m_swap=$(free -m)
|
||||
local t_swap=$(echo "$m_swap" | awk '/^Swap:/ {print $2}')
|
||||
local u_swap=$(echo "$m_swap" | awk '/^Swap:/ {print $3}')
|
||||
if [[ "$u_swap" -eq 0 ]]; then
|
||||
return
|
||||
fi
|
||||
local p_swap=$(awk "BEGIN {printf \"%.0f\", ($u_swap/$t_swap)*100}")
|
||||
local usage_height=$((max_height * u_swap / 100))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
local status_line=""
|
||||
status_line+="^c$grey^^r$base_x,${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c$white^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
status_line+="^d^^f4^" # buffer of 1
|
||||
status_line+="${p_swap}%"
|
||||
echo "|S:$status_line"
|
||||
}
|
||||
|
||||
disk() {
|
||||
local usage_p2=$(df -h | grep '/dev/mmcblk0p2' | awk '{print $5}' | tr -d '%')
|
||||
local usage_p4=$(df -h | grep '/dev/mmcblk0p1' | awk '{print $5}' | tr -d '%')
|
||||
if [[ ! "$usage_p2" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
usage_p2=0
|
||||
fi
|
||||
if [[ ! "$usage_p4" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
usage_p4=0
|
||||
fi
|
||||
local status_line=""
|
||||
local -A usages=(
|
||||
[p2]=$usage_p2
|
||||
[p4]=$usage_p4
|
||||
)
|
||||
for partition in p2 p4; do
|
||||
local percentage=${usages[$partition]}
|
||||
local usage_height=$(($percentage * $max_height / 100))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
status_line+="^c$grey^^r${base_x},${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c$white^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
base_x=$((base_x + bar_width + gap))
|
||||
done
|
||||
status_line+="^d^^f8^" #Buffer of 1
|
||||
echo "DF:${status_line}R:${usage_p2}%-U:${usage_p4}%"
|
||||
}
|
||||
|
||||
cpu_temperature(){
|
||||
local temp=$(awk '{print int($1 / 1000)}' /sys/class/thermal/thermal_zone0/temp)
|
||||
local max_temp=80
|
||||
local color=$white
|
||||
if [ "$temp" -gt "$max_temp" ]; then
|
||||
color=$red
|
||||
elif [ "$temp" -lt "$max_temp" ]; then
|
||||
color=$green
|
||||
fi
|
||||
local adj_y=5
|
||||
local usage_height=$(($temp * $max_height / $max_temp))
|
||||
local usage_y=$((adj_y + 10 - usage_height))
|
||||
local temp_icon="^c$black^"
|
||||
temp_icon+="^r2,${base_y},5,${max_height}^" #BG bar
|
||||
temp_icon+="^c$color^"
|
||||
temp_icon+="^r3,${usage_y},3,${usage_height}^" #C bar
|
||||
temp_icon+="^c$black^"
|
||||
temp_icon+="^r1,11,8,5^" #two rectangles
|
||||
temp_icon+="^r2,10,6,7^" #to mimic a circle
|
||||
temp_icon+="^d^^f11^" #Buffer of 1
|
||||
echo "${temp_icon}${temp}°C"
|
||||
}
|
||||
|
||||
battery() {
|
||||
local throttled=$(cat /sys/devices/platform/soc/soc:firmware/get_throttled)
|
||||
local capacity=0
|
||||
local status=""
|
||||
|
||||
if [ $((throttled & 0x1)) -ne 0 ]; then
|
||||
status+="Under-voltage detected"
|
||||
fi
|
||||
if [ $((throttled & 0x2)) -ne 0 ]; then
|
||||
status+="ARM frequency capped"
|
||||
fi
|
||||
if [ $((throttled & 0x4)) -ne 0 ]; then
|
||||
status+="Currently throttled"
|
||||
fi
|
||||
if [ $((throttled & 0x8)) -ne 0 ]; then
|
||||
status+="Soft temperature limit active"
|
||||
fi
|
||||
if [ $((throttled & 0x10000)) -ne 0 ]; then
|
||||
status+="Under-voltage has occurred since last reboot"
|
||||
fi
|
||||
if [ $((throttled & 0x20000)) -ne 0 ]; then
|
||||
status+="ARM frequency capped has occurred since last reboot"
|
||||
fi
|
||||
if [ $((throttled & 0x40000)) -ne 0 ]; then
|
||||
status+="Throttling has occurred since last reboot"
|
||||
fi
|
||||
if [ $((throttled & 0x80000)) -ne 0 ]; then
|
||||
status+="Soft temperature limit has occurred since last reboot"
|
||||
fi
|
||||
|
||||
if [ "$throttled" -eq 0 ]; then
|
||||
status+="No issues detected"
|
||||
capacity=100
|
||||
fi
|
||||
|
||||
# Check the core voltage using vcgencmd
|
||||
local volt=$(vcgencmd measure_volts core | awk -F'=' '{print $2}')
|
||||
local fill_width=$(($capacity * 9 / 100)) # corresponds to width of bar
|
||||
local battery_icon="^c$black^"
|
||||
battery_icon+="^r1,6,13,8^"
|
||||
battery_icon+="^c$grey^"
|
||||
battery_icon+="^r3,8,9,4^"
|
||||
battery_icon+="^c$green^"
|
||||
battery_icon+="^r3,8,$fill_width,4^"
|
||||
battery_icon+="^c$black^"
|
||||
battery_icon+="^r14,7,2,4^"
|
||||
battery_icon+="^d^^f17^" #Buffer of 1
|
||||
echo "${battery_icon}${volt}"
|
||||
}
|
||||
|
||||
wifi() {
|
||||
local iface=$(ip -o link show | grep -v "lo:" | awk -F': ' '{print $2}');
|
||||
local ssid=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d':' -f2)
|
||||
ssid="${ssid:-No WiFi}"
|
||||
ssid="${ssid:0:5}"
|
||||
local dwm=$(grep "$iface" /proc/net/wireless | awk '{ print int($4) }')
|
||||
if [ "$ssid" = "No WiFi" ]; then
|
||||
local signal=0
|
||||
else
|
||||
local signal_normalized=$(( (dwm + 90) * 100 / 60 ))
|
||||
if [ $signal_normalized -gt 100 ]; then
|
||||
signal=100
|
||||
elif [ $signal_normalized -lt 0 ]; then
|
||||
signal=0
|
||||
else
|
||||
signal=$signal_normalized
|
||||
fi
|
||||
fi
|
||||
|
||||
local color=$white
|
||||
if [ $signal -ge 66 ]; then
|
||||
color=$green
|
||||
elif [ $signal -le 33 ]; then
|
||||
color=$red
|
||||
elif [ $signal -gt 33 ] && [ $signal -lt 66 ]; then
|
||||
color=$yellow
|
||||
fi
|
||||
|
||||
local max_bars=5
|
||||
local bars_filled=$((signal / 20))
|
||||
|
||||
local wifi_icon="^c$color^"
|
||||
for i in 1 2 3 4 5; do
|
||||
local width=$(( (2 * i + 1) ))
|
||||
local height=$(( (2 * i + 1) ))
|
||||
local adj_y=$((max_height - height))
|
||||
if [ $i -le $bars_filled ]; then
|
||||
wifi_icon+="^c$color^"
|
||||
else
|
||||
wifi_icon+="^c$grey^"
|
||||
fi
|
||||
wifi_icon+="^r$((base_x + 2 * ( i - 3 ))),$((adj_y + 1)),$width,$height^"
|
||||
done
|
||||
wifi_icon+="^d^^f7^"
|
||||
|
||||
echo " ${wifi_icon}${ssid} ${signal}%}"
|
||||
}
|
||||
status(){
|
||||
echo "$(cpu)|$(ram)|$(swap)$(disk)|$(cpu_temperature)|$(battery)|$(wifi)"
|
||||
}
|
||||
while true; do
|
||||
DISPLAY=:0
|
||||
xsetroot -name "$(status)"
|
||||
done
|
||||
Reference in New Issue
Block a user