mirror of
https://github.com/eRgo35/dwm.git
synced 2026-02-04 11:36:11 +01:00
Compare commits
7 Commits
7b00729d64
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| f02c5dbc0b | |||
| ab9f2e41a5 | |||
| 7b365e95a7 | |||
| d400b7b0e9 | |||
| e965863d95 | |||
| 66fa978463 | |||
| e63c8cbfd4 |
143
bar.sh
143
bar.sh
@@ -1,24 +1,97 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Rosé Pine color palette
|
# Global variables for theme tracking
|
||||||
BASE=#191724
|
CURRENT_THEME=""
|
||||||
SURFACE=#1f1d2e
|
THEME_FILE="$HOME/.current_theme"
|
||||||
OVERLAY=#26233a
|
LAST_MTIME=0
|
||||||
|
|
||||||
MUTED=#6e6a86
|
# Function to read current theme from file
|
||||||
SUBTLE=#908caa
|
get_current_theme() {
|
||||||
TEXT=#e0def4
|
if [ -f "$THEME_FILE" ]; then
|
||||||
|
cat "$THEME_FILE" 2>/dev/null || echo "dark"
|
||||||
|
else
|
||||||
|
echo "dark" # default to dark theme
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
LOVE=#eb6f92
|
# Function to check if theme file has been modified
|
||||||
GOLD=#f6c177
|
theme_file_changed() {
|
||||||
ROSE=#ebbcba
|
if [ -f "$THEME_FILE" ]; then
|
||||||
PINE=#31748f
|
local current_mtime=$(stat -c %Y "$THEME_FILE" 2>/dev/null || echo 0)
|
||||||
FOAM=#9ccfd8
|
if [ "$current_mtime" -gt "$LAST_MTIME" ]; then
|
||||||
IRIS=#c4a7e7
|
LAST_MTIME="$current_mtime"
|
||||||
|
return 0 # File was modified
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 1 # No change
|
||||||
|
}
|
||||||
|
|
||||||
HIGHLIGHT_LOW=#21202e
|
# Function to update theme if changed
|
||||||
HIGHLIGHT_MED=#403d52
|
update_theme_if_changed() {
|
||||||
HIGHLIGHT_HIGH=#524f67
|
if theme_file_changed; then
|
||||||
|
local new_theme=$(get_current_theme)
|
||||||
|
if [ "$new_theme" != "$CURRENT_THEME" ]; then
|
||||||
|
CURRENT_THEME="$new_theme"
|
||||||
|
set_colors
|
||||||
|
echo "Bar theme changed to: $CURRENT_THEME" >&2
|
||||||
|
return 0 # Theme was updated
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 1 # No update
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to set color palette based on theme
|
||||||
|
set_colors() {
|
||||||
|
if [ "$CURRENT_THEME" = "light" ]; then
|
||||||
|
# Rosé Pine Dawn (light) color palette
|
||||||
|
BASE=#faf4ed
|
||||||
|
SURFACE=#fffaf3
|
||||||
|
OVERLAY=#f2e9e1
|
||||||
|
|
||||||
|
MUTED=#9893a5
|
||||||
|
SUBTLE=#797593
|
||||||
|
TEXT=#575279
|
||||||
|
|
||||||
|
LOVE=#b4637a
|
||||||
|
GOLD=#ea9d34
|
||||||
|
ROSE=#d7827e
|
||||||
|
PINE=#286983
|
||||||
|
FOAM=#56949f
|
||||||
|
IRIS=#907aa9
|
||||||
|
|
||||||
|
HIGHLIGHT_LOW=#f4ede8
|
||||||
|
HIGHLIGHT_MED=#dfdad9
|
||||||
|
HIGHLIGHT_HIGH=#cecacd
|
||||||
|
else
|
||||||
|
# Rosé Pine (dark) color palette - default
|
||||||
|
BASE=#191724
|
||||||
|
SURFACE=#1f1d2e
|
||||||
|
OVERLAY=#26233a
|
||||||
|
|
||||||
|
MUTED=#6e6a86
|
||||||
|
SUBTLE=#908caa
|
||||||
|
TEXT=#e0def4
|
||||||
|
|
||||||
|
LOVE=#eb6f92
|
||||||
|
GOLD=#f6c177
|
||||||
|
ROSE=#ebbcba
|
||||||
|
PINE=#31748f
|
||||||
|
FOAM=#9ccfd8
|
||||||
|
IRIS=#c4a7e7
|
||||||
|
|
||||||
|
HIGHLIGHT_LOW=#21202e
|
||||||
|
HIGHLIGHT_MED=#403d52
|
||||||
|
HIGHLIGHT_HIGH=#524f67
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Initialize theme
|
||||||
|
CURRENT_THEME=$(get_current_theme)
|
||||||
|
if [ -f "$THEME_FILE" ]; then
|
||||||
|
LAST_MTIME=$(stat -c %Y "$THEME_FILE" 2>/dev/null || echo 0)
|
||||||
|
fi
|
||||||
|
set_colors
|
||||||
|
echo "Bar started with theme: $CURRENT_THEME" >&2
|
||||||
|
|
||||||
# Function to get CPU usage
|
# Function to get CPU usage
|
||||||
get_cpu_usage() {
|
get_cpu_usage() {
|
||||||
@@ -83,6 +156,37 @@ get_brightness() {
|
|||||||
|
|
||||||
# Function to get weighted average battery level
|
# Function to get weighted average battery level
|
||||||
get_battery_level() {
|
get_battery_level() {
|
||||||
|
BAT_PATHS=(/sys/class/power_supply/BAT*)
|
||||||
|
|
||||||
|
total_now=0
|
||||||
|
total_full=0
|
||||||
|
|
||||||
|
for BAT in "${BAT_PATHS[@]}"; do
|
||||||
|
if [[ -f "$BAT/energy_now" && -f "$BAT/energy_full" ]]; then
|
||||||
|
now=$(<"$BAT/energy_now")
|
||||||
|
full=$(<"$BAT/energy_full")
|
||||||
|
elif [[ -f "$BAT/charge_now" && -f "$BAT/charge_full" ]]; then
|
||||||
|
now=$(<"$BAT/charge_now")
|
||||||
|
full=$(<"$BAT/charge_full")
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
total_now=$((total_now + now))
|
||||||
|
total_full=$((total_full + full))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $total_full -eq 0 ]]; then
|
||||||
|
percent=0
|
||||||
|
else
|
||||||
|
percent=$((100 * total_now / total_full))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( percent < 15 )); then
|
||||||
|
echo "^c$TEXT^^b$LOVE^BAT: $percent%^b$BASE^"
|
||||||
|
else
|
||||||
|
echo "^c$LOVE^BAT: $percent%"
|
||||||
|
fi
|
||||||
# Get battery levels (adjust paths if needed)
|
# Get battery levels (adjust paths if needed)
|
||||||
# battery0_level=$(cat /sys/class/power_supply/BAT0/capacity)
|
# battery0_level=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
# battery1_level=$(cat /sys/class/power_supply/BAT1/capacity)
|
# battery1_level=$(cat /sys/class/power_supply/BAT1/capacity)
|
||||||
@@ -96,8 +200,8 @@ get_battery_level() {
|
|||||||
|
|
||||||
# Calculate weighted average
|
# Calculate weighted average
|
||||||
# weighted_avg=$(awk "BEGIN {printf \"%.0f%%\", ($battery0_level * $weight0 + $battery1_level * $weight1)}")
|
# weighted_avg=$(awk "BEGIN {printf \"%.0f%%\", ($battery0_level * $weight0 + $battery1_level * $weight1)}")
|
||||||
battery0_level=$(cat /sys/class/power_supply/BAT0/capacity)
|
# battery0_level=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
echo "^c$LOVE^BAT: $battery0_level%"
|
# echo "^c$LOVE^BAT: $battery0_level%"
|
||||||
|
|
||||||
# Output the result with color
|
# Output the result with color
|
||||||
# echo "^c$LOVE^BAT: $weighted_avg"
|
# echo "^c$LOVE^BAT: $weighted_avg"
|
||||||
@@ -121,6 +225,9 @@ is_laptop() {
|
|||||||
|
|
||||||
# Main loop to update xsetroot
|
# Main loop to update xsetroot
|
||||||
while true; do
|
while true; do
|
||||||
|
# Check for theme changes on every iteration
|
||||||
|
update_theme_if_changed
|
||||||
|
|
||||||
# Combine all status components
|
# Combine all status components
|
||||||
if is_laptop; then
|
if is_laptop; then
|
||||||
# Include battery and brightness for laptops
|
# Include battery and brightness for laptops
|
||||||
|
|||||||
25
config.def.h
25
config.def.h
@@ -70,7 +70,8 @@ static const int topbar = 1; /* 0 means bottom bar */
|
|||||||
/* Display modes of the tab bar: never shown, always shown, shown only in */
|
/* Display modes of the tab bar: never shown, always shown, shown only in */
|
||||||
/* monocle mode in the presence of several windows. */
|
/* monocle mode in the presence of several windows. */
|
||||||
/* Modes after showtab_nmodes are disabled. */
|
/* Modes after showtab_nmodes are disabled. */
|
||||||
enum showtab_modes {
|
enum showtab_modes
|
||||||
|
{
|
||||||
showtab_never,
|
showtab_never,
|
||||||
showtab_auto,
|
showtab_auto,
|
||||||
showtab_nmodes,
|
showtab_nmodes,
|
||||||
@@ -382,10 +383,14 @@ static const char title_bg_dark[] = "#303030";
|
|||||||
static const char title_bg_light[] = "#fdfdfd";
|
static const char title_bg_light[] = "#fdfdfd";
|
||||||
static const int color_ptrs[][ColCount] = {
|
static const int color_ptrs[][ColCount] = {
|
||||||
/* fg bg border float */
|
/* fg bg border float */
|
||||||
[SchemeNorm] = {-1, -1, 5, 12}, [SchemeSel] = {-1, -1, 11, 13},
|
[SchemeNorm] = {-1, -1, 5, 12},
|
||||||
[SchemeTitleNorm] = {6, -1, -1, -1}, [SchemeTitleSel] = {6, -1, -1, -1},
|
[SchemeSel] = {-1, -1, 11, 13},
|
||||||
[SchemeTagsNorm] = {2, 0, 0, -1}, [SchemeTagsSel] = {6, 5, 5, -1},
|
[SchemeTitleNorm] = {6, -1, -1, -1},
|
||||||
[SchemeHidNorm] = {5, 0, 0, -1}, [SchemeHidSel] = {6, -1, -1, -1},
|
[SchemeTitleSel] = {6, -1, -1, -1},
|
||||||
|
[SchemeTagsNorm] = {2, 0, 0, -1},
|
||||||
|
[SchemeTagsSel] = {6, 5, 5, -1},
|
||||||
|
[SchemeHidNorm] = {5, 0, 0, -1},
|
||||||
|
[SchemeHidSel] = {6, -1, -1, -1},
|
||||||
[SchemeUrg] = {7, 9, 9, 15},
|
[SchemeUrg] = {7, 9, 9, 15},
|
||||||
};
|
};
|
||||||
#endif // BAR_VTCOLORS_PATCH
|
#endif // BAR_VTCOLORS_PATCH
|
||||||
@@ -906,10 +911,6 @@ static const Layout layouts[] = {
|
|||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
#if TILE_LAYOUT
|
#if TILE_LAYOUT
|
||||||
{"[]=", tile}, /* first entry is default */
|
{"[]=", tile}, /* first entry is default */
|
||||||
#endif
|
|
||||||
{"><>", NULL}, /* no layout function means floating behavior */
|
|
||||||
#if MONOCLE_LAYOUT
|
|
||||||
{"[M]", monocle},
|
|
||||||
#endif
|
#endif
|
||||||
#if BSTACK_LAYOUT
|
#if BSTACK_LAYOUT
|
||||||
{"TTT", bstack},
|
{"TTT", bstack},
|
||||||
@@ -947,6 +948,10 @@ static const Layout layouts[] = {
|
|||||||
#if NROWGRID_LAYOUT
|
#if NROWGRID_LAYOUT
|
||||||
{"###", nrowgrid},
|
{"###", nrowgrid},
|
||||||
#endif
|
#endif
|
||||||
|
#if MONOCLE_LAYOUT
|
||||||
|
{"[M]", monocle},
|
||||||
|
#endif
|
||||||
|
{"><>", NULL}, /* no layout function means floating behavior */
|
||||||
};
|
};
|
||||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||||
|
|
||||||
@@ -1689,6 +1694,8 @@ static const Key keys[] = {
|
|||||||
#if CYCLELAYOUTS_PATCH
|
#if CYCLELAYOUTS_PATCH
|
||||||
{MODKEY | ControlMask, XK_comma, cyclelayout, {.i = -1}},
|
{MODKEY | ControlMask, XK_comma, cyclelayout, {.i = -1}},
|
||||||
{MODKEY | ControlMask, XK_period, cyclelayout, {.i = +1}},
|
{MODKEY | ControlMask, XK_period, cyclelayout, {.i = +1}},
|
||||||
|
{MODKEY, XK_grave, cyclelayout, {.i = +1}},
|
||||||
|
{MODKEY | ShiftMask, XK_grave, cyclelayout, {.i = -1}},
|
||||||
#endif // CYCLELAYOUTS_PATCH
|
#endif // CYCLELAYOUTS_PATCH
|
||||||
#if MPDCONTROL_PATCH
|
#if MPDCONTROL_PATCH
|
||||||
{MODKEY, XK_F1, mpdchange, {.i = -1}},
|
{MODKEY, XK_F1, mpdchange, {.i = -1}},
|
||||||
|
|||||||
0
patch/dwmc
Executable file → Normal file
0
patch/dwmc
Executable file → Normal file
0
patch/layoutmenu.sh
Executable file → Normal file
0
patch/layoutmenu.sh
Executable file → Normal file
977
patches.def.h
977
patches.def.h
File diff suppressed because it is too large
Load Diff
0
rebuild.sh
Executable file → Normal file
0
rebuild.sh
Executable file → Normal file
Reference in New Issue
Block a user