adjustments for astal+ewwbar

main
Amir Alexander Abdelbaki 2026-07-08 21:56:51 +02:00
parent d680730d30
commit 84420733bb
3 changed files with 46 additions and 5 deletions

View File

@ -53,8 +53,49 @@ class AstalMenuApp(Gtk.Application):
settings = Settings() settings = Settings()
services = Services() services = Services()
self.window = MenuWindow(self, settings, services) self.window = MenuWindow(self, settings, services)
self._register_actions()
self.hold() # stay alive with no visible window self.hold() # stay alive with no visible window
def _register_actions(self) -> None:
# Mirrors the --show/--hide/--toggle/--appdrawer verbs from do_command_line, but
# reachable via org.gtk.Actions.Activate. menu-toggle.sh calls these directly with
# `gdbus call` for already-running instances, which skips spawning a whole second
# python3 + GTK process (~0.5s) just to forward one verb over D-Bus.
def add(name: str, callback, has_side: bool) -> None:
action = Gio.SimpleAction.new(name, GLib.VariantType.new("s") if has_side else None)
action.connect("activate", callback)
self.add_action(action)
def side_of(param: GLib.Variant | None) -> str:
return param.get_string() if param is not None else ""
def on_show(_action, param) -> None:
assert self.window is not None
if side_of(param):
self.window.set_side(side_of(param))
self.window.show_menu()
def on_hide(_action, _param) -> None:
assert self.window is not None
self.window.hide_menu()
def on_toggle(_action, param) -> None:
assert self.window is not None
if side_of(param):
self.window.set_side(side_of(param))
self.window.toggle()
def on_appdrawer(_action, param) -> None:
assert self.window is not None
if side_of(param):
self.window.set_side(side_of(param))
self.window.show_menu(focus_appdrawer=True)
add("show", on_show, has_side=True)
add("hide", on_hide, has_side=False)
add("toggle", on_toggle, has_side=True)
add("appdrawer", on_appdrawer, has_side=True)
def do_command_line(self, cmdline: Gio.ApplicationCommandLine) -> int: def do_command_line(self, cmdline: Gio.ApplicationCommandLine) -> int:
args = list(cmdline.get_arguments()[1:]) args = list(cmdline.get_arguments()[1:])
# Optional "--side top|bottom|left|right": the menu slides in from and pins to # Optional "--side top|bottom|left|right": the menu slides in from and pins to

View File

@ -1,7 +1,7 @@
* { * {
all: unset; // Unsets everything so you can style everything from scratch all: unset; // Unsets everything so you can style everything from scratch
font-family: Agave Nerd Font Mono, sans-serif; font-family: Agave Nerd Font Mono, sans-serif;
font-size: 13pt; font-size: 20pt;
} }
tooltip { tooltip {
@ -72,8 +72,8 @@ tooltip {
color: #5018dd; color: #5018dd;
margin: 2px 3px; margin: 2px 3px;
min-width: 26px; min-width: 40px;
min-height: 26px; min-height: 40px;
border-radius: 50%; border-radius: 50%;
} }

View File

@ -6,7 +6,7 @@
:geometry (geometry :x "0%" :geometry (geometry :x "0%"
:y "1%" :y "1%"
:width "99%" :width "99%"
:height "44px" :height "60px"
:anchor "top center") :anchor "top center")
:exclusive true :exclusive true
(bar :monitor_ monitor)) (bar :monitor_ monitor))
@ -26,7 +26,7 @@
(box :orientation "h" :space-evenly false :halign "start" (box :orientation "h" :space-evenly false :halign "start"
(osk) (osk)
(box :class "music" {"${battery}"}) (box :class "music" {"${battery}"})
(button :onclick "~/.config/scripts/menu-toggle.sh toggle top" :class "icon-btn" :valign "center" :width 26 :height 26 {""}) (button :onclick "~/.config/scripts/menu-toggle.sh" :class "icon-btn" :valign "center" :width 26 :height 26 {""})
(metric :label "󰓃 " (metric :label "󰓃 "
:value volume :value volume
:onchange "pactl set-sink-volume @DEFAULT_SINK@ {}%" :onchange "pactl set-sink-volume @DEFAULT_SINK@ {}%"