[GH-ISSUE #94] Allow scripts in src image prop / script output not captured #7082

Closed
opened 2026-05-23 02:52:20 +01:00 by JakeStanger · 18 comments
Owner

Originally created by @yavko on GitHub (Apr 1, 2023).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/94

Is your feature request related to a problem? Please describe.

I want to display cover image of current song in bar

Describe the solution you'd like

Allow scripts in src

Describe alternatives you've considered

I would still like scripts to be allowed to be used in src, but cover in bar could also be added to the music widget.

Additional context

image

Originally created by @yavko on GitHub (Apr 1, 2023). Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/94 **Is your feature request related to a problem? Please describe.** I want to display cover image of current song in bar **Describe the solution you'd like** Allow scripts in src **Describe alternatives you've considered** I would still like scripts to be allowed to be used in src, but cover in bar could also be added to the music widget. **Additional context** ![image](https://user-images.githubusercontent.com/15178513/229270139-1bff11d9-d9bf-4ff8-a535-4567be1f57df.png)
Author
Owner

@JakeStanger commented on GitHub (Apr 1, 2023):

Makes sense, don't think this will be too hard to do.

<!-- gh-comment-id:1492945358 --> @JakeStanger commented on GitHub (Apr 1, 2023): Makes sense, don't think this will be too hard to do.
Author
Owner

@yavko commented on GitHub (Apr 10, 2023):

yay

<!-- gh-comment-id:1502482798 --> @yavko commented on GitHub (Apr 10, 2023): yay
Author
Owner

@yavko commented on GitHub (Apr 12, 2023):

Doesn't work on latest commit
image

config:

music_img = rec {
        type = "custom";
        name = "music-img";
        class = name;
        bar = [
          {
            type = "image";
            src = ''file:///{{poll:5000:playerctl metadata mpris:artUrl | sed -E "s/file:\/\/\///"}}'';
          }
        ];
      };

doesn't matter what combination of /s I use, it just won't work

<!-- gh-comment-id:1504668065 --> @yavko commented on GitHub (Apr 12, 2023): Doesn't work on latest commit ![image](https://user-images.githubusercontent.com/15178513/231359174-49d1aa26-97f7-4a1a-b62d-f602d5a3862a.png) config: ```nix music_img = rec { type = "custom"; name = "music-img"; class = name; bar = [ { type = "image"; src = ''file:///{{poll:5000:playerctl metadata mpris:artUrl | sed -E "s/file:\/\/\///"}}''; } ]; }; ``` doesn't matter what combination of `/`s I use, it just won't work
Author
Owner

@JakeStanger commented on GitHub (Apr 12, 2023):

That's odd, looks like the script output isn't getting captured. Also those slashes are horrible 🙃

If you try just a label element with the same script, can you get the URL to display as text? Also, can you double check it's writing to stdout (idk why it wouldn't)?

<!-- gh-comment-id:1505816157 --> @JakeStanger commented on GitHub (Apr 12, 2023): That's odd, looks like the script output isn't getting captured. Also those slashes are horrible :upside_down_face: If you try just a `label` element with the same script, can you get the URL to display as text? Also, can you double check it's writing to stdout (idk why it wouldn't)?
Author
Owner

@yavko commented on GitHub (Apr 13, 2023):

That's odd, looks like the script output isn't getting captured.

WAIT! That explains it, since i'm not able to get the uptime script thing you have in the power thing to work either

Also those slashes are horrible upside_down_face

I agree, I was trying everything, this just happened to be the last thing I tried lmao

If you try just a label element with the same script, can you get the URL to display as text?

YEAH IT DOESN'T
image

Also, can you double check it's writing to stdout (idk why it wouldn't)?

image
stdout works, unless this isn't stdout?

Ig this can re-closed, and a diff issue could be used, since it seems that no script is running.

<!-- gh-comment-id:1506343498 --> @yavko commented on GitHub (Apr 13, 2023): > That's odd, looks like the script output isn't getting captured. WAIT! That explains it, since i'm not able to get the uptime script thing you have in the power thing to work either > Also those slashes are horrible upside_down_face I agree, I was trying everything, this just happened to be the last thing I tried lmao > If you try just a `label` element with the same script, can you get the URL to display as text? YEAH IT DOESN'T ![image](https://user-images.githubusercontent.com/15178513/231656699-043bf1c5-c604-4845-b8e1-d8b50255b5ab.png) > Also, can you double check it's writing to stdout (idk why it wouldn't)? ![image](https://user-images.githubusercontent.com/15178513/231654702-9154d0a0-f007-4ebd-a17d-eb1b120b7f1a.png) stdout works, unless this isn't stdout? Ig this can re-closed, and a diff issue could be used, since it seems that no script is running.
Author
Owner

@yavko commented on GitHub (Apr 13, 2023):

Works in my repl, idk why it aint working
image

Though I know ironbar also uses pipes and listens for updates over channels, its probably a ironbar issue.

<!-- gh-comment-id:1506361634 --> @yavko commented on GitHub (Apr 13, 2023): Works in my repl, idk why it aint working ![image](https://user-images.githubusercontent.com/15178513/231658939-84de9959-27d6-472a-9906-92fa5dfe4188.png) Though I know ironbar also uses pipes and listens for updates over channels, its probably a ironbar issue.
Author
Owner

@JakeStanger commented on GitHub (Apr 13, 2023):

stdout works, unless this isn't stdout?

Standard pipe will be stdout, so that rules that out.

Ig this can re-closed, and a diff issue could be used, since it seems that no script is running.

I'm happy to keep it here since we've got the context here. Have updated the issue to reflect that.

Though I know ironbar also uses pipes and listens for updates over channels, its probably a ironbar issue.

Ironbar runs commands by spawning a sh -c '<your script here>'. Could it be a nixos quirk causing some kind of env issue with that? Clearly not based on the REPL, scrap that. Scripts definitely do work for me on Arch on latest commit though.

<!-- gh-comment-id:1506818893 --> @JakeStanger commented on GitHub (Apr 13, 2023): > stdout works, unless this isn't stdout? Standard pipe will be stdout, so that rules that out. > Ig this can re-closed, and a diff issue could be used, since it seems that no script is running. I'm happy to keep it here since we've got the context here. Have updated the issue to reflect that. > Though I know ironbar also uses pipes and listens for updates over channels, its probably a ironbar issue. Ironbar runs commands by spawning a `sh -c '<your script here>'`. ~~Could it be a nixos quirk causing some kind of env issue with that?~~ Clearly not based on the REPL, scrap that. Scripts definitely do work for me on Arch on latest commit though.
Author
Owner

@JakeStanger commented on GitHub (Apr 13, 2023):

I've just pushed up a commit into master that adds some additional logging to the script module. Could you try running a minimal config (ie just custom module with a single label with a script in it) using IRONBAR_LOG=trace (or IRONBAR_FILE_LOG=trace) and send the log pls? (It'll probably be very long)

<!-- gh-comment-id:1506829140 --> @JakeStanger commented on GitHub (Apr 13, 2023): I've just pushed up a commit into master that adds some additional logging to the script module. Could you try running a minimal config (ie just custom module with a single label with a script in it) using `IRONBAR_LOG=trace` (or `IRONBAR_FILE_LOG=trace`) and send the log pls? (It'll probably be very long)
Author
Owner

@yavko commented on GitHub (Apr 16, 2023):

I've just pushed up a commit into master that adds some additional logging to the script module. Could you try running a minimal config (ie just custom module with a single label with a script in it) using IRONBAR_LOG=trace (or IRONBAR_FILE_LOG=trace) and send the log pls? (It'll probably be very long)

with a minimal example it works?!??!

<!-- gh-comment-id:1510024106 --> @yavko commented on GitHub (Apr 16, 2023): > I've just pushed up a commit into master that adds some additional logging to the script module. Could you try running a minimal config (ie just custom module with a single label with a script in it) using `IRONBAR_LOG=trace` (or `IRONBAR_FILE_LOG=trace`) and send the log pls? (It'll probably be very long) with a minimal example it works?!??!
Author
Owner

@yavko commented on GitHub (Apr 16, 2023):

This is weird maybe when one command fails, it brings down all the other commands? But why would some commands fail, they are all valid?

<!-- gh-comment-id:1510024993 --> @yavko commented on GitHub (Apr 16, 2023): This is weird maybe when one command fails, it brings down all the other commands? But why would some commands fail, they are all valid?
Author
Owner

@JakeStanger commented on GitHub (Apr 16, 2023):

Oh very interesting, I've no idea why that would happen, unless you're triggering some kind of hrottling (why would dbus or a unix socket do that?) or there's some wires getting crossed in Ironbar.

Are you able to share your full config file (preferably in the compiled JSON format rather than Nix) and I can try and replicate exactly what's happening?

<!-- gh-comment-id:1510282831 --> @JakeStanger commented on GitHub (Apr 16, 2023): Oh very interesting, I've no idea why that would happen, unless you're triggering some kind of hrottling (why would dbus or a unix socket do that?) or there's some wires getting crossed in Ironbar. Are you able to share your full config file (preferably in the compiled JSON format rather than Nix) and I can try and replicate exactly what's happening?
Author
Owner

@yavko commented on GitHub (Apr 16, 2023):

Oh very interesting, I've no idea why that would happen, unless you're triggering some kind of hrottling (why would dbus or a unix socket do that?) or there's some wires getting crossed in Ironbar.

Are you able to share your full config file (preferably in the compiled JSON format rather than Nix) and I can try and replicate exactly what's happening?

Here:

{
  "anchor_to_edges": true,
  "center": [
    {
      "format": "{title}",
      "music_dir": "/home/yavor/Music",
      "player_type": "mpris",
      "truncate": "end",
      "type": "music"
    }
  ],
  "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:uptime -p | cut -d ' ' -f2-}}",
              "name": "uptime",
              "type": "label"
            }
          ]
        }
      ],
      "tooltip": "Up: {{30000:uptime -p | cut -d ' ' -f2-}}",
      "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"
    }
  ]
}

<!-- gh-comment-id:1510489591 --> @yavko commented on GitHub (Apr 16, 2023): > Oh very interesting, I've no idea why that would happen, unless you're triggering some kind of hrottling (why would dbus or a unix socket do that?) or there's some wires getting crossed in Ironbar. > > Are you able to share your full config file (preferably in the compiled JSON format rather than Nix) and I can try and replicate exactly what's happening? Here: ```json { "anchor_to_edges": true, "center": [ { "format": "{title}", "music_dir": "/home/yavor/Music", "player_type": "mpris", "truncate": "end", "type": "music" } ], "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:uptime -p | cut -d ' ' -f2-}}", "name": "uptime", "type": "label" } ] } ], "tooltip": "Up: {{30000:uptime -p | cut -d ' ' -f2-}}", "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" } ] } ```
Author
Owner

@JakeStanger commented on GitHub (Apr 20, 2023):

So! I think I've found the bug and it's in the script input parser - because the playerctl command contains a colon, it's hitting that and only taking everything after as the command. I don't think that'll be too hard to fix.

<!-- gh-comment-id:1516907367 --> @JakeStanger commented on GitHub (Apr 20, 2023): So! I think I've found the bug and it's in the script input parser - because the playerctl command contains a colon, it's hitting that and only taking everything after as the command. I don't think that'll be too hard to fix.
Author
Owner

@yavko commented on GitHub (Apr 20, 2023):

So! I think I've found the bug and it's in the script input parser - because the playerctl command contains a colon, it's hitting that and only taking everything after as the command. I don't think that'll be too hard to fix.

Ohhh, that would make sense

<!-- gh-comment-id:1516918241 --> @yavko commented on GitHub (Apr 20, 2023): > So! I think I've found the bug and it's in the script input parser - because the playerctl command contains a colon, it's hitting that and only taking everything after as the command. I don't think that'll be too hard to fix. Ohhh, that would make sense
Author
Owner

@JakeStanger commented on GitHub (Apr 20, 2023):

The linked PR works for me at least with your config - are you able to give it a shot when you get a few mins and confirm please?

<!-- gh-comment-id:1516942667 --> @JakeStanger commented on GitHub (Apr 20, 2023): The linked PR works for me at least with your config - are you able to give it a shot when you get a few mins and confirm please?
Author
Owner

@yavko commented on GitHub (Apr 20, 2023):

Sure, I'm at school rn so I'll do it in like 2 hours

<!-- gh-comment-id:1516977928 --> @yavko commented on GitHub (Apr 20, 2023): Sure, I'm at school rn so I'll do it in like 2 hours
Author
Owner

@yavko commented on GitHub (Apr 21, 2023):

Sorry something came up, but it does work! It fixed it!!

<!-- gh-comment-id:1517326674 --> @yavko commented on GitHub (Apr 21, 2023): Sorry something came up, but it does work! It fixed it!!
Author
Owner

@JakeStanger commented on GitHub (Apr 21, 2023):

No worries at all, work and sleep keep me busy most the day so it's never a rush. Thanks for testing, I'll merge the PR now.

<!-- gh-comment-id:1518258415 --> @JakeStanger commented on GitHub (Apr 21, 2023): No worries at all, work and sleep keep me busy most the day so it's never a rush. Thanks for testing, I'll merge the PR now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/ironbar#7082
No description provided.