You are not logged in.
I'm attempting to have xdg-open open plain textfiles with terminal vim. I've tried the following:
First setting vim as my default plain/text application:
xdg-mime default vim.desktop text/plain
Further I've made a script in /usr/local/bin/st-vim-wrapper:
#!/bin/bash -f
bash -ic 'vim "$@"' vim "$@"
In /usr/share/applications/vim.desktop I've set the following:
TryExec=st-vim-wrapper
Exec=st -e "st-vim-wrapper %F"
Terminal=false
However when I attempt to open a text file through xdg-open it simply opens an st-terminal window and immediately closes it again. Running the wrapper-script directly works fine, also with a file parameter e.g.
st-vim-wrapper textfile.txt
If I attempt to run
st -e "st-vim-wrapper textfile.txt"
directly, it responds "child exited with status 1".
Not sure what is going wrong here.
Last edited by vegarab (2020-06-05 14:23:24)
Offline
Exec=st -e "st-vim-wrapper %F"
Compare
st -e "vim /path/to/file.txt"
and
st -e vim /path/to/file.txt
Offline
In addition to the above - what's the purpose of the wrapper? You can run vim in st from the desktop file.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
The solution here was to change the .desktop file entry to:
Exec=st -e st-vim-wrapper %F
Thank you, Seth.
In addition to the above - what's the purpose of the wrapper? You can run vim in st from the desktop file.
Doing that resulted in absolutely nothing (visually) happening when xdg-open attempted to open a textfile.
Offline
Doing that resulted in absolutely nothing
What was your actual exact attempt and how many quotes where in it?
Offline
Doing that resulted in absolutely nothing
What was your actual exact attempt and how many quotes where in it?
I can't find the original SO-post where I found a proposed solution with the wrapper (and an explanation for why you need it, which I didn't truly understand).
TryExec=vim
Exec=st -e vim %F
Terminal=false
gives me no visual feedback when opening a text-file with xdg-open.
After a few attempts, it reverts back to using VSCode to open the files, and I need to apply the xdg-mime command again to revert back to vim.
Simply running
st -e vim \path\to\file.txt
works totally fine otherwise, so not sure what is causing this.
Offline
The TryExec line?
(Terminal is false so there will be no tty and just "vim" might error out for that)
Offline
The TryExec line?
(Terminal is false so there will be no tty and just "vim" might error out for that)
Setting TryExec to
st -e vim
results in VScode being opened immediately (I assume its setup as a fallback editor).
Anyways, to me, everything is working perfectly fine with my wrapper.
Offline
Just remove the TryExec line.
Offline
Just remove the TryExec line.
It now opens textfiles in vim in st, without using the wrapper!
Where can I find more documentation on these .desktop files? I didn't find the Wiki-entry (https://wiki.archlinux.org/index.php/desktop_entries) very useful in understanding the use of TryExec and Terminal.
Edit: Found this: https://specifications.freedesktop.org/ … -variables
Last edited by vegarab (2020-06-05 14:58:14)
Offline