nwg-panel icon indicating copy to clipboard operation
nwg-panel copied to clipboard

[Feature Request] generate default configs and exit

Open nazarewk opened this issue 9 months ago • 3 comments

Is your feature request related to a problem? Please describe. I am trying to configure nwg-shell pieces as a home-manager (Nix) module. In high-level overview it expects a static file to load as defaults and is able to merge it with some piece of configuration to produce a complete (also static) configuration file.

I am loading supposedly default config from https://github.com/nwg-piotr/nwg-panel/blob/dfc5104548cc6d047a9fe4a5d6a2f86e544f8cec/nwg_panel/config/config , but it is incomplete.

From what I'm seeing defaults are mostly set at runtime https://github.com/nwg-piotr/nwg-panel/blob/dfc5104548cc6d047a9fe4a5d6a2f86e544f8cec/nwg_panel/modules/sway_mode.py#L18-L24

Describe the solution you'd like I would like to be able to run nwg-panel with a flag that would result in filling in configuration structure and exiting without actually displaying any window.

Describe alternatives you've considered I think I could run it once to generate config at build time of Nix package, but I am not sure it would work.

Additional context Add any other context or screenshots about the feature request here.

nazarewk avatar Apr 24 '24 17:04 nazarewk

I'm actually getting pa_context_connect() failed: Connection refused when trying to run it in build context

nazarewk avatar Apr 24 '24 17:04 nazarewk

actually I'm not sure those settings are filled in at all, seems like file from the first run is EXACTLY the same as the static file available in repository.

are they purely runtime defaults not stored inside config?

nazarewk avatar Apr 24 '24 18:04 nazarewk

Well, each "defaults" are being added to prevent the panel from crashing in case some keys are missing from the config file. The provided config is very basic, and honestly, I haven't touched it for months, or even years. I distribute the panel as a part of the nwg-shell project, together with a bunch of more sophisticated config files.

I exported a config file for you, together with all the substitutions done programmatically, as seen from the program point of view just before entering the Gtk.main() loop.

[
  {
    "name": "panel-top",
    "output": "eDP-1",
    "layer": "bottom",
    "position": "top",
    "controls": "right",
    "height": 30,
    "homogeneous": true,
    "margin-top": 0,
    "margin-bottom": 0,
    "padding-horizontal": 0,
    "padding-vertical": 0,
    "spacing": 0,
    "items-padding": 0,
    "icons": "light",
    "css-name": "panel-top",
    "modules-left": [
      "button-sample",
      "playerctl"
    ],
    "modules-center": [
      "clock"
    ],
    "modules-right": [
      "sway-mode"
    ],
    "controls-settings": {
      "components": [
        "brightness",
        "volume",
        "battery"
      ],
      "commands": {
        "battery": ""
      },
      "show-values": false,
      "interval": 1,
      "icon-size": 16,
      "hover-opens": false,
      "leave-closes": true,
      "click-closes": false,
      "css-name": "controls-window",
      "custom-items": [
        {
          "name": "Panel settings",
          "icon": "nwg-panel",
          "cmd": "nwg-panel-config"
        }
      ],
      "menu": {
        "name": "Exit",
        "icon": "system-shutdown-symbolic",
        "items": [
          {
            "name": "Lock",
            "cmd": "swaylock -f -c 000000"
          },
          {
            "name": "Logout",
            "cmd": "swaymsg exit"
          },
          {
            "name": "Reboot",
            "cmd": "systemctl reboot"
          },
          {
            "name": "Shutdown",
            "cmd": "systemctl -i poweroff"
          }
        ]
      },
      "window-width": 0,
      "window-margin": 0,
      "show-brightness": false,
      "show-volume": false,
      "show-battery": true,
      "root-css-name": "controls-overview",
      "angle": 0,
      "battery-low-level": 20,
      "battery-low-interval": 3,
      "readme-label": "README",
      "processes-label": "Processes",
      "backlight-controller": "brightnessctl",
      "backlight-device": "",
      "output-switcher": false,
      "window-margin-vertical": 0,
      "window-margin-horizontal": 0
    },
    "tray": {
      "root-css-name": "tray",
      "inner-css-name": "inner-tray"
    },
    "sway-taskbar": {
      "workspace-menu": [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8"
      ],
      "name-max-len": 20,
      "image-size": 16,
      "workspaces-spacing": 0,
      "task-padding": 0,
      "show-app-icon": true,
      "show-app-name": true,
      "show-layout": true,
      "workspace-buttons": false,
      "all-workspaces": true,
      "mark-autotiling": true,
      "mark-xwayland": true,
      "all-outputs": true
    },
    "sway-workspaces": {
      "numbers": [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8"
      ]
    },
    "clock": {
      "format": "%a, %d. %b  %H:%M:%S",
      "tooltip-text": "",
      "on-left-click": "",
      "on-middle-click": "",
      "on-right-click": "",
      "on-scroll-up": "",
      "on-scroll-down": "",
      "css-name": "clock",
      "interval": 1,
      "root-css-name": "root-clock",
      "tooltip-date-format": false,
      "angle": 0.0,
      "calendar-path": "",
      "calendar-css-name": "calendar-window",
      "calendar-placement": "top",
      "calendar-margin-horizontal": 0,
      "calendar-margin-vertical": 0,
      "calendar-icon-size": 24,
      "calendar-interval": 60,
      "calendar-on": true
    },
    "playerctl": {
      "buttons-position": "left",
      "icon-size": 16,
      "chars": 30,
      "scroll": false,
      "button-css-name": "",
      "label-css-name": "",
      "interval": 1,
      "show-cover": true,
      "cover-size": 24,
      "angle": 0.0
    },
    "button-sample": {
      "command": "notify-send 'sample button'",
      "icon": "view-grid",
      "label": "",
      "label-position": "right",
      "css-name": "button-custom",
      "icon-size": 16
    },
    "menu-start": "off",
    "exclusive-zone": true,
    "sigrt": 64,
    "use-sigrt": false,
    "scratchpad": {},
    "sway-mode": {},
    "openweather": {},
    "brightness-slider": {},
    "dwl-tags": {},
    "hyprland-taskbar": {},
    "hyprland-workspaces": {},
    "start-hidden": false,
    "width": 1920,
    "menu-start-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",
      "height": 0,
      "icon-size-large": 32,
      "icon-size-small": 16,
      "icon-size-button": 16,
      "margin-bottom": 0,
      "margin-left": 0,
      "margin-right": 0,
      "margin-top": 0,
      "padding": 2,
      "terminal": "foot",
      "width": 0
    },
    "swaync": {
      "interval": 1,
      "root-css-name": "root-executor",
      "css-name": "executor-label",
      "icon-placement": "left",
      "icon-size": 18,
      "tooltip-text": "",
      "on-left-click": "swaync-client -t",
      "on-right-click": "",
      "on-middle-click": "",
      "on-scroll-up": "",
      "on-scroll-down": "",
      "always-show-icon": true
    }
  },
  {
    "name": "panel-bottom",
    "output": "eDP-1",
    "layer": "bottom",
    "position": "bottom",
    "controls": "off",
    "height": 30,
    "margin-top": 0,
    "margin-bottom": 0,
    "padding-horizontal": 6,
    "padding-vertical": 0,
    "spacing": 0,
    "items-padding": 0,
    "icons": "",
    "css-name": "panel-bottom",
    "modules-left": [
      "sway-taskbar"
    ],
    "modules-center": [],
    "modules-right": [
      "executor-weather"
    ],
    "controls-settings": {
      "components": [
        "brightness",
        "volume",
        "battery"
      ],
      "commands": {
        "battery": ""
      },
      "show-values": false,
      "interval": 1,
      "icon-size": 16,
      "hover-opens": false,
      "leave-closes": true,
      "click-closes": false,
      "css-name": "controls-window",
      "custom-items": [
        {
          "name": "Panel settings",
          "icon": "nwg-panel",
          "cmd": "nwg-panel-config"
        }
      ],
      "menu": {
        "name": "unnamed",
        "icon": "",
        "items": []
      },
      "window-width": 0,
      "window-margin": 0
    },
    "sway-taskbar": {
      "workspace-menu": [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8"
      ],
      "name-max-len": 20,
      "image-size": 16,
      "workspaces-spacing": 0,
      "task-padding": 0,
      "show-app-icon": true,
      "show-app-name": true,
      "show-layout": true,
      "workspace-buttons": false,
      "all-workspaces": true,
      "mark-autotiling": true,
      "mark-xwayland": true,
      "all-outputs": false
    },
    "sway-workspaces": {
      "numbers": [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8"
      ]
    },
    "clock": {
      "format": "%a, %d. %b  %H:%M:%S",
      "tooltip-text": "",
      "on-left-click": "",
      "on-middle-click": "",
      "on-right-click": "",
      "on-scroll-up": "",
      "on-scroll-down": "",
      "css-name": "clock",
      "interval": 1
    },
    "playerctl": {
      "buttons-position": "left",
      "icon-size": 16,
      "chars": 30,
      "scroll": false,
      "button-css-name": "",
      "label-css-name": "",
      "interval": 1
    },
    "executor-weather": {
      "script": "curl https://wttr.in/?format=1 -s",
      "interval": 1800,
      "css-name": "weather",
      "on-right-click": "",
      "icon-size": 16,
      "show-icon": true,
      "tooltip-text": "",
      "on-left-click": "",
      "on-middle-click": "",
      "on-scroll-up": "",
      "on-scroll-down": "",
      "root-css-name": "root-executor",
      "icon-placement": "left",
      "angle": 0.0,
      "sigrt": 34,
      "use-sigrt": false
    },
    "sigrt": 0,
    "use-sigrt": false,
    "start-hidden": false,
    "width": 1920,
    "menu-start": "off",
    "menu-start-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",
      "height": 0,
      "icon-size-large": 32,
      "icon-size-small": 16,
      "icon-size-button": 16,
      "margin-bottom": 0,
      "margin-left": 0,
      "margin-right": 0,
      "margin-top": 0,
      "padding": 2,
      "terminal": "foot",
      "width": 0
    },
    "homogeneous": false,
    "exclusive-zone": true
  }
]

nwg-piotr avatar Apr 24 '24 22:04 nwg-piotr