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

Append arguments to .desktop Exec #168

Open
Slider-Whistle opened this issue Jul 10, 2024 · 2 comments
Open

Append arguments to .desktop Exec #168

Slider-Whistle opened this issue Jul 10, 2024 · 2 comments

Comments

@Slider-Whistle
Copy link

Hi, say I've got the following .desktop file: (I don't actually load my Doom through Steam, but it naturally applies to other use-cases)

[Desktop Entry]
Name=Doom
Comment=Play this game on Steam
Exec=steam -applaunch 2280
Icon=steam_icon_2280
Terminal=false
Type=Application
Categories=Game;

When I enter the text Doom -warp e1m1, I think it would be nice if j4-dmenu-desktop treated the Exec line as though it looked like this: (In case you're unfamiliar, this argument makes Doom skip the title screen and start the player in a given level)

Exec=steam -applaunch 2280 -warp e1m1

What do you think, might be pretty cool?

@meator
Copy link
Collaborator

meator commented Jul 10, 2024

This mechanism (or a very similar one) is already implemented in j4-dmenu-desktop. j4-dmenu-desktop handles arguments for desktop files whose Exec fields includes the %f, %F, %u or %U field codes (as the XDG specification mandates). j4-dmenu-desktop's implementation isn't exactly to the spec, it just replaces the field code with arguments given to Dmenu by the user. This means that with the following slightly modified desktop file:

[Desktop Entry]
Name=Doom
Comment=Play this game on Steam
Exec=steam -applaunch 2280 %F
Icon=steam_icon_2280
Terminal=false
Type=Application
Categories=Game;

You can achieve what you want. Note that the whole name of the desktop app has to be provided. This works as expected in the default mode, but if you use something like --display-binary, Doom entry will become Doom (steam), so you'll have to type Doom (steam) -warp e1m1 (tab completion of Dmenu will help you).

This feature has been in j4-dmenu-desktop for a long time (I have verified it works on version r2.18).

The second easiest solution is to make a custom desktop file:

[Desktop Entry]
Name=Doom skip
Comment=Play this modified game on Steam
Exec=steam -applaunch 2280 -warp e1m1
Icon=steam_icon_2280
Terminal=false
Type=Application
Categories=Game;

I believe this is the best solution if you want to launch the program with this set of flags often and if you don't want to retype -warp e1m1 every time you want to execute Doom.

You can put these custom desktop files in ~/.local/share/applications/ (or wherever in your $XDG_DATA_HOME or $XDG_DATA_DIRS) instead of system directories if you don't want to mess with system directories.

Specifying arguments currently works only for desktop files with % field codes mentioned above. This means that it won't work with the desktop file you have provided in the issue. I don't think that adding support for supplying arguments to any desktop app is a critical feature. I have outlined two alternative functional ways to solve the problem above, so it is possible to achieve what you want without changing j4-dmenu-desktop. Because of this, I don't think that I'll be working on implementing this feature in the near future. This doesn't mean that it will never get implemented, if any other useful use cases come up or if more people will request this feature or react to this issue, I might reconsider. Also, this mechanism is already implemented for % field codes, so it shouldn't be that hard to change the code to add support for it for all desktop apps.

Because of this issue, I have looked deeper into the argument handling mechanism and "accidentally" found a bug: #169. It is not thankfully present in any released version of j4-dmenu-desktop, but I was planning to release version r3.1 soon, which would have included this bug if I hadn't found it. So thanks for that.

@Slider-Whistle
Copy link
Author

Slider-Whistle commented Jul 10, 2024 via email

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

2 participants