Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bin/omarchy-agent-look-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ for item in "$OMARCHY_PATH"/shell/*; do
[[ $(basename "$item") == "shell.qml" ]] || ln -s "$item" "$work/config/$(basename "$item")"
done

component_url=$(jq -Rn --arg path "$plugin/$entry" '"file://" + ($path | split("/") | map(@uri) | join("/"))')
shot_path=$(jq -Rn --arg path "$work/shot.png" '$path')

cat > "$work/config/shell.qml" <<EOF
import QtQuick
import Quickshell
Expand Down Expand Up @@ -67,7 +70,7 @@ ShellRoot {
running: true
onTriggered: {
if (root.step === 0) {
var component = Qt.createComponent("file://$plugin/$entry")
var component = Qt.createComponent($component_url)
if (component.status !== Component.Ready) {
console.log("PREVIEW_ERROR " + component.errorString())
Qt.quit()
Expand All @@ -83,7 +86,7 @@ ShellRoot {
root.widget.anchors.right = host.right
} else if (root.step === 2) {
frame.grabToImage(function(result) {
result.saveToFile("$work/shot.png")
result.saveToFile($shot_path)
console.log("PREVIEW_SAVED " + Math.round(root.widget.width) + "x" + Math.round(root.widget.height))
Qt.quit()
})
Expand Down
7 changes: 6 additions & 1 deletion bin/omarchy-debug
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ while (( $# > 0 )); do
esac
done

LOG_FILE="/tmp/omarchy-debug.log"
LOG_FILE=$(mktemp /tmp/omarchy-debug.XXXXXX.log)
trap 'rm -f "$LOG_FILE"' EXIT

if [[ $NO_SUDO = "true" ]]; then
DMESG_OUTPUT="(skipped - --no-sudo flag used)"
Expand Down Expand Up @@ -60,6 +61,10 @@ INSTALLED PACKAGES
$({ expac -S '%n %v (%r)' $(pacman -Qqe) 2>/dev/null; comm -13 <(pacman -Sql | sort) <(pacman -Qqe | sort) | xargs -r expac -Q '%n %v (AUR)'; } | sort)
EOF

if publish=$(mktemp /tmp/omarchy-debug.XXXXXX.log 2>/dev/null); then
cp "$LOG_FILE" "$publish" 2>/dev/null && mv -fT "$publish" /tmp/omarchy-debug.log 2>/dev/null || rm -f "$publish"
fi

if [[ $PRINT_ONLY = "true" ]]; then
cat "$LOG_FILE"
exit 0
Expand Down
39 changes: 36 additions & 3 deletions bin/omarchy-games-retro-install
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,52 @@ if [[ ! -f $core_path ]]; then
exit 1
fi

core_path=$(realpath -- "$core_path")
game_path=$(realpath -- "$game_path")

desktop_string_escape() {
local value="$1"

value=${value//\\/\\\\}
value=${value//$'\t'/\\t}
value=${value//$'\r'/\\r}
value=${value//$'\n'/\\n}
[[ $value == " "* ]] && value="\\s${value# }"

printf '%s' "$value"
}

desktop_exec_arg() {
local value="$1"

value=${value//\\/\\\\}
value=${value//\"/\\\"}
value=${value//\`/\\\`}
value=${value//\$/\\\$}
value=${value//%/%%}

printf '"%s"' "$value"
}

game_name=$(printf '%s' "${game_path##*/}" | sed 's/\.[^.]*$//; s/[[:space:]]*([^)]*)//g; s/[[:space:]]\+/ /g; s/^ //; s/ $//' | perl -Mopen=locale -pe 's/(^|[[:space:]])([^[:space:]])/$1\U$2/g')
[[ -n $game_name ]] || game_name="${game_path##*/}"
desktop_name="$game_name"
desktop_id=$(printf '%s' "$desktop_name" | tr '[:upper:]' '[:lower:]' | tr -cs '[:alnum:]' '-' | sed 's/^-//; s/-$//')
[[ -n $desktop_id ]] || desktop_id="retroarch-$(printf '%s' "$game_path" | md5sum | cut -c1-12)"
desktop_dir="$HOME/.local/share/applications"
desktop_file="$desktop_dir/$desktop_id.desktop"
mkdir -p "$desktop_dir"

name_field=$(desktop_string_escape "$desktop_name")
comment_field=$(desktop_string_escape "Play $game_name with RetroArch")
exec_field=$(desktop_string_escape "retroarch -L $(desktop_exec_arg "$core_path") $(desktop_exec_arg "$game_path")")

cat >"$desktop_file" <<EOF
[Desktop Entry]
Version=1.0
Name=$desktop_name
Comment=Play $game_name with RetroArch
Exec=retroarch -L "$core_path" "$game_path"
Name=$name_field
Comment=$comment_field
Exec=$exec_field
Terminal=false
Type=Application
Icon=retro-gaming
Expand Down
16 changes: 12 additions & 4 deletions bin/omarchy-launch-or-focus
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
#!/bin/bash

# omarchy:summary=Launch an app or focus an existing window matching a pattern
# omarchy:args=<window-pattern> <launch-command>
# omarchy:args=<window-pattern> [<launch-command>|-- <command> [args...]]

if (($# == 0)); then
echo "Usage: omarchy-launch-or-focus [window-pattern] [launch-command]"
echo "Usage: omarchy-launch-or-focus [window-pattern] [launch-command|-- command [args...]]"
exit 1
fi

WINDOW_PATTERN="$1"
LAUNCH_COMMAND="${2:-"uwsm-app -- $WINDOW_PATTERN"}"
WINDOW_ADDRESS=$(hyprctl clients -j | jq -r --arg p "$WINDOW_PATTERN" '.[]|select((.class|test("\\b" + $p + "\\b";"i")) or (.title|test("\\b" + $p + "\\b";"i")))|.address' | head -n1)

if [[ -n $WINDOW_ADDRESS ]]; then
hyprctl dispatch "hl.dsp.focus({ window = \"address:$WINDOW_ADDRESS\" })" >/dev/null 2>&1 || hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS"
elif [[ ${2:-} == "--" ]]; then
shift 2
if (($# == 0)); then
echo "Usage: omarchy-launch-or-focus [window-pattern] [launch-command|-- command [args...]]" >&2
exit 1
fi
exec setsid "$@"
elif (($# >= 2)); then
eval exec setsid "$2"
else
eval exec setsid $LAUNCH_COMMAND
exec setsid uwsm-app -- "$WINDOW_PATTERN"
fi
32 changes: 28 additions & 4 deletions bin/omarchy-launch-or-focus-tui
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,36 @@
# omarchy:summary=Launch a TUI or focus an existing terminal window for it
# omarchy:args=[--app-id=<app-id>] <command> [args...]

if (($# == 0)); then
echo "Usage: omarchy-launch-or-focus-tui [--app-id=<app-id>] <command> [args...]" >&2
exit 1
fi

APP_ID=""
APP_ID_ARGS=()
if [[ ${1:-} == --app-id=* ]]; then
APP_ID="${1#--app-id=}"
else
APP_ID="org.omarchy.$(basename "$1")"
APP_ID_ARGS=("$1")
shift
fi

LAUNCH_COMMAND="omarchy-launch-tui $@"
if (($# == 0)); then
echo "Usage: omarchy-launch-or-focus-tui [--app-id=<app-id>] <command> [args...]" >&2
exit 1
fi

exec omarchy-launch-or-focus "$APP_ID" "$LAUNCH_COMMAND"
# Preserve legacy single-string command invocations (e.g. from Hyprland
# helpers.lua or user menu extensions) via the existing eval path so tilde
# expansion and quoting continue to work, while multi-arg calls bypass eval.
if (($# == 1)) && [[ $1 == *[[:space:]]* && ! -x $1 ]]; then
read -r first _ <<<"$1"
if [[ -z $APP_ID ]]; then
APP_ID="org.omarchy.$(basename -- "${first:-$1}")"
fi
exec omarchy-launch-or-focus "$APP_ID" "omarchy-launch-tui ${APP_ID_ARGS[0]:+${APP_ID_ARGS[0]@Q} }$1"
Comment thread
dhh marked this conversation as resolved.
Resolved
else
if [[ -z $APP_ID ]]; then
APP_ID="org.omarchy.$(basename -- "$1")"
fi
exec omarchy-launch-or-focus "$APP_ID" -- omarchy-launch-tui "${APP_ID_ARGS[@]}" "$@"
fi
3 changes: 1 addition & 2 deletions bin/omarchy-launch-or-focus-webapp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ fi

WINDOW_PATTERN="$1"
shift
LAUNCH_COMMAND="omarchy-launch-webapp $@"

exec omarchy-launch-or-focus "$WINDOW_PATTERN" "$LAUNCH_COMMAND"
exec omarchy-launch-or-focus "$WINDOW_PATTERN" -- omarchy-launch-webapp "$@"
4 changes: 2 additions & 2 deletions bin/omarchy-launch-tui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [[ ${1:-} == --app-id=* ]]; then
APP_ID="${1#--app-id=}"
shift
else
APP_ID="org.omarchy.$(basename $1)"
APP_ID="org.omarchy.$(basename -- "$1")"
fi

# An agent runs its commands with colors and paging switched off (NO_COLOR=1 with
Expand All @@ -19,4 +19,4 @@ if [[ ${NO_COLOR:-} == "1" && ${PAGER:-} == "cat" ]]; then
[[ ${GIT_PAGER:-} == "cat" ]] && unset GIT_PAGER
fi

exec setsid uwsm-app -- xdg-terminal-exec --app-id=$APP_ID -e "$1" "${@:2}"
exec setsid uwsm-app -- xdg-terminal-exec --app-id="$APP_ID" -e "$1" "${@:2}"
2 changes: 1 addition & 1 deletion bin/omarchy-launch-webapp
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ if [[ -z $browser_exec ]]; then
fi

if ! omarchy-cmd-browser-handoff "$browser_exec" --app="$1" "${@:2}"; then
exec setsid uwsm-app -- $browser_exec --app="$1" "${@:2}"
exec setsid uwsm-app -- "$browser_exec" --app="$1" "${@:2}"
fi
15 changes: 9 additions & 6 deletions bin/omarchy-menu-images
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ if (( ${#image_dirs[@]} == 0 )); then
exit 1
fi

selection_file=$(mktemp)
done_file=$(mktemp)
pending_file=$(mktemp)
pending_video_file=$(mktemp)
rm -f "$done_file"
trap 'rm -f "$selection_file" "$done_file" "$pending_file" "$pending_video_file"' EXIT
work_dir=$(mktemp -d)
selection_file="$work_dir/selection"
done_file="$work_dir/done"
pending_file="$work_dir/pending"
pending_video_file="$work_dir/pending-video"
: >"$selection_file"
: >"$pending_file"
: >"$pending_video_file"
trap 'rm -rf "$work_dir"' EXIT

image_dirs_env=""
for dir in "${image_dirs[@]}"; do
Expand Down
9 changes: 5 additions & 4 deletions bin/omarchy-menu-input
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ while (( $# > 0 )); do
shift
done

selection_file=$(mktemp)
done_file=$(mktemp)
rm -f "$done_file"
trap 'rm -f "$selection_file" "$done_file"' EXIT
work_dir=$(mktemp -d)
selection_file="$work_dir/selection"
done_file="$work_dir/done"
: >"$selection_file"
trap 'rm -rf "$work_dir"' EXIT

payload=$(jq -nc \
--arg prompt "$prompt" \
Expand Down
9 changes: 5 additions & 4 deletions bin/omarchy-menu-select
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ if (( ${#options[@]} == 0 )); then
exit 1
fi

selection_file=$(mktemp)
done_file=$(mktemp)
rm -f "$done_file"
trap 'rm -f "$selection_file" "$done_file"' EXIT
work_dir=$(mktemp -d)
selection_file="$work_dir/selection"
done_file="$work_dir/done"
: >"$selection_file"
trap 'rm -rf "$work_dir"' EXIT

payload=$(
if (( ${#selected[@]} > 0 )); then
Expand Down
2 changes: 1 addition & 1 deletion bin/omarchy-theme-set-herdr-machines
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ for target in $targets; do
result=$(printf 'theme=%q from=%q\n%s\n' "$theme" "$(hostname)" "$REMOTE_SCRIPT" |
timeout 60 ssh -o BatchMode=yes -o ConnectTimeout=5 \
-o ControlMaster=auto -o ControlPersist=600 -o "ControlPath=$control_dir/%C" \
"$target" bash -l -s 2>&1 | tail -n 1)
-- "$target" bash -l -s 2>&1 | tail -n 1)
echo "$(date '+%F %T') $target: ${result:-unreachable}"
done
64 changes: 55 additions & 9 deletions bin/omarchy-tui-install
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,40 @@ set -e
ICON_DIR="$HOME/.local/share/icons/hicolor/256x256/apps"

safe_icon_name() {
printf '%s\n' "$1" \
local name
name=$(printf '%s\n' "$1" \
| tr '[:upper:]' '[:lower:]' \
| sed 's/[^[:alnum:]]\+/-/g; s/^-//; s/-$//'
| sed 's/[^[:alnum:]]\+/-/g; s/^-//; s/-$//')
if [[ -n $name ]]; then
printf '%s\n' "$name"
else
printf 'tui-%s\n' "$(printf '%s' "$1" | sha256sum | cut -c1-12)"
fi
}

require_plain_name() {
if [[ $1 == */* || $1 == "." || $1 == ".." ]]; then
echo "App name cannot contain '/' or be '.'/'..': $1" >&2
exit 1
fi
}

desktop_string_escape() {
local value="$1"

value=${value//\\/\\\\}
value=${value//$'\t'/\\t}
value=${value//$'\r'/\\r}
value=${value//$'\n'/\\n}
[[ $value == " "* ]] && value="\\s${value# }"

printf '%s' "$value"
}

icon_name_from_ref() {
local ref="$1"
local name
name=$(basename "$ref")
name=$(basename -- "$ref")

if [[ $name == *.* ]]; then
safe_icon_name "${name%.*}"
Expand All @@ -32,14 +57,29 @@ install_user_icon() {

[[ $ext == "$source" ]] && ext="png"
mkdir -p "$ICON_DIR"
cp "$source" "$ICON_DIR/$name.$ext"
cp -- "$source" "$ICON_DIR/$name.$ext"
gtk-update-icon-cache "$HOME/.local/share/icons/hicolor" &>/dev/null || true
printf '%s\n' "$name"
}

download_icon() {
local tmp
tmp=$(mktemp "$(dirname "$2")/.icon.XXXXXX") || return 1
if curl -fsSL --max-time 10 -o "$tmp" -- "$1" 2>/dev/null &&
[[ -s $tmp && $(file -b --mime-type "$tmp") == image/* ]]; then
chmod 644 "$tmp"
mv -f "$tmp" "$2"
return 0
else
rm -f "$tmp"
return 1
fi
}

if (( $# != 4 )); then
echo -e "\e[32m$(omarchy-i18n tui.intro)\n\e[0m"
APP_NAME=$(gum input --prompt "$(omarchy-i18n tui.namePrompt)" --placeholder "$(omarchy-i18n tui.namePlaceholder)")
require_plain_name "$APP_NAME"
APP_EXEC=$(gum input --prompt "$(omarchy-i18n tui.commandPrompt)" --placeholder "$(omarchy-i18n tui.commandPlaceholder "lazydocker" "bash -c 'dust; read -n 1 -s'")")
WINDOW_STYLE=$(gum choose --header "$(omarchy-i18n tui.windowStyle)" float tile)
ICON_REF=$(gum input --prompt "$(omarchy-i18n tui.iconPrompt)" --placeholder "$(omarchy-i18n tui.iconPlaceholder "https://dashboardicons.com")")
Expand All @@ -55,13 +95,15 @@ if [[ -z $APP_NAME || -z $APP_EXEC || -z $ICON_REF ]]; then
exit 1
fi

require_plain_name "$APP_NAME"

DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop"
mkdir -p "$(dirname "$DESKTOP_FILE")"

if [[ $ICON_REF =~ ^https?:// ]]; then
ICON_VALUE=$(safe_icon_name "$APP_NAME")
mkdir -p "$ICON_DIR"
if ! curl -sL -o "$ICON_DIR/$ICON_VALUE.png" "$ICON_REF"; then
if ! download_icon "$ICON_REF" "$ICON_DIR/$ICON_VALUE.png"; then
echo "Error: Failed to download icon."
exit 1
fi
Expand All @@ -79,15 +121,19 @@ else
APP_CLASS="TUI.tile"
fi

name_field=$(desktop_string_escape "$APP_NAME")
exec_field=$(desktop_string_escape "xdg-terminal-exec --app-id=$APP_CLASS -e $APP_EXEC")
icon_field=$(desktop_string_escape "$ICON_VALUE")

cat >"$DESKTOP_FILE" <<EOF
[Desktop Entry]
Version=1.0
Name=$APP_NAME
Comment=$APP_NAME
Exec=xdg-terminal-exec --app-id=$APP_CLASS -e $APP_EXEC
Name=$name_field
Comment=$name_field
Exec=$exec_field
Terminal=false
Type=Application
Icon=$ICON_VALUE
Icon=$icon_field
StartupNotify=true
EOF

Expand Down
Loading