ironbar: Scripts don't work while running ironbar under a systemd service NixOS

Describe the bug

Scripts don’t work while running ironbar under a systemd service

To Reproduce Steps to reproduce the behavior:

  1. Use script
  2. See error

Expected behavior

Scripts work

System information:

  • Distro: NixOS unstable (aka 23.05)
  • Compositor: Hyprland
  • Ironbar version: 0.11 (latest commit on master)

Configuration

Config (generated json from nix)
{
  "anchor_to_edges": true,
  "center": [
    {
      "bar": [
        {
          "class": "music-img-img",
          "src": "{{poll:5000:playerctl metadata mpris:artUrl}}",
          "type": "image"
        }
      ],
      "class": "music-img",
      "name": "music-img",
      "on_mouse_enter": {
        "cmd": "/nix/store/7kaxirybmsqz1wnq290aj9fifwgdisjx-mctrls-shower/bin/mctrls-shower"
      },
      "on_mouse_exit": {
        "cmd": "/nix/store/c6swqv9dw2sbiw5zsxar5f3s5zl1m0ix-mctrls-hider/bin/mctrls-hider"
      },
      "type": "custom"
    },
    {
      "format": "{title}",
      "icons": {
        "pause": "icon:media-playback-pause",
        "play": "icon:media-playback-start"
      },
      "music_dir": "/home/yavor/Music",
      "on_mouse_enter": {
        "cmd": "/nix/store/7kaxirybmsqz1wnq290aj9fifwgdisjx-mctrls-shower/bin/mctrls-shower"
      },
      "on_mouse_exit": {
        "cmd": "/nix/store/c6swqv9dw2sbiw5zsxar5f3s5zl1m0ix-mctrls-hider/bin/mctrls-hider"
      },
      "player_type": "mpris",
      "show_status_icon": false,
      "truncate": "end",
      "type": "music"
    },
    {
      "bar": [
        {
          "class": "music-ctrls-prev",
          "label": "玲",
          "on_click": "!/nix/store/nxip05k3sg7m937vvavjpfdak6k3ica0-iron-previous/bin/iron-previous",
          "type": "button"
        },
        {
          "class": "music-ctrls-pp",
          "label": "{{poll:100:/nix/store/jha3arpk5fpcspbam0nkdrrdsvx79l09-pp-icon/bin/pp-icon}}",
          "on_click": "!/nix/store/rqacrmlhvwnmp90i88wmmx14bismvjp2-iron-play-pause/bin/iron-play-pause",
          "type": "button"
        },
        {
          "class": "music-ctrls-next",
          "label": "怜",
          "on_click": "!/nix/store/qf2246j28xybmz7h9yb23nxi4b0yhm13-iron-next/bin/iron-next",
          "type": "button"
        }
      ],
      "class": "music-ctrls",
      "name": "music-ctrls",
      "on_mouse_enter": {
        "cmd": "/nix/store/7kaxirybmsqz1wnq290aj9fifwgdisjx-mctrls-shower/bin/mctrls-shower"
      },
      "on_mouse_exit": {
        "cmd": "/nix/store/c6swqv9dw2sbiw5zsxar5f3s5zl1m0ix-mctrls-hider/bin/mctrls-hider"
      },
      "show_if": {
        "cmd": "/nix/store/i9mm84k7myf1fis2xgnbsqxj3jd1ygn6-mctrls-checker/bin/mctrls-checker",
        "interval": 500,
        "mode": "poll"
      },
      "transition_type": "slide_start",
      "type": "custom"
    }
  ],
  "end": [
    {
      "type": "tray"
    },
    {
      "format": [
        " {cpu_percent}%",
        " {memory_percent}%"
      ],
      "type": "sys_info"
    },
    {
      "bar": [
        {
          "label": "",
          "name": "power-btn",
          "on_click": "popup:toggle",
          "type": "button"
        }
      ],
      "class": "power-menu",
      "popup": [
        {
          "orientation": "vertical",
          "type": "box",
          "widgets": [
            {
              "label": "Power menu",
              "name": "header",
              "type": "label"
            },
            {
              "type": "box",
              "widgets": [
                {
                  "class": "power-btn",
                  "label": "<span font-size='40pt'></span>",
                  "on_click": "!shutdown now",
                  "type": "button"
                },
                {
                  "class": "power-btn",
                  "label": "<span font-size='40pt'></span>",
                  "on_click": "!reboot",
                  "type": "button"
                }
              ]
            },
            {
              "label": "Uptime: {{30000:/nix/store/ws0j8bcqxcy08d664cbbbg6j0xlg1vg6-fmt-uptime/bin/fmt-uptime}}",
              "name": "uptime",
              "type": "label"
            }
          ]
        }
      ],
      "tooltip": "Up: {{30000:/nix/store/ws0j8bcqxcy08d664cbbbg6j0xlg1vg6-fmt-uptime/bin/fmt-uptime}}",
      "type": "custom"
    },
    {
      "format": "%l:%M %P",
      "type": "clock"
    }
  ],
  "height": 32,
  "icon_theme": "Papirus-Dark",
  "position": "top",
  "start": [
    {
      "bar": [
        {
          "label": "",
          "on_click": "!hyprctl dispatch exec \"zsh -c 'rofi -show drun'\"",
          "type": "button"
        }
      ],
      "class": "nix-launcher",
      "name": "nix-launcher",
      "type": "custom"
    },
    {
      "all_monitors": false,
      "name_map": {
        "1": "●",
        "10": "●",
        "2": "●",
        "3": "●",
        "4": "●",
        "5": "●",
        "6": "●",
        "7": "●",
        "8": "●",
        "9": "●"
      },
      "type": "workspaces"
    }
  ]
}

Additional context

Works while executing normally, and not under systemd service

Screenshots

image

From journalctl and is same for like every occurance of the issue, which is like a lot cuz its polling (and retrying? I presume)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Firstly because it would make this issue worse - systemd units do not read PATH because they have no idea of it, so it would add the requirement for every script to use the absolute path. Also because being able to do bash scripting in your config is neat, and I’d rather not lose that.

makes sense, then

I’m not sure what’s causing that, but it sure ain’t the PR as that literally changes the sh calls to /bin/sh. I’ve also not merged any changes to the Wayland code yet. I’d imagine this is likely another issue with running under systemd you’d not encountered up until now (possibly again because it won’t read any env vars unless you specifically write them into the unit, or maybe some nix things).

Not sure either but it went away

I think I know why - the program is spawned as just sh but systemd won’t check PATH. Before I fix, can you confirm /bin/sh exists on NixOS pls?

It does image