mirror of
https://github.com/eRgo35/dwm.git
synced 2025-12-16 05:46:09 +01:00
changed terminal and updated bar
This commit is contained in:
257
bar.sh
257
bar.sh
@@ -1,179 +1,136 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function lighten_color() {
|
||||
offset=20
|
||||
# Rosé Pine color palette
|
||||
BASE=#191724
|
||||
SURFACE=#1f1d2e
|
||||
OVERLAY=#26233a
|
||||
|
||||
hex_color=$1
|
||||
hex_color=${hex_color:1}
|
||||
MUTED=#6e6a86
|
||||
SUBTLE=#908caa
|
||||
TEXT=#e0def4
|
||||
|
||||
red=${hex_color:0:2}
|
||||
green=${hex_color:2:2}
|
||||
blue=${hex_color:4:2}
|
||||
LOVE=#eb6f92
|
||||
GOLD=#f6c177
|
||||
ROSE=#ebbcba
|
||||
PINE=#31748f
|
||||
FOAM=#9ccfd8
|
||||
IRIS=#c4a7e7
|
||||
|
||||
red_dec=$(printf "%d" 0x$red)
|
||||
green_dec=$(printf "%d" 0x$green)
|
||||
blue_dec=$(printf "%d" 0x$blue)
|
||||
HIGHLIGHT_LOW=#21202e
|
||||
HIGHLIGHT_MED=#403d52
|
||||
HIGHLIGHT_HIGH=#524f67
|
||||
|
||||
if [[ $red_dec -lt 128 ]]; then
|
||||
red_dec_l=$((red_dec+offset))
|
||||
green_dec_l=$((green_dec+offset))
|
||||
blue_dec_l=$((blue_dec+offset))
|
||||
else
|
||||
red_dec_l=$((red_dec-offset))
|
||||
green_dec_l=$((green_dec-offset))
|
||||
blue_dec_l=$((blue_dec-offset))
|
||||
fi
|
||||
# Function to get CPU usage
|
||||
get_cpu_usage() {
|
||||
cpu_usage=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print int(($2+$4-u1) * 100 / (t-t1)); }' \
|
||||
<(grep 'cpu ' /proc/stat) <(sleep 1; grep 'cpu ' /proc/stat))
|
||||
|
||||
red=$(printf "%02X" $red_dec_l)
|
||||
green=$(printf "%02X" $green_dec_l)
|
||||
blue=$(printf "%02X" $blue_dec_l)
|
||||
|
||||
echo "#$red$green$blue"
|
||||
echo "^c$FOAM^CPU: $cpu_usage%"
|
||||
}
|
||||
|
||||
# ^c$var^ = fg color
|
||||
# ^b$var^ = bg color
|
||||
# Function to get memory usage
|
||||
get_memory_usage() {
|
||||
# Extract used and total memory in kilobytes
|
||||
mem_info=$(free -k | awk '/^Mem:/ {print $3, $2}')
|
||||
used_mem=$(echo $mem_info | awk '{print $1}')
|
||||
total_mem=$(echo $mem_info | awk '{print $2}')
|
||||
|
||||
interval=0
|
||||
# Calculate memory usage percentage
|
||||
mem_percent=$(awk "BEGIN {printf \"%.0f%%\", ($used_mem / $total_mem) * 100}")
|
||||
|
||||
# load colors
|
||||
# . ~/.config/bar_themes/onedark
|
||||
|
||||
# colors
|
||||
|
||||
rosewater=#f4dbd6
|
||||
flamingo=#f0c6c6
|
||||
pink=#f5bde6
|
||||
mauve=#c6a0f6
|
||||
red=#fb4934
|
||||
maroon=#ee99a0
|
||||
peach=#f5a97f
|
||||
yellow=#eed49f
|
||||
green=#b8bb26
|
||||
teal=#8bd5ca
|
||||
sky=#91d7e3
|
||||
sapphire=#7dc4e4
|
||||
blue=#8aadf4
|
||||
lavender=#b7bdf8
|
||||
text=#cad3f5
|
||||
subtext1=#b8c0e0
|
||||
subtext0=#a5adcb
|
||||
overlay2=#939ab7
|
||||
overlay1=#8087a2
|
||||
overlay0=#6e738d
|
||||
surface2=#5b6078
|
||||
surface1=#494d64
|
||||
surface0=#363a4f
|
||||
base=#24273a
|
||||
mantle=#1e2030
|
||||
crust=#181926
|
||||
|
||||
# Special
|
||||
background=#282828
|
||||
foreground=#ebdbb2
|
||||
cursor=#ebdbb2
|
||||
|
||||
# Colors
|
||||
color0=#05090e
|
||||
color1=#425965
|
||||
color2=#016b86
|
||||
color3=#1f7284
|
||||
color4=#48717a
|
||||
color5=#358292
|
||||
color6=#79796b
|
||||
color7=#828486
|
||||
color8=#43464a
|
||||
color9=#597787
|
||||
color10=#028FB3
|
||||
color11=#2A99B1
|
||||
color12=#6097A3
|
||||
color13=#47AEC3
|
||||
color14=#A2A28F
|
||||
color15=#c0c1c2
|
||||
|
||||
background0=$(lighten_color $background)
|
||||
background1=$(lighten_color $background0)
|
||||
background2=$(lighten_color $background1)
|
||||
|
||||
pulse () {
|
||||
VOL=$(pamixer --get-volume)
|
||||
STATE=$(pamixer --get-mute)
|
||||
|
||||
printf "%s" "$SEP1"
|
||||
if [ "$STATE" = "true" ] || [ "$VOL" -eq 0 ]; then
|
||||
printf "AMUT%%"
|
||||
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
|
||||
printf "A%s%%" "$VOL"
|
||||
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
|
||||
printf "A%s%%" "$VOL"
|
||||
else
|
||||
printf "A%s%%" "$VOL"
|
||||
fi
|
||||
printf "%s\n" "$SEP2"
|
||||
# Output the result with color
|
||||
echo "^c$IRIS^MEM: $mem_percent"
|
||||
}
|
||||
|
||||
cpu() {
|
||||
cpu_val=$(grep -o "^[^ ]*" /proc/loadavg)
|
||||
# Function to get volume level
|
||||
get_volume() {
|
||||
# Get the default sink (output device) and its volume/mute status
|
||||
default_sink=$(pactl get-default-sink)
|
||||
volume=$(pactl get-sink-volume $default_sink | grep -o '[0-9]*%' | head -1)
|
||||
is_muted=$(pactl get-sink-mute $default_sink | grep -o 'yes\|no')
|
||||
|
||||
printf "^c$background^ ^b$yellow^ "
|
||||
printf "^c$background^ ^b$yellow^$cpu_val"
|
||||
# Replace "yes" with "MUT" and "no" with the volume level
|
||||
if [ "$is_muted" = "yes" ]; then
|
||||
volume="MUT"
|
||||
fi
|
||||
|
||||
# Get the default source (input device) and its volume/mute status
|
||||
default_source=$(pactl get-default-source)
|
||||
mic_level=$(pactl get-source-volume $default_source | grep -o '[0-9]*%' | head -1)
|
||||
is_mic_muted=$(pactl get-source-mute $default_source | grep -o 'yes\|no')
|
||||
|
||||
# Replace "yes" with "MUT" and "no" with the microphone level
|
||||
if [ "$is_mic_muted" = "yes" ]; then
|
||||
mic_level="MUT"
|
||||
fi
|
||||
|
||||
# Output the results with colors
|
||||
echo "^c$PINE^VOL: $volume MIC: $mic_level"
|
||||
}
|
||||
|
||||
battery() {
|
||||
capacity_0="$(cat /sys/class/power_supply/BAT0/capacity)"
|
||||
capacity_1="$(cat /sys/class/power_supply/BAT1/capacity)"
|
||||
# Function to get brightness percentage
|
||||
get_brightness() {
|
||||
# Get the current brightness level (adjust path if needed)
|
||||
brightness=$(cat /sys/class/backlight/intel_backlight/brightness)
|
||||
max_brightness=$(cat /sys/class/backlight/intel_backlight/max_brightness)
|
||||
|
||||
capacity="$capacity_0+$capacity_1"
|
||||
# capacity=$(((capacity_0 + capacity_1) / 2))
|
||||
# Calculate brightness percentage
|
||||
brightness_percent=$(awk "BEGIN {printf \"%.0f%%\", ($brightness / $max_brightness) * 100}")
|
||||
|
||||
printf " B$capacity%% "
|
||||
# Output the result with color
|
||||
echo "^c$ROSE^BRT: $brightness_percent"
|
||||
}
|
||||
|
||||
brightness() {
|
||||
value=$(cat /sys/class/backlight/*/brightness)
|
||||
percentage=$(echo "scale=2; $value / 8.54" | bc)
|
||||
printf "L%.0f%%" "$percentage"
|
||||
# Function to get weighted average battery level
|
||||
get_battery_level() {
|
||||
# Get battery levels (adjust paths if needed)
|
||||
battery0_level=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||
battery1_level=$(cat /sys/class/power_supply/BAT1/capacity)
|
||||
|
||||
battery0_energy_full=$(cat /sys/class/power_supply/BAT0/energy_full)
|
||||
battery1_energy_full=$(cat /sys/class/power_supply/BAT1/energy_full)
|
||||
|
||||
# Calculate weights based on energy capacity
|
||||
weight0=$(awk "BEGIN {printf \"%.2f\", $battery0_energy_full / ($battery0_energy_full + $battery1_energy_full)}")
|
||||
weight1=$(awk "BEGIN {printf \"%.2f\", $battery1_energy_full / ($battery0_energy_full + $battery1_energy_full)}")
|
||||
|
||||
# Calculate weighted average
|
||||
weighted_avg=$(awk "BEGIN {printf \"%.0f%%\", ($battery0_level * $weight0 + $battery1_level * $weight1)}")
|
||||
|
||||
# Output the result with color
|
||||
echo "^c$LOVE^BAT: $weighted_avg"
|
||||
}
|
||||
|
||||
mem() {
|
||||
printf "^c$background^^b$green^ "
|
||||
printf "^c$background^^b$green^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)"
|
||||
# Function to get date and time in American 12-hour format
|
||||
get_datetime() {
|
||||
datetime=$(date +"%a %d %b %I:%M %p")
|
||||
echo "^c$GOLD^$datetime"
|
||||
}
|
||||
|
||||
wlan() {
|
||||
case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in
|
||||
up) printf "^c$background^ ^b$blue^ ^c$background^ ^b$blue^Connected" ;;
|
||||
down) printf "^c$background^ ^b$blue^ ^c$background^ ^b$blue^Disconnected" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
clock() {
|
||||
printf " $(date '+%I:%M %P') "
|
||||
}
|
||||
|
||||
today() {
|
||||
printf " $(date '+%b %e') "
|
||||
}
|
||||
|
||||
net() {
|
||||
if nc -zw1 c2yz.com 443; then
|
||||
printf "^c$background^^b$green^ i "
|
||||
else
|
||||
printf "^c$background^^b$red^ ! "
|
||||
fi
|
||||
# Function to detect if the system is a laptop
|
||||
is_laptop() {
|
||||
# Check if battery and brightness files exist
|
||||
if [ -d /sys/class/power_supply/BAT0 ] && [ -d /sys/class/backlight/intel_backlight ]; then
|
||||
return 0 # Laptop
|
||||
else
|
||||
return 1 # PC
|
||||
fi
|
||||
}
|
||||
|
||||
# Main loop to update xsetroot
|
||||
while true; do
|
||||
# Combine all status components
|
||||
if is_laptop; then
|
||||
# Include battery and brightness for laptops
|
||||
status="$(get_volume) ^c$TEXT^| $(get_cpu_usage) ^c$TEXT^| $(get_memory_usage) ^c$TEXT^| $(get_brightness) ^c$TEXT^| $(get_battery_level) ^c$TEXT^| $(get_datetime)"
|
||||
else
|
||||
# Exclude battery and brightness for PCs
|
||||
status="$(get_volume) ^c$TEXT^| $(get_cpu_usage) ^c$TEXT^| $(get_memory_usage) ^c$TEXT^| $(get_datetime)"
|
||||
fi
|
||||
|
||||
# [ $interval = 0 ] || [ $(($interval % 3600)) = 0 ] && updates=$(pkg_updates)
|
||||
# interval=$((interval + 1))
|
||||
|
||||
# sleep 1 && xsetroot -name "$updates $(battery) $(brightness) $(cpu) $(mem) $(wlan) $(clock)"
|
||||
# sleep 1 && xsetroot -name "$(battery) $(brightness) $(cpu) $(mem) $(wlan) $(clock)"
|
||||
if hash dockd 2>/dev/null; then
|
||||
sleep 1 && xsetroot -name "^c$foreground^^b$background1^ $(brightness) ^b$background0^ $(battery) $(net)^c$foreground^^b$background0^ $(today) ^b$background1^ $(clock) ^b$background2^ $(pulse) "
|
||||
else
|
||||
sleep 1 && xsetroot -name "^c$foreground^$(net)^c$foreground^^b$background0^ $(today) ^b$background1^ $(clock) ^b$background2^ $(pulse) "
|
||||
fi
|
||||
# Update the root window name with a darker background
|
||||
xsetroot -name "$status"
|
||||
|
||||
# Sleep for 250 milis before updating
|
||||
sleep 0.25
|
||||
done
|
||||
|
||||
2280
config.def.h
2280
config.def.h
File diff suppressed because it is too large
Load Diff
4
rebuild.sh
Executable file
4
rebuild.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -f config.h patches.h
|
||||
make clean && make && sudo make install
|
||||
Reference in New Issue
Block a user