From e021863b67bf4f17a9c2cd8d8693874e2a8bd9c6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 20 May 2026 22:33:45 +0200 Subject: [PATCH] Convert tui and web app remove to QS menus --- bin/omarchy-tui-remove | 29 +++++++++----------------- bin/omarchy-webapp-remove | 33 ++++++++++-------------------- default/omarchy/omarchy-menu.jsonc | 4 ++-- shell/plugins/menu/Menu.qml | 2 +- 4 files changed, 24 insertions(+), 44 deletions(-) diff --git a/bin/omarchy-tui-remove b/bin/omarchy-tui-remove index 369528e2..9272886a 100755 --- a/bin/omarchy-tui-remove +++ b/bin/omarchy-tui-remove @@ -1,7 +1,7 @@ #!/bin/bash -# omarchy:summary=Remove terminal UI desktop launchers -# omarchy:args=[name...] +# omarchy:summary=Remove a terminal UI desktop launcher +# omarchy:args=[name] set -e @@ -17,30 +17,21 @@ if (( $# == 0 )); then done < <(find "$DESKTOP_DIR" -name '*.desktop' -print0) if ((${#TUIS[@]})); then - IFS=$'\n' SORTED_TUIS=($(sort <<<"${TUIS[*]}")) - unset IFS - APP_NAMES_STRING=$(gum choose --no-limit --header "Select TUI to remove..." --selected-prefix="✗ " "${SORTED_TUIS[@]}") - # Convert newline-separated string to array - APP_NAMES=() - while IFS= read -r line; do - [[ -n $line ]] && APP_NAMES+=("$line") - done <<< "$APP_NAMES_STRING" + mapfile -t SORTED_TUIS < <(printf '%s\n' "${TUIS[@]}" | sort) + APP_NAME=$(omarchy-menu-select "Select TUI to remove" "${SORTED_TUIS[@]}" -- --width 520 --maxheight 520) else echo "No TUIs to remove." exit 1 fi else - # Use array to preserve spaces in app names - APP_NAMES=("$@") + APP_NAME="$*" fi -if (( ${#APP_NAMES[@]} == 0 )); then - echo "You must provide TUI names." +if [[ -z $APP_NAME ]]; then + echo "You must select a TUI to remove." exit 1 fi -for APP_NAME in "${APP_NAMES[@]}"; do - rm -f "$DESKTOP_DIR/$APP_NAME.desktop" - rm -f "$ICON_DIR/$APP_NAME.png" - echo "Removed $APP_NAME" -done +rm -f "$DESKTOP_DIR/$APP_NAME.desktop" +rm -f "$ICON_DIR/$APP_NAME.png" +omarchy-notification-send "TUI removed" "$APP_NAME" diff --git a/bin/omarchy-webapp-remove b/bin/omarchy-webapp-remove index e75acd03..6e61ab50 100755 --- a/bin/omarchy-webapp-remove +++ b/bin/omarchy-webapp-remove @@ -1,7 +1,7 @@ #!/bin/bash -# omarchy:summary=Remove web app desktop launchers -# omarchy:args=[name...] +# omarchy:summary=Remove a web app desktop launcher +# omarchy:args=[name] set -e @@ -17,34 +17,23 @@ if (( $# == 0 )); then done < <(find "$DESKTOP_DIR" -name '*.desktop' -print0) if ((${#WEB_APPS[@]})); then - IFS=$'\n' SORTED_WEB_APPS=($(sort <<<"${WEB_APPS[*]}")) - unset IFS - APP_NAMES_STRING=$(gum choose --no-limit --header "Select web app to remove..." --selected-prefix="✗ " "${SORTED_WEB_APPS[@]}") - # Convert newline-separated string to array - APP_NAMES=() - while IFS= read -r line; do - [[ -n $line ]] && APP_NAMES+=("$line") - done <<< "$APP_NAMES_STRING" + mapfile -t SORTED_WEB_APPS < <(printf '%s\n' "${WEB_APPS[@]}" | sort) + APP_NAME=$(omarchy-menu-select "Select web app to remove" "${SORTED_WEB_APPS[@]}" -- --width 520 --maxheight 520) else echo "No web apps to remove." exit 1 fi else - # Use array to preserve spaces in app names - APP_NAMES=("$@") + APP_NAME="$*" fi -if (( ${#APP_NAMES[@]} == 0 )); then - echo "You must select at least one web app to remove." +if [[ -z $APP_NAME ]]; then + echo "You must select a web app to remove." exit 1 fi -for APP_NAME in "${APP_NAMES[@]}"; do - rm -f "$DESKTOP_DIR/$APP_NAME.desktop" - rm -f "$ICON_DIR/$APP_NAME.png" - echo "Removed $APP_NAME" -done +rm -f "$DESKTOP_DIR/$APP_NAME.desktop" +rm -f "$ICON_DIR/$APP_NAME.png" -if command -v update-desktop-database &>/dev/null; then - update-desktop-database "$DESKTOP_DIR" &>/dev/null || true -fi +omarchy-notification-send "Web app removed" "$APP_NAME" +update-desktop-database "$DESKTOP_DIR" &>/dev/null diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index bb4e9f5e..d24c7531 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -227,8 +227,8 @@ // Remove "remove.package": {"icon":"󰣇","label":"Package","keywords":"uninstall","action":"xdg-terminal-exec --app-id=org.omarchy.terminal omarchy-pkg-remove"}, - "remove.webapp": {"icon":"","label":"Web App","keywords":"uninstall","action":"omarchy-launch-floating-terminal-with-presentation omarchy-webapp-remove"}, - "remove.tui": {"icon":"","label":"TUI","keywords":"uninstall terminal app","action":"omarchy-launch-floating-terminal-with-presentation omarchy-tui-remove"}, + "remove.webapp": {"icon":"","label":"Web App","keywords":"uninstall","action":"omarchy-webapp-remove"}, + "remove.tui": {"icon":"","label":"TUI","keywords":"uninstall terminal app","action":"omarchy-tui-remove"}, "remove.development": {"icon":"󰵮","label":"Development","keywords":"uninstall languages"}, "remove.theme": {"icon":"󰸌","label":"Theme","keywords":"uninstall","action":"omarchy-theme-remove"}, "remove.browser": {"icon":"","label":"Browser","keywords":"uninstall"}, diff --git a/shell/plugins/menu/Menu.qml b/shell/plugins/menu/Menu.qml index cd72f46c..4918b04c 100644 --- a/shell/plugins/menu/Menu.qml +++ b/shell/plugins/menu/Menu.qml @@ -1187,7 +1187,7 @@ Item { anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor - onContainsMouseChanged: if (containsMouse) { + onPositionChanged: { root.cursorActive = true root.selectedIndex = row.index }