awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.41k stars 598 forks source link

Make menubar.utils.terminal compatible with different terminals #2392

Open ThanosApostolou opened 6 years ago

ThanosApostolou commented 6 years ago

Output of awesome --version:

awesome v4.2 (Human after all)
 • Compiled against Lua 5.3.4 (running with Lua 5.3)
 • D-Bus support: ✔
 • execinfo support: ✔
 • xcb-randr version: 1.5
 • LGI version: 0.9.

How to reproduce the issue:

Menubar cannot launch applications which have Terminal=true when it's used with xfce4-terminal, mate-terminal, gnome-terminal, termite. The problematic line is https://github.com/awesomeWM/awesome/blob/68e4dd430f3c5a356afbd3d0cf4b94ac2bf64f4f/lib/menubar/utils.lua#L402 which takes for granted that terminals use the -e option to execute a command. However, in most terminals the command needs to be wrapped in quotes or even better it's preferable to use the -x option which passes all the rest arguments into the command. If I try to wrap the cmdline with quotes like this:

cmdline = utils.terminal .. ' -e "' .. cmdline:gsub('"', '\\"') .. '"'

then xfce4-terminal, mate-terminal, gnome-terminal and termite work but it breaks it for applications like lxterminal, st, urxvt.

Actual result:

Menubar only works with a few terminal options

Expected result: Menubar should work with many terminal options

After a lot of thinking, I believe that the best solution is to add a FIeld at menubar.utils Module like menubar.utils.terminal_execute_option which will be set to -e by default but users will be able to change it in -x and then menubar will execute the terminal argument according to this option. What do you think?

ThanosApostolou commented 6 years ago

@Elv13 you were right that having hardcoded terminal options was bad. Tell me what you think about my suggestion.

blueyed commented 6 years ago

menubar.utils.terminal_execute_option

Sounds good to me.. maybe this should be a printf pattern though, i.e. -e "%s"?