Skip to content

Commit

Permalink
Add --term-cmd option to fvwm-menu-desktop.
Browse files Browse the repository at this point in the history
  * fvwm-menu-desktop now honors the Terminal=True .desktop
    specification. If Terminal=True is set, the menu will
    now run "Exec exec termCmd programExec" instead of
    "Exec exec programExec".
  * New option --term-cmd can be used to set the terminal
    command used to run Terminal applications with.
    Default is "xterm -e".
  * The terminal command can be configured via
    FvwmForm-XDGMenu-Config.
  • Loading branch information
Jaimos authored and ThomasAdam committed Mar 20, 2018
1 parent 527ead9 commit d1fc45c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
8 changes: 8 additions & 0 deletions bin/fvwm-menu-desktop-config.fpl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ $fvwmform_commands .= "
*${modname}: Text \"\$[gt.Insert Menu Into: ]\"
*${modname}: Input InsertInto 20 \"\"

*${modname}: Line left
*${modname}: Text \"\$[gt.Terminal command: ]\"
*${modname}: Input TermCmd 30 \"xterm -e\"
*${modname}: Text \"\$[gt. (Used to run Terminal entries)]\"

*${modname}: Line left
*${modname}: Text \"\$[gt.Icon directory: ]\"
*${modname}: Input IconDir 30 \"~/.fvwm/icons\"
Expand Down Expand Up @@ -191,6 +196,7 @@ $fvwmform_commands .= "\"
\$(IncludeRegen\?regenerate)\\
\$(IncludeBoth\?both)\\
\$(IncludeNone\?none) \\
\$(TermCmd\?--term-cmd \"\$(TermCmd)\" )\\
\$(IconDir\?--mini-icon-dir \$(IconDir) )\\
\$(DirIcon\?--dir-icon \$(DirIcon) )\\
\$(AppIcon\?--app-icon \$(AppIcon) )\\
Expand Down Expand Up @@ -232,6 +238,7 @@ $fvwmform_commands .= "
'*${modname}Default: Title \$(Title) ' ; /bin/echo \\
'*${modname}Default: InsertInto \$(InsertInto) ' ; /bin/echo \\
'*${modname}Default: Path \$(Path) ' ; /bin/echo \\
'*${modname}Default: TermCmd \$(TermCmd) ' ; /bin/echo \\
'*${modname}Default: IconDir \$(IconDir) ' ; /bin/echo \\
'*${modname}Default: DirIcon \$(DirIcon) ' ; /bin/echo \\
'*${modname}Default: AppIcon \$(AppIcon) ' \\
Expand Down Expand Up @@ -271,6 +278,7 @@ $fvwmform_commands .= "
'*${modname}Default: Title \$(Title) ' ; /bin/echo \\
'*${modname}Default: InsertInto \$(InsertInto) ' ; /bin/echo \\
'*${modname}Default: Path \$(Path) ' ; /bin/echo \\
'*${modname}Default: TermCmd \$(TermCmd) ' ; /bin/echo \\
'*${modname}Default: IconDir \$(IconDir) ' ; /bin/echo \\
'*${modname}Default: DirIcon \$(DirIcon) ' ; /bin/echo \\
'*${modname}Default: AppIcon \$(AppIcon) ' \\
Expand Down
7 changes: 7 additions & 0 deletions bin/fvwm-menu-desktop.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fvwm-menu-desktop
[ \fB\-\-all\-menus\fR ]
[ \fB\-\-include\-items\fR \fINAME\fR ]
[ \fB\-\-regen\-cmd\fR \fICMD\fR ]
[ \fB\-\-term\-cmd\fR \fICMD\fR ]
[ \fB\-\-dynamic\fR ]
[ \fB\-\-menu-error\fR|\fB\-e\fR ]
[ \fB\-\-verbose\fR|\fB\-v\fR ]
Expand Down Expand Up @@ -124,6 +125,12 @@ are included in the top level menu. \fINAME\fR can be one of \fIregenerate\fR,
This option sets the fvwm command \fICMD\fR that is run when the menu item
\'Regenerate' is selected. The default is "PipeRead `fvwm-menu-desktop`".

.IP "\fB\-\-term\-cmd\fR \fICMD\fR "
This option sets the terminal emulator command \fICMD\fR that is used to
to run terminal applications in. \fICMD\fR needs to end with an execute
option, such as xterm's -e option, which will run the command that is
appended to \fICMD\fR. The default is "xterm -e".

.IP "\fB\-\-dynamic\fR "
This option is to be used with creating dynamic menus using
\fBDynamicPopUpAction\fR and \fBDynamicPopDownAction\fR. This adds
Expand Down
21 changes: 16 additions & 5 deletions bin/fvwm-menu-desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# - Updated script for and require Python 3.
# - Drop support for Python 2.
# - Added support for xdg.Menu.Separator.
# - Added option --term-cmd to state the terminal emulator command
# to use with Terminal=True .desktop entries. Default: xterm -e

# Changed on 16/12/31 by Jaimos Skriletz:
# - Added check for FVWM_USERDIR env variable.
Expand Down Expand Up @@ -157,15 +159,15 @@ Standard output is a series Fvwm commands."""
try:
opts, args = getopt.getopt(sys.argv[1:], "hs:t:vwe",
["help", "verbose", "enable-mini-icons", "with-titles", "without-titles", "version",
"desktop=", "size=", "theme=", "install-prefix=", "menu-type=", "regen-cmd=",
"desktop=", "size=", "theme=", "install-prefix=", "menu-type=", "regen-cmd=", "term-cmd=",
"title=", "get-menus=", "set-menus=", "insert-in-menu=", "mini-icon-dir=", "menu-error",
"app-icon=", "dir-icon=", "include-items=", "dynamic", "all-menus"]+obs_args+equaled_obs_parms)
except getopt.GetoptError as err:
# print help information and exit:
print(str(err)) # will print something like "option -a not recognized"
print(usage)
sys.exit(2)
global verbose, force, size, current_theme, icon_dir, top, install_prefix, menu_type, menu_list_length
global verbose, force, size, current_theme, icon_dir, top, install_prefix, menu_type, menu_list_length, term_cmd
global with_titles, menu_entry_count, get_menus, timestamp, set_menus, printmode, insert_in_menu, previous_theme
global default_app_icon, default_dir_icon, include_items, config_menus, regen_cmd, dynamic_menu, build_all_menus
version = "2.4"
Expand Down Expand Up @@ -194,6 +196,7 @@ Standard output is a series Fvwm commands."""
regen_cmd = 'PipeRead `fvwm-menu-desktop`'
dynamic_menu = False
menu_error = False
term_cmd = "xterm -e"

# Loads config options from $FVWM_USERDIR/.FvwmForm-XDGMenu-Config
if "FVWM_USERDIR" in os.environ:
Expand Down Expand Up @@ -237,6 +240,8 @@ Standard output is a series Fvwm commands."""
include_items = "both"
elif o[1] == 'IncludeNone' and o[2] == 'on':
include_items = "none"
elif o[1] == 'TermCmd':
term_cmd = " ".join(o[2:])
fvwmform_config.close()

for o, a in opts:
Expand Down Expand Up @@ -307,6 +312,8 @@ Standard output is a series Fvwm commands."""
sys.exit(1)
elif o in ("--regen-cmd") :
regen_cmd = a
elif o in ("--term-cmd") :
term_cmd = a
elif o in ("--dynamic") :
dynamic_menu = True
elif o in ("--all-menus") :
Expand Down Expand Up @@ -733,7 +740,9 @@ def parsemenu(menu, name="", title=""):
desktop = DesktopEntry(entry.DesktopEntry.getFileName())
# eliminate '%U' etc behind execute string
execProgram = m.sub('', desktop.getExec())
printmenu(desktop.getName(), desktop.getIcon(), "Exec exec " + " " + execProgram)
if desktop.getTerminal():
execProgram = "%s %s" % (term_cmd, execProgram)
printmenu(desktop.getName(), desktop.getIcon(), "Exec exec " + execProgram)
menu_entry_count += 1
elif isinstance(entry, xdg.Menu.Separator):
if printmode:
Expand Down Expand Up @@ -792,8 +801,8 @@ Options:
of the menu NAME.
--get-menus all|desktop prints a space separated list of full menu paths.
'all' is all menus on the system except empty
ones. 'desktop' list the menus that would have been
generated. No menu generation is done.
ones. 'desktop' list the menus that would have
been generated. No menu generation is done.
--set-menus menu_paths expects a space separated list of full menu paths
to generate user specified menus.
--all-menus generate all menus found.
Expand All @@ -802,6 +811,8 @@ Options:
or 'none'. Default both.
--regen-cmd ACTION The fvwm ACTION for the 'Regenerate' menu item.
Default: 'PipeRead `fvwm-menu-desktop`'
--term-cmd CMD Terminal emulator CMD used on terminal entries.
Default: xterm -e
--dynamic used with dynamic menus.
-e, --menu-error out python-xdg not found error in menu.
-v, --verbose run and display debug info on STDERR."""
Expand Down
24 changes: 16 additions & 8 deletions modules/FvwmForm/FvwmForm-XDGOptionsHelp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ DestroyModuleConfig FvwmForm-XDGOptionsHelp: *
#*FvwmForm-XDGOptionsHelp: Line center
#*FvwmForm-XDGOptionsHelp: Text "$[gt.XDGMenu Options Help]"
#*FvwmForm-XDGOptionsHelp: Line
*FvwmForm-XDGOptionsHelp: Line center
*FvwmForm-XDGOptionsHelp: Text "----------------------------------------------------------------------------------------"
*FvwmForm-XDGOptionsHelp: Line center
*FvwmForm-XDGOptionsHelp: Text "$[gt.General Options]"
#*FvwmForm-XDGOptionsHelp: Line center
#*FvwmForm-XDGOptionsHelp: Text "----------------------------------------------------------------------------------------"
#*FvwmForm-XDGOptionsHelp: Line center
#*FvwmForm-XDGOptionsHelp: Text "$[gt.General Options]"
*FvwmForm-XDGOptionsHelp: Line left
*FvwmForm-XDGOptionsHelp: Line " "
*FvwmForm-XDGOptionsHelp: Line Left
Expand Down Expand Up @@ -109,14 +109,22 @@ DestroyModuleConfig FvwmForm-XDGOptionsHelp: *
*FvwmForm-XDGOptionsHelp: Line Left
*FvwmForm-XDGOptionsHelp: Line " "
*FvwmForm-XDGOptionsHelp: Line Left
*FvwmForm-XDGOptionsHelp: Text "$[gt.Output path: ]"
*FvwmForm-XDGOptionsHelp: Text "$[gt.Enter the FULL path to export menu. Default $FVWM_USERDIR/.XDGMmenu.]"
*FvwmForm-XDGOptionsHelp: Text "$[gt.Terminal Command: ]"
*FvwmForm-XDGOptionsHelp: Text "$[gt.Enter terminal emulator command used to launch terminal applications. The command]"
*FvwmForm-XDGOptionsHelp: Line Left
*FvwmForm-XDGOptionsHelp: Text "$[gt. ]"
*FvwmForm-XDGOptionsHelp: Text "$[gt.must end with an execute option (-e). Default xterm -e.]"
*FvwmForm-XDGOptionsHelp: Line Left
*FvwmForm-XDGOptionsHelp: Line " "
*FvwmForm-XDGOptionsHelp: Line center
*FvwmForm-XDGOptionsHelp: Text "----------------------------------------------------------------------------------------"
*FvwmForm-XDGOptionsHelp: Line Left
*FvwmForm-XDGOptionsHelp: Text "$[gt.Output path: ]"
*FvwmForm-XDGOptionsHelp: Text "$[gt.Enter the FULL path to export menu. Default $FVWM_USERDIR/.XDGMmenu.]"
*FvwmForm-XDGOptionsHelp: Line Left
*FvwmForm-XDGOptionsHelp: Line " "
#*FvwmForm-XDGOptionsHelp: Line center
#*FvwmForm-XDGOptionsHelp: Text "----------------------------------------------------------------------------------------"
#*FvwmForm-XDGOptionsHelp: Line Left
#*FvwmForm-XDGOptionsHelp: Line " "
# Buttons
*FvwmForm-XDGOptionsHelp: Line center
*FvwmForm-XDGOptionsHelp: Button quit "$[gt.Close]" ^M
Expand Down

0 comments on commit d1fc45c

Please sign in to comment.