libdesktop.applications¶
A module for interacting with system applications.
-
libdesktop.applications.
mac_app_exists
(app)[source]¶ Check if ‘app’ is installed (OS X).
Check if the given applications is installed on this OS X system.
Parameters: app (str) – The application name. Returns: Is the app installed or not? Return type: bool
-
libdesktop.applications.
open_file_with_default_program
(file_path, background=False, return_cmd=False)[source]¶ Opens a file with the default program for that type.
Open the file with the user’s preferred application.
Parameters: Returns: Only if
return_cmd
, the command to run the program is returned instead of running it. Else returns nothing.Return type:
-
libdesktop.applications.
terminal
(exec_='', background=False, shell_after_cmd_exec=False, keep_open_after_cmd_exec=False, return_cmd=False)[source]¶ Start the default terminal emulator.
Start the user’s preferred terminal emulator, optionally running a command in it.
- Order of starting
- Windows:
- Powershell
- Mac:
- iTerm2
- Terminal.app
- Linux/Unix:
$TERMINAL
x-terminal-emulator
- Terminator
- Desktop environment’s terminal
- gnome-terminal
- urxvt
- rxvt
- xterm
Parameters: - exec_ (str) – An optional command to run in the opened terminal emulator. Defaults to empty (no command).
- background (bool) – Run the terminal in the background, instead of waiting for completion. Defaults to
False
. - shell_after_cmd_exec (bool) – Start the user’s shell after running the command (see exec_). Defaults to False.
- return_cmd (bool) – Returns the command used to start the terminal (str) instead of running it. Defaults to
False
.
Returns: Only if
return_cmd
, returns the command to run the terminal instead of running it. Else returns nothing.Return type:
-
libdesktop.applications.
text_editor
(file='', background=False, return_cmd=False)[source]¶ Starts the default graphical text editor.
Start the user’s preferred graphical text editor, optionally with a file.
Parameters: - file (str) – The file to be opened with the editor. Defaults to an empty string (i.e. no file).
- background (bool) – Runs the editor in the background, instead of waiting for completion. Defaults to
False
. - return_cmd (bool) – Returns the command (str) to run the editor instead of running it. Defaults to
False
.
Returns: Only if
return_cmd
, the command to run the editor is returned. Else returns nothing.Return type: