feat: improve session switching, fractional DPI/GTK theming, XDG launcher, CPU/RAM status, and power policy
This commit is contained in:
1 parent
72b05b650e
commit
07d9134d2d
28 files changed
+2670
-302
No files matched your search
+135
-45
@@ -39,7 +39,7 @@ xres_get() {
|
||||
}
|
||||
|
||||
TNAME="$(xres_get theme.name "AnodeDefault")"
|
||||
DARK="$(xres_get theme.isDark "1")"
|
||||
DARK="$(xres_get theme.isDark "")"
|
||||
FONT_FACE="$(xres_get theme.fontFace "Fira Code")"
|
||||
BASE_SZ="$(xres_get theme.baseFontSize "15")"
|
||||
SCALE="$(xres_get theme.scale "1.00")"
|
||||
@@ -73,24 +73,46 @@ DANGER="$(xres_get theme.danger "#f07178")"
|
||||
|
||||
THEME_ID="ANODE-$TNAME"
|
||||
|
||||
CALC="$(awk -v s="$SCALE" -v bsz="$BASE_SZ" -v dark="$DARK" 'BEGIN {
|
||||
CALC="$(awk -v s="$SCALE" -v bsz="$BASE_SZ" -v dark="$DARK" -v bg="$BG_MAIN" -v cur="$CUR_SZ" '
|
||||
function hex_byte(h, hi, lo) {
|
||||
hi = index("0123456789abcdef", substr(h, 1, 1)) - 1
|
||||
lo = index("0123456789abcdef", substr(h, 2, 1)) - 1
|
||||
if (hi < 0 || lo < 0) return -1
|
||||
return hi * 16 + lo
|
||||
}
|
||||
function bg_is_dark(bghex, hs, r, g, b, lum) {
|
||||
hs = tolower(bghex)
|
||||
gsub(/^#/, "", hs)
|
||||
if (length(hs) == 6) {
|
||||
r = hex_byte(substr(hs, 1, 2))
|
||||
g = hex_byte(substr(hs, 3, 2))
|
||||
b = hex_byte(substr(hs, 5, 2))
|
||||
if (r >= 0 && g >= 0 && b >= 0) {
|
||||
lum = 0.299 * r + 0.587 * g + 0.114 * b
|
||||
return (lum < 128.0) ? 1 : 0
|
||||
}
|
||||
}
|
||||
return 1
|
||||
}
|
||||
BEGIN {
|
||||
sc = s + 0.0
|
||||
if (sc < 0.50) sc = 0.50
|
||||
if (sc > 4.00) sc = 4.00
|
||||
gdk_sc = (sc < 1.75) ? 1 : int(sc + 0.5)
|
||||
# Effective GTK logical scale multiplier when GDK_SCALE=1 vs 2
|
||||
eff = sc / gdk_sc
|
||||
if (eff < 0.5) eff = 0.5
|
||||
pt = int(((bsz + 0.0) * 0.72 / gdk_sc) + 0.5)
|
||||
logical_px = (bsz + 0.0) / sc
|
||||
pt = int((logical_px * 0.65) + 0.5)
|
||||
if (pt < 7) pt = 7
|
||||
if (pt > 24) pt = 24
|
||||
btn_pv = int(6.0 * eff + 0.5); if (btn_pv < 3) btn_pv = 3
|
||||
btn_ph = int(12.0 * eff + 0.5); if (btn_ph < 6) btn_ph = 6
|
||||
rad = int(6.0 * eff + 0.5); if (rad < 3) rad = 3
|
||||
row_h = int(28.0 * eff + 0.5); if (row_h < 20) row_h = 20
|
||||
sb_w = int(12.0 * eff + 0.5); if (sb_w < 8) sb_w = 8
|
||||
is_d = (dark == "1" || dark == "true") ? 1 : 0
|
||||
printf "%d %d %d %d %d %d %d %d\n", gdk_sc, pt, btn_pv, btn_ph, rad, row_h, sb_w, is_d
|
||||
if (pt > 22) pt = 22
|
||||
btn_pv = 3
|
||||
btn_ph = 8
|
||||
rad = 4
|
||||
row_h = 24
|
||||
sb_w = 8
|
||||
if (dark == "1" || tolower(dark) == "true") is_d = 1
|
||||
else if (dark == "0" || tolower(dark) == "false") is_d = 0
|
||||
else is_d = bg_is_dark(bg)
|
||||
gtk_cur = int(((cur + 0.0) / gdk_sc) + 0.5); if (gtk_cur < 16) gtk_cur = 16
|
||||
printf "%d %d %d %d %d %d %d %d %d\n", gdk_sc, pt, btn_pv, btn_ph, rad, row_h, sb_w, is_d, gtk_cur
|
||||
}')"
|
||||
set -- $CALC
|
||||
GDK_SCALE_VAL="$1"
|
||||
@@ -101,6 +123,7 @@ RAD_PX="$5"
|
||||
ROW_H="$6"
|
||||
SB_W="$7"
|
||||
IS_DARK="$8"
|
||||
GTK_CUR_SZ="$9"
|
||||
|
||||
GTK_FONT="$FONT_FACE $GTK_PT"
|
||||
|
||||
@@ -134,7 +157,17 @@ style "anode-default" {
|
||||
text[SELECTED] = "$SEL_FG"
|
||||
text[INSENSITIVE] = "$FG_MUTED"
|
||||
}
|
||||
style "anode-menu" {
|
||||
xthickness = 4
|
||||
ythickness = 4
|
||||
GtkMenu::horizontal-padding = 2
|
||||
GtkMenu::vertical-padding = 4
|
||||
GtkMenuItem::horizontal-padding = 6
|
||||
GtkMenuBar::internal-padding = 2
|
||||
}
|
||||
class "GtkWidget" style "anode-default"
|
||||
class "GtkMenu" style "anode-menu"
|
||||
widget_class "*<GtkMenuItem>*" style "anode-menu"
|
||||
EOF
|
||||
mv -f "$GTK2_DIR/gtkrc.tmp.$$" "$GTK2_DIR/gtkrc"
|
||||
|
||||
@@ -158,8 +191,30 @@ mkdir -p "$GTK3_THEME_DIR" "$GTK4_THEME_DIR" "$GTK3_CONF_DIR" "$GTK4_CONF_DIR"
|
||||
write_gtk_css() {
|
||||
_dest="$1"
|
||||
_is4="$2"
|
||||
_user_override="$3"
|
||||
_force_dark="$4"
|
||||
_tmp="${_dest}.tmp.$$"
|
||||
cat > "$_tmp" <<EOF
|
||||
_use_dark="$IS_DARK"
|
||||
if [ "$_force_dark" = "1" ]; then
|
||||
_use_dark="1"
|
||||
fi
|
||||
: > "$_tmp"
|
||||
if [ "$_user_override" = "0" ]; then
|
||||
if [ "$_is4" = "1" ]; then
|
||||
if [ "$_use_dark" = "1" ]; then
|
||||
printf '@import url("resource:///org/gtk/libgtk/theme/Default/Default-dark.css");\n' > "$_tmp"
|
||||
else
|
||||
printf '@import url("resource:///org/gtk/libgtk/theme/Default/Default-light.css");\n' > "$_tmp"
|
||||
fi
|
||||
else
|
||||
if [ "$_use_dark" = "1" ]; then
|
||||
printf '@import url("resource:///org/gtk/libgtk/theme/Adwaita/gtk-contained-dark.css");\n' > "$_tmp"
|
||||
else
|
||||
printf '@import url("resource:///org/gtk/libgtk/theme/Adwaita/gtk-contained.css");\n' > "$_tmp"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
cat >> "$_tmp" <<EOF
|
||||
/* ANODE GTK theme ($THEME_ID, scale=$SCALE) */
|
||||
@define-color theme_bg_color $BG_MAIN;
|
||||
@define-color theme_fg_color $FG_MAIN;
|
||||
@@ -167,10 +222,15 @@ write_gtk_css() {
|
||||
@define-color theme_text_color $FG_BRIGHT;
|
||||
@define-color theme_selected_bg_color $SEL_BG;
|
||||
@define-color theme_selected_fg_color $SEL_FG;
|
||||
@define-color theme_unfocused_bg_color $BG_MAIN;
|
||||
@define-color theme_unfocused_fg_color $FG_MUTED;
|
||||
@define-color theme_unfocused_base_color $BG_ALT_EVEN;
|
||||
@define-color theme_unfocused_text_color $FG_MAIN;
|
||||
@define-color insensitive_bg_color $BG_ALT_EVEN;
|
||||
@define-color insensitive_fg_color $FG_MUTED;
|
||||
@define-color insensitive_base_color $BG_ALT_EVEN;
|
||||
@define-color borders $BORDER;
|
||||
@define-color unfocused_borders $DIVIDER;
|
||||
@define-color accent_bg_color $SEL_BG;
|
||||
@define-color accent_fg_color $SEL_FG;
|
||||
@define-color accent_color $ACCENT;
|
||||
@@ -186,61 +246,89 @@ write_gtk_css() {
|
||||
@define-color dialog_fg_color $FG_MAIN;
|
||||
@define-color popover_bg_color $BG_OVERLAY;
|
||||
@define-color popover_fg_color $FG_MAIN;
|
||||
@define-color content_view_bg $BG_ALT_EVEN;
|
||||
@define-color text_view_bg $BG_INPUT;
|
||||
@define-color success_color $SUCCESS;
|
||||
@define-color warning_color $WARNING;
|
||||
@define-color error_color $DANGER;
|
||||
EOF
|
||||
if [ "$_user_override" = "0" ]; then
|
||||
cat >> "$_tmp" <<EOF
|
||||
|
||||
window, .background, messagedialog {
|
||||
window, .background, messagedialog, dialog {
|
||||
background-color: $BG_MAIN;
|
||||
color: $FG_MAIN;
|
||||
font-family: "$FONT_FACE", sans-serif;
|
||||
}
|
||||
|
||||
headerbar, .titlebar {
|
||||
headerbar, .titlebar, menubar, toolbar {
|
||||
background-color: $BG_HEADER;
|
||||
color: $FG_BRIGHT;
|
||||
border-bottom: 1px solid $DIVIDER;
|
||||
min-height: ${ROW_H}px;
|
||||
border-color: $DIVIDER;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: $BG_BUTTON;
|
||||
color: $FG_BRIGHT;
|
||||
border: 1px solid $BORDER;
|
||||
border-radius: ${RAD_PX}px;
|
||||
padding: ${PAD_V}px ${PAD_H}px;
|
||||
menu, .menu, .context-menu, popover, popover.background {
|
||||
background-color: $BG_OVERLAY;
|
||||
color: $FG_MAIN;
|
||||
border-color: $BORDER;
|
||||
}
|
||||
button:hover {
|
||||
menu menuitem:hover, .menu menuitem:hover, menubar > menuitem:hover, popover modelbutton:hover {
|
||||
background-color: $SEL_BG;
|
||||
color: $SEL_FG;
|
||||
}
|
||||
|
||||
button:not(.flat) {
|
||||
background-color: $BG_BUTTON;
|
||||
background-image: none;
|
||||
color: $FG_BRIGHT;
|
||||
border-color: $BORDER;
|
||||
}
|
||||
button:not(.flat):hover {
|
||||
background-color: $BG_OVERLAY;
|
||||
border-color: $ACCENT;
|
||||
}
|
||||
button:checked, button.suggested-action {
|
||||
button:not(.flat):checked, button:not(.flat):active, button.suggested-action {
|
||||
background-color: $SEL_BG;
|
||||
background-image: none;
|
||||
color: $SEL_FG;
|
||||
border-color: $ACCENT;
|
||||
}
|
||||
button.flat:not(:hover):not(:checked):not(:active) {
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
entry, spinbutton, combobox button {
|
||||
entry, textview, textview text, .view, treeview.view, list, listbox {
|
||||
background-color: $BG_INPUT;
|
||||
color: $FG_BRIGHT;
|
||||
border: 1px solid $BORDER;
|
||||
border-radius: ${RAD_PX}px;
|
||||
padding: ${PAD_V}px;
|
||||
border-color: $BORDER;
|
||||
}
|
||||
entry:focus {
|
||||
background-color: $BG_INPUT_FOC;
|
||||
border-color: $ACCENT;
|
||||
}
|
||||
|
||||
row:selected, .view:selected, treeview.view:selected, *:selected {
|
||||
row:selected, .view:selected, treeview.view:selected, *:selected, selection {
|
||||
background-color: $SEL_BG;
|
||||
color: $SEL_FG;
|
||||
}
|
||||
|
||||
notebook header, notebook tab {
|
||||
background-color: $BG_HEADER;
|
||||
color: $FG_MAIN;
|
||||
border-color: $DIVIDER;
|
||||
}
|
||||
notebook tab:checked {
|
||||
background-color: $BG_MAIN;
|
||||
color: $FG_BRIGHT;
|
||||
border-color: $ACCENT;
|
||||
}
|
||||
|
||||
frame > border, scrolledwindow.frame, separator {
|
||||
border-color: $DIVIDER;
|
||||
}
|
||||
|
||||
scrollbar slider {
|
||||
min-width: ${SB_W}px;
|
||||
min-height: ${SB_W}px;
|
||||
border-radius: ${RAD_PX}px;
|
||||
background-color: $BORDER;
|
||||
}
|
||||
scrollbar slider:hover {
|
||||
@@ -250,10 +338,10 @@ scrollbar slider:hover {
|
||||
tooltip, .tooltip {
|
||||
background-color: $BG_OVERLAY;
|
||||
color: $FG_BRIGHT;
|
||||
border: 1px solid $ACCENT;
|
||||
border-radius: ${RAD_PX}px;
|
||||
border-color: $ACCENT;
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
if [ "$_is4" = "1" ]; then
|
||||
cat >> "$_tmp" <<EOF
|
||||
|
||||
@@ -264,10 +352,12 @@ EOF
|
||||
mv -f "$_tmp" "$_dest"
|
||||
}
|
||||
|
||||
write_gtk_css "$GTK3_THEME_DIR/gtk.css" 0
|
||||
write_gtk_css "$GTK3_CONF_DIR/gtk.css" 0
|
||||
write_gtk_css "$GTK4_THEME_DIR/gtk.css" 1
|
||||
write_gtk_css "$GTK4_CONF_DIR/gtk.css" 1
|
||||
write_gtk_css "$GTK3_THEME_DIR/gtk.css" 0 0 0
|
||||
write_gtk_css "$GTK3_THEME_DIR/gtk-dark.css" 0 0 1
|
||||
write_gtk_css "$GTK3_CONF_DIR/gtk.css" 0 1 0
|
||||
write_gtk_css "$GTK4_THEME_DIR/gtk.css" 1 0 0
|
||||
write_gtk_css "$GTK4_THEME_DIR/gtk-dark.css" 1 0 1
|
||||
write_gtk_css "$GTK4_CONF_DIR/gtk.css" 1 1 0
|
||||
|
||||
cat > "$GTK3_CONF_DIR/settings.ini.tmp.$$" <<EOF
|
||||
[Settings]
|
||||
@@ -275,7 +365,7 @@ gtk-theme-name=$THEME_ID
|
||||
gtk-icon-theme-name=$ICON_THEME
|
||||
gtk-font-name=$GTK_FONT
|
||||
gtk-application-prefer-dark-theme=$IS_DARK
|
||||
gtk-cursor-theme-size=$CUR_SZ
|
||||
gtk-cursor-theme-size=$GTK_CUR_SZ
|
||||
gtk-decoration-layout=menu:minimize,maximize,close
|
||||
EOF
|
||||
mv -f "$GTK3_CONF_DIR/settings.ini.tmp.$$" "$GTK3_CONF_DIR/settings.ini"
|
||||
@@ -286,7 +376,7 @@ gtk-theme-name=$THEME_ID
|
||||
gtk-icon-theme-name=$ICON_THEME
|
||||
gtk-font-name=$GTK_FONT
|
||||
gtk-application-prefer-dark-theme=$IS_DARK
|
||||
gtk-cursor-theme-size=$CUR_SZ
|
||||
gtk-cursor-theme-size=$GTK_CUR_SZ
|
||||
EOF
|
||||
mv -f "$GTK4_CONF_DIR/settings.ini.tmp.$$" "$GTK4_CONF_DIR/settings.ini"
|
||||
|
||||
@@ -298,7 +388,7 @@ cat > "$XSET_DIR/xsettingsd.conf.tmp.$$" <<EOF
|
||||
Net/ThemeName "$THEME_ID"
|
||||
Net/IconThemeName "$ICON_THEME"
|
||||
Gtk/FontName "$GTK_FONT"
|
||||
Gtk/CursorThemeSize $CUR_SZ
|
||||
Gtk/CursorThemeSize $GTK_CUR_SZ
|
||||
Gdk/WindowScalingFactor $GDK_SCALE_VAL
|
||||
EOF
|
||||
mv -f "$XSET_DIR/xsettingsd.conf.tmp.$$" "$XSET_DIR/xsettingsd.conf"
|
||||
|
||||
Reference in new issue
Block a user