Skip to content

GNOME extension to create fully customizable quick toggle buttons to run user defined commands and launch custom scripts.

License

Notifications You must be signed in to change notification settings

StorageB/custom-command-toggle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Command Toggle

A GNOME extension to create custom quick toggle buttons.

Custom Command Toggle is an extension for GNOME 45/46/47/48 to create fully customizable quick toggle buttons.


Screenshot-main


Features:

  • Run terminal commands and launch custom scripts using quick toggle buttons.
  • Assign custom button names and icons.
  • Enter separate commands to run when the button is switched on and when it is switched off.
  • Run a command at startup to determine the button's initial state based on the command output, or manually specify whether the button starts as on, off, or in its last known state.
  • Run associated on or off command at startup to sync button state if required.
  • Option to toggle the button only if the command executes successfully and returns exit code 0 (for use with sudo commands using pkexec sudo where the command could be canceled or incorrect password entered).
  • Customize toggle button behavior to toggle or be in an always on or off state.
  • Assign keyboard shortcuts to quick toggle buttons.
  • Create up to 6 custom buttons.

Installation

Recommended

Browse for and install this extension through the GNOME Extension Manager, or install through the GNOME Extensions website.

Manual

  1. Download the custom-command-toggle.zip file of the latest release.
  2. In the terminal run: gnome-extensions install --force custom-command-toggle.zip
  3. Logout and login.

To enable and configure the extension:

gnome-extensions enable custom-command-toggle@storageb.github.com
gnome-extensions prefs custom-command-toggle@storageb.github.com

Configuration

Open the extension preferences via the Extension Manager or run gnome-extensions prefs custom-command-toggle@storageb.github.com

General Settings

In the Configuration tab under Settings, select the number of toggle buttons to create (maximum of 6). Note that this requires logging off/on or rebooting for changes to take effect.

There is also an option to export the current configuration for all the toggle buttons to a file for backup purposes.

Screenshot-settings


Appearance

Enter the name and icon information to use for the quick toggle button.

Screenshot-appearance

For a list of available symbolic icons to use refer to:

Alternatively, browse the icon directory for your system’s theme (typically /usr/share/icons), or use the Icon Library app.

To use a custom icon, place an SVG icon in: ~/.local/share/icons/hicolor/scalable/apps/. Reboot and then enter the icon name (without the file extension).


Commands

Enter the terminal/shell commands to associate with the quick toggle on/off actions.

Screenshot-commands

Command tips:

  • Run multiple commands in parallel by using & between commands.
  • Run multiple commands one at a time using && between commands.
  • Commands run silently (no terminal output), so test the full command in a terminal before adding it to the menu.
  • To run a command in a terminal window, use gnome-terminal -- command. Note that by default the GNOME terminal will close after the command is complete, but that can be changed in the terminal preferences if needed.
  • For sudo commands that require a password, use pkexec before the command to get a password prompt. For example, pkexec sudo command prompts for your password and then runs the command. Alternatively, use gnome-terminal -- sudo command to open a terminal where you can enter your password.
  • To open the command configuration window for this extension directly, use the command gnome-extensions prefs custom-command-list@storageb.github.com.

Startup Behavior

Specify the state of each toggle button at startup (on, off, the previous state it was in, or check a command's output to determine the state), and select if you want that command to run at startup to sync to the selected toggle state.

Screenshot-appearance

If "Run Command at Startup" is selected, there is an option to specify a delay time before the command is executed. Because GNOME extensions load early in the startup process, it may be required to delay your command from running by a few seconds to allow other processes to finish loading first. If this is not required, set the delay to 0.

If "Command output" is selected as the Initial State, Enter a command to check its output. If the specified Search Term appears in the command output, the button will be set to ON at startup. Otherwise, the button will be OFF at startup.

Screenshot-appearance


Toggle Behavior

Assign keyboard shortcuts for each button, and specify how the button and menu behave when the button is clicked.

Screenshot-appearance

If using pkexec or gnome-terminal -- command to run sudo commands, it is recommended to enable Check Command Exit Code so that if an incorrect password is entered or the command is canceled, the button will not toggle if the command does not run.


License

This project is licensed under the GNU General Public License.


I hope you found this extension useful!

Buy Me A Coffee

About

GNOME extension to create fully customizable quick toggle buttons to run user defined commands and launch custom scripts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published