diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 93b5d1e..0517c8a 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -29,6 +29,7 @@ SKELETON_PANEL: dict = { "layer": "bottom", "position": "top", "controls": "off", + "menu-start": "off", "width": "auto", "height": 0, "margin-top": 0, @@ -54,6 +55,29 @@ SKELETON_PANEL: dict = { "custom-items": [{"name": "Panel settings", "icon": "nwg-panel", "cmd": "nwg-panel-config"}], "menu": {"name": "unnamed", "icon": "", "items": []} }, + "menu-settings": { + "cmd-lock": "swaylock -f -c 000000", + "cmd-logout": "swaymsg exit", + "cmd-restart": "systemctl reboot", + "cmd-shutdown": "systemctl -i poweroff", + "autohide": True, + "file-manager": "thunar", + "horizontal-align": "left", + "height": 0, + "icon-size-large": 32, + "icon-size-small": 16, + "lang": "", + "margin-bottom": 0, + "margin-left": 0, + "margin-right": 0, + "margin-top": 0, + "output": "", + "padding": 2, + "styling": "", + "terminal": "alacritty", + "vertical-align": "", + "width": 0 + }, "sway-taskbar": { "workspace-menu": ["1", "2", "3", "4", "5", "6", "7", "8"], "name-max-len": 20, @@ -508,7 +532,8 @@ class EditorWrapper(object): "output": "", "layer": "bottom", "position": "top", - "controls": False, + "controls": "off", + "menu-start": "off", "width": "auto", "height": 0, "margin-top": 0, @@ -563,6 +588,17 @@ class EditorWrapper(object): else: self.cb_controls.set_active_id("off") + self.cb_menu = builder.get_object("menu") + if not self.panel["menu-start"]: + self.cb_menu.set_active_id("off") + else: + if self.panel["menu-start"] == "right": + self.cb_menu.set_active_id("right") + elif self.panel["menu-start"] == "left": + self.cb_menu.set_active_id("left") + else: + self.cb_menu.set_active_id("off") + self.cb_layer = builder.get_object("layer") self.cb_layer.set_active_id(self.panel["layer"]) @@ -667,6 +703,13 @@ class EditorWrapper(object): else: self.panel["controls"] = "off" + val = self.cb_menu.get_active_id() + if val: + if val in ["left", "right"]: + self.panel["menu-start"] = val + else: + self.panel["menu-start"] = "off" + val = self.cb_layer.get_active_id() if val: self.panel["layer"] = val diff --git a/nwg_panel/glade/config_panel.glade b/nwg_panel/glade/config_panel.glade index ede7450..5a131dd 100644 --- a/nwg_panel/glade/config_panel.glade +++ b/nwg_panel/glade/config_panel.glade @@ -2,7 +2,7 @@ - + True False @@ -108,14 +108,80 @@ - + True - True - 4 + False + + on the rigth + on the left + off + 1 - 11 + 4 + + + + + True + False + start + Controls + + + 0 + 4 + + + + + True + False + start + CSS name + + + 0 + 14 + + + + + True + True + 20 + + + 1 + 14 + + + + + True + False + start + Icon set + + + 0 + 13 + + + + + True + False + + custom light + custom dark + GTK + + + + 1 + 13 @@ -125,6 +191,29 @@ start Spacing + + 0 + 12 + + + + + True + True + 4 + + + 1 + 12 + + + + + True + False + start + Vertical padding + 0 11 @@ -138,7 +227,7 @@ 1 - 10 + 11 @@ -146,7 +235,7 @@ True False start - Vertical padding + Horizontal padding 0 @@ -161,7 +250,7 @@ 1 - 9 + 10 @@ -169,7 +258,7 @@ True False start - Horizontal padding + Bottom margin 0 @@ -184,7 +273,7 @@ 1 - 8 + 9 @@ -192,7 +281,7 @@ True False start - Bottom margin + Top margin 0 @@ -207,7 +296,7 @@ 1 - 7 + 8 @@ -215,7 +304,7 @@ True False start - Top margin + Height 0 @@ -231,7 +320,7 @@ 1 - 6 + 7 @@ -239,7 +328,7 @@ True False start - Height + Width 0 @@ -279,7 +368,7 @@ 1 - 5 + 6 @@ -287,7 +376,7 @@ True False start - Width + Menu Start 0 @@ -295,80 +384,18 @@ - - True - False - start - Controls - - - 0 - 4 - - - - + True False - to the rigth - to the left + on the left + on the rigth off 1 - 4 - - - - - True - False - - custom light - custom dark - GTK - - - - 1 - 12 - - - - - True - False - start - Icon set - - - 0 - 12 - - - - - True - False - start - CSS name - - - 0 - 13 - - - - - True - True - 20 - - - 1 - 13 + 5 diff --git a/nwg_panel/main.py b/nwg_panel/main.py index 06ba68a..dc48d96 100644 --- a/nwg_panel/main.py +++ b/nwg_panel/main.py @@ -323,6 +323,38 @@ def main(): controls_settings = panel["controls-settings"] check_key(controls_settings, "show-values", False) + check_key(panel, "menu-start", "off") + if panel["menu-start"]: + check_key(panel, "menu-start-settings", {}) + defaults = { + "cmd-lock": "swaylock -f -c 000000", + "cmd-logout": "swaymsg exit", + "cmd-restart": "systemctl reboot", + "cmd-shutdown": "systemctl -i poweroff", + "autohide": True, + "file-manager": "thunar", + "horizontal-align": "left", + "height": 0, + "icon-size-large": 32, + "icon-size-small": 16, + "lang": "", + "margin-bottom": 0, + "margin-left": 0, + "margin-right": 0, + "margin-top": 0, + "output": panel["output"], + "padding": 2, + "styling": "", + "terminal": "alacritty", + "vertical-align": panel["position"], + "width": 0 + } + for key in defaults: + check_key(panel["menu-start-settings"], key, defaults[key]) + + if panel["menu-start"] != "off": + panel["menu-start-settings"]["horizontal-align"] = panel["menu-start"] + Gtk.Widget.set_size_request(window, w, h) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) @@ -333,8 +365,6 @@ def main(): check_key(panel, "modules-center", []) check_key(panel, "modules-right", []) - check_key(panel, "menu-start", False) - # This is to allow the "auto" value. Actually all non-numeric values will be removed. if "homogeneous" in panel and not isinstance(panel["homogeneous"], bool): panel.pop("homogeneous") @@ -364,16 +394,8 @@ def main(): common.controls_list.append(cc) left_box.pack_start(cc, False, False, 0) - if panel["menu-start"]: - settings = { - "output": panel["output"], - "position": panel["position"], - "alignment": "left", - "margin-left": 0, - "margin-bottom": 0, - "autohide": True - } - ms = MenuStart(settings, icons_path=icons_path) + if panel["menu-start"] == "left": + ms = MenuStart(panel["menu-start-settings"], icons_path=icons_path) left_box.pack_start(ms, False, False, 0) instantiate_content(panel, left_box, panel["modules-left"], icons_path=icons_path) @@ -391,6 +413,10 @@ def main(): check_key(panel, "modules-right", []) instantiate_content(panel, right_box, panel["modules-right"], icons_path=icons_path) + if panel["menu-start"] == "right": + ms = MenuStart(panel["menu-start-settings"], icons_path=icons_path) + right_box.pack_end(ms, False, False, 0) + if panel["controls"] and panel["controls"] == "right": monitor = None try: diff --git a/nwg_panel/modules/menu_start.py b/nwg_panel/modules/menu_start.py index a3292ce..10e4282 100644 --- a/nwg_panel/modules/menu_start.py +++ b/nwg_panel/modules/menu_start.py @@ -23,38 +23,53 @@ class MenuStart(Gtk.Button): self.connect("clicked", self.on_click) - check_key(settings, "css-name", "") - if settings["css-name"]: - self.set_property("name", settings["css-name"]) - self.show() def on_click(self, button): - cmd = "nwg-panel-plugin-menu" - """settings = { - "output": panel["output"], - "position": panel["position"], - "alignment": "left", - "margin-left": 6, - "margin-bottom": 6 - }""" - if self.settings["output"]: - cmd += " -o {}".format(self.settings["output"]) - - if self.settings["position"]: - cmd += " -va {}".format(self.settings["position"]) - - if self.settings["alignment"]: - cmd += " -ha {}".format(self.settings["alignment"]) - - if self.settings["margin-left"]: - cmd += " -ml {}".format(self.settings["margin-left"]) - - if self.settings["margin-bottom"]: - cmd += " -mb {}".format(self.settings["margin-bottom"]) + cmd = "nwg-menu" + if self.settings["cmd-lock"] != "swaylock -f -c 000000": + cmd += " -cmd-lock '{}'".format(self.settings["cmd-lock"]) + if self.settings["cmd-logout"] != "swaymsg exit": + cmd += " -cmd-logout '{}'".format(self.settings["cmd-logout"]) + if self.settings["cmd-restart"] != "systemctl reboot": + cmd += " -cmd-restart '{}'".format(self.settings["cmd-restart"]) + if self.settings["cmd-shutdown"] != "systemctl -i poweroff": + cmd += " -cmd-shutdown '{}'".format(self.settings["cmd-shutdown"]) if self.settings["autohide"]: cmd += " -d" + if self.settings["file-manager"] != "thunar": + cmd += " -fm {}".format(self.settings["file-manager"]) + if self.settings["horizontal-align"] != "left": + cmd += " -ha {}".format(self.settings["horizontal-align"]) + if self.settings["height"] > 0: + cmd += " -height {}".format(self.settings["height"]) + if self.settings["icon-size-large"] != 32: + cmd += " -isl {}".format(self.settings["icon-size-large"]) + if self.settings["icon-size-small"] != 16: + cmd += " -iss {}".format(self.settings["icon-size-small"]) + if self.settings["lang"]: + cmd += " -lang {}".format(self.settings["lang"]) + if self.settings["margin-bottom"] > 0: + cmd += " -mb {}".format(self.settings["margin-bottom"]) + if self.settings["margin-left"] > 0: + cmd += " -ml {}".format(self.settings["margin-left"]) + if self.settings["margin-right"] > 0: + cmd += " -mr {}".format(self.settings["margin-right"]) + if self.settings["margin-top"] > 0: + cmd += " -mt {}".format(self.settings["margin-top"]) + if self.settings["output"]: + cmd += " -o {}".format(self.settings["output"]) + if self.settings["padding"] != 2: + cmd += " -padding {}".format(self.settings["padding"]) + if self.settings["styling"]: + cmd += " -s {}".format(self.settings["styling"]) + if self.settings["terminal"] != "alacritty": + cmd += " -term {}".format(self.settings["terminal"]) + if self.settings["vertical-align"] != "bottom": + cmd += " -va {}".format(self.settings["vertical-align"]) + if self.settings["width"] > 0: + cmd += " -width {}".format(self.settings["width"]) print("Executing '{}'".format(cmd)) subprocess.Popen('exec {}'.format(cmd), shell=True) diff --git a/setup.py b/setup.py index 5bf699b..555973c 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(f_name): setup( name='nwg-panel', - version='0.2.4', + version='0.3.1', description='GTK3-based panel for sway window manager', packages=find_packages(), include_package_data=True,