Open mreppen opened 3 years ago
swaymsg exec "\"termite\""
works fine, and swaymsg exec "\"termite -t test\""
works fine too. So I guess we're incorrectly stripping too many quotes?
Indeed. I would expect your second example to fail.
@emersion those are both as expected. exec strips 1 layer of outer quotes, as it does in i3. https://i3wm.org/docs/userguide.html#exec_quoting
Similarly, i3-msg exec "\"test file\""
in i3 and swaymsg exec "\"test file\""
in sway have the same behavior for me. They both execute an executable with name "test" and argument "file".
If you want to run an executable "test file", use: swaymsg exec '"\"test file\""'
. The ''
are stripped by the shell, the ""
are stripped by exec, and the inner \"test file\"
is passed to the exec'd shell as "test file"
so our command test file
runs with no arguments.
@mreppen could you give an example desktop file where i3 and sway differ? A debug log could help identify how sway interprets the commands.
@RPigott Sure. But you don't need a desktop file to see that they are different:
~/test exec.sh
:
#!/bin/bash
notify-send Works
Works: i3-msg 'exec "\"$HOME/test exec.sh\""'
Does not work: swaymsg 'exec "\"$HOME/test exec.sh\""'
.desktop example:
~/.local/share/applications/myapp.desktop
:
[Desktop Entry]
Name=My App
Exec="$HOME/test exec.sh"
Terminal=false
Type=Application
Running i3-dmenu-desktop
and selecting "My App" in i3 works, but in Sway not.
I actually patched i3-dmenu-desktop
to do more proper escaping before I realized that it already works in i3
Well at least an example wasn't hard to find.
EDIT: Nvm, this is similar but not relevant here. Will leave for somebody to find and hopefully save time from debugging other things
This is probably also related: It incorrectly quotes Exec entries. I have compared other launchers:
Exec=bash -c 'notify-send "asd"'
i3-dmenu-desktop
sends "asd"
whereas other launchers yield asd
as expected.
Also, for some weird reason (in exec_always { ... }
block) 'notify-send "\\""'
prints "
, but 'notify-send "\\'"'
prints \'
. 'notify-send "\'"'
doesn't print at all.
I deleted my previous comments, the best workaroud is to use string concatenation:
exec_always {
'notify-send ''"'"'"'"''"$(localectl status | grep "X11 Layout" | sed -e "s/^.*X11 Layout: //" )"''"'"'"'"'
# 'notify-send ' '"' "'" '"' '"$(localectl status | grep "X11 Layout" | sed -e "s/^.*X11 Layout: //" )"' '"' "'" '"'
}
Backslash escaping works unreliably: \"
works only on login, \\"
works only on config reload.
Sway 1.5.1
exec
on an executable with a space in the path, i3 works with double-quoting, but sway does not. But Sway does work with\
for quoting the spaces.exec "\"my exectuable\""
exec "\"my exectuable\""
failsIs this intentional?
Because the spec for .desktop files specify quoting, it breaks using
i3-dmenu-desktop
in Sway for such .desktop files