-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
add .desktop prompt launcher #651
base: master
Are you sure you want to change the base?
Conversation
I am interested in reactions to this idea and if there is a better way to go about it. I am very happy with this in my setup. It is particularly useful for launching steam games. |
XMonad/Prompt/DotDesktop.hs
Outdated
cmdFilter :: String -> String -- fixme future do something other than dropping these | ||
cmdFilter ('%':'f':xs) = cmdFilter xs | ||
cmdFilter ('%':'F':xs) = cmdFilter xs | ||
cmdFilter ('%':'u':xs) = cmdFilter xs | ||
cmdFilter ('%':'U':xs) = cmdFilter xs | ||
cmdFilter ('%':'c':xs) = cmdFilter xs | ||
cmdFilter ('%':'k':xs) = cmdFilter xs | ||
cmdFilter ('%':'i':xs) = cmdFilter xs | ||
cmdFilter ('%':'%':xs) = '%' : cmdFilter xs | ||
cmdFilter (x:xs) = x : cmdFilter xs | ||
cmdFilter "" = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this doesn't look fun :) I'm not familiar with .desktop
files at all; what exactly are you doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to just execute the .desktop command specified, without arguments.
Per the spec here:
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
there are many field codes for arguments which I cannot pass directly to the shell to execute, so I just remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to see if using xdg-open
to run it gives you more options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand how I would use xdg-open? Could you provide an example?
Just for context, here is an example from gimp.desktop
:
[Desktop Entry]
Version=1.0
Type=Application
Name=GNU Image Manipulation Program
...
Exec=gimp-2.10 %U
...
Basically the user could type image
, fuzzyMatch finds and displays GNU Image Manipulation Program
, and if it is selected, the Exec is gimp-2.10 %U
. This code filters out the %U and passes gimp-2.10
to the shell to launch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gtk-launch
or kioclient5 exec
can be used to run a .desktop file: https://askubuntu.com/a/1114798/950919
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gtk-launch
is (well, at least on my distro) installed with the gtk
package itself, so chances are users will definitely have this installed.
Will the fact that it goes into /usr/share/applications
by itself be a problem? Out of the current paths that the code searches (~/.local/share/applications
, /usr/share/applications
, and /usr/local/share/applications
) on the first one seems not to get searched by gtk-launch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gtk-launch
does look into ~/.local/share/applications
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mh, doesn't work on my end; a .desktop
file that's only in ~/.local/share/applications
but not in any of the other directories will fail to be found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's really weird, I looked into the source of gtk/glib and I don't see why it wouldn't look there. Maybe try stracing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh indeed, strace
tells me that the directory is searched. Upon closer inspection, the .desktop
file contains a non-existant executable; instead of telling me that, gtk-launch
told me that the .desktop
file couldn't be found, however ._.
Arg! How strange. I introduced some broken desktop files and logging locally to double check the behavior on my end and I cannot seem to reproduce the issue yet. logging diffs: modified XMonad/Prompt/DotDesktop.hs
@@ -54,6 +54,8 @@ getDirContents dir = do
getDotDesktopApps :: IO [DotDesktopApp]
getDotDesktopApps = do
appFolders <- getAppFolders
+ appendFile "/home/tulth/.xmonad/debug.log" $
+ unlines $ ("appfolder: " ++ ) <$> appFolders
contentsPerFolder <- mapM getDirContents appFolders
let folderFiles = join $ rights contentsPerFolder
dotDesktopFiles = filter isDotDesktop folderFiles
@@ -63,6 +65,7 @@ getDotDesktopApps = do
let parseErrs = lefts parseResults
dotDesktopApps = rights parseResults
mapM_ print parseErrs
+ appendFile "/home/tulth/.xmonad/debug.log" $ unlines parseErrs
return dotDesktopApps I thought perhaps a parse failure in a folder would cause a bigger problem, but that was no issue on my system.
Any ideas? Is |
Sorry, I was referring to |
@tulth what do you think about the idea of using |
I was thinking about this as well, but I do not think it makes much difference. |
I don't use desktop files, so forgive my ignorance here, but the man page for |
I note that |
@tulth any updates? |
@tulth friendly ping |
Description
Add a prompt bar that can launch
.desktop
files.Example use
Checklist
I've read CONTRIBUTING.md
I've considered how to best test these changes (property, unit,
manually, ...) and concluded: XXX
I updated the
CHANGES.md
file