Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print to standard output instead of passing to dmenu #39

Closed
roomcays opened this issue Apr 21, 2015 · 6 comments
Closed

Print to standard output instead of passing to dmenu #39

roomcays opened this issue Apr 21, 2015 · 6 comments

Comments

@roomcays
Copy link

I wonder if it is possible to print everything that j4-dmenu-desktop passes to dmenu to standard output.
I am trying to integrate j4-dmenu-desktop with rofi so it can be used as one of it's so-called "modis" instead of be executed via j4-dmenu-desktop's --dmenu argument.

The best I've come so far is using temporary file, as simple cat does not work (tries to execute first element, interpreting new line character as a user interaction):

j4-dmenu-desktop --dmenu="cat > /tmp/elements.txt" 2>&1 1>/dev/null

This, however, is just a half way to the success, because:

  1. uses temporary file
  2. loses relation between element name and .desktop file it is related with; this is how temporary file looks like:
Atom Zombie Smasher
Bastion
Cogs
Legend of Grimrock
Half-Life 2 (Beta)
Portal (Beta)

How this could be accomplished, if at all?

@gautrr
Copy link

gautrr commented Jun 14, 2015

I just ran into the same "problem" and trying to figure it out. I've also been looking for alternatives to j4-dmenu-desktop that could print available programs from .desktop to standard output, but to no avail so far.

@enkore
Copy link
Owner

enkore commented Jun 15, 2015

There is a command line utility to introspect .desktop files written in Python by an Arch Linux guy, hosted on Github. Don't remember the name, though, but you may be able to find it.

@enkore
Copy link
Owner

enkore commented Jan 30, 2016

While I took a stab at #51, I remembered this.

This should work, mostly:

#!/bin/sh
CURPID=$$
STDOUT=$(readlink -f /proc/$CURPID/fd/1)
j4-dmenu-desktop --dmenu="(cat > $STDOUT) | (cat << EOF)" &> /dev/null

It relies on some conventions, i.e. readlink -f resolving symlinks, /proc/$PID, and that FD 1 of a shell process is the active standard output. You'll need to put this in a script and run that.

The other way around is possible, too

j4-dmenu-desktop --dmenu="(cat &> /dev/null) | (echo '$*')"

($* = all arguments passed to the shell script, but really, any variable works)

With this it should be quite possible to integrate j4-dmenu-desktop with practically any kind of menu. #48

@roomcays
Copy link
Author

Wow, I have not expected this 👍
I have tried your script and it nicely prints out list of application names to the console, but when combined with rofi it - strangely - does not work :(
Something is telling me that it might be the case of output redirection, but I am not able to prove it...

@enkore
Copy link
Owner

enkore commented Jan 30, 2016

Hm, this should be transparent if the shell script is run like a shell script in a separate shell process. I don't know Rofi, maybe it documents somewhere how exactly it implements these modis.

Edit: Rofi appears to be a C program, so I'd expect it uses a proper shell process to execute scripts handed to it.

@roomcays
Copy link
Author

roomcays commented Feb 2, 2016

I will report this issue to Rofi's developer, he might be interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants