Skip to content
Closed
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: 7 additions & 0 deletions bin/omarchy-cursor-current
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

CONFIG_FILE="$HOME/.config/hypr/envs.conf"

[[ ! -f "$CONFIG_FILE" ]] && exit

grep 'env = HYPRCURSOR_THEME' "$CONFIG_FILE" | cut -d ',' -f2 | tr -d ' ' | sed -E 's/-/ /g'
7 changes: 7 additions & 0 deletions bin/omarchy-cursor-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

find ~/.local/share/icons/ /usr/share/icons/ -mindepth 1 -maxdepth 2 -iname 'cursors' \( -type d -o -type l \) -exec dirname {} \; | sort | while read -r path; do
echo "$(
basename "$path" | sed -E 's/(^|-)([a-z])/\1\u\2/g; s/-/ /g'
)"
done
52 changes: 52 additions & 0 deletions bin/omarchy-cursor-set
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# omarchy-cursor-set: Set a cursor theme, specified by its name.
# Usage: omarchy-cursor-set <cursor-theme-name>

if [[ -z "$1" && "$1" != "CNCLD" ]]; then
echo "Usage: omarchy-cursor-set <cursor-theme-name>" >&2
exit 1
fi

GLOBAL_CURSOR_THEME_PATH="/usr/share/icons/"
LOCAL_CURSOR_THEME_PATH="$HOME/.local/share/icons"

CURSOR_THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr ' ' '-')
CURSOR_THEME_PATH=$(find $GLOBAL_CURSOR_THEME_PATH $LOCAL_CURSOR_THEME_PATH -maxdepth 1 -type d -iname "$CURSOR_THEME_NAME")

CURSOR_SIZE=${HYPRCURSOR_SIZE:-24}
CONFIG_FILE="$HOME/.config/hypr/envs.conf"

HYPR_ENV_LINE="env = HYPRCURSOR_THEME"
X_ENV_LINE="env = XCURSOR_THEME"

if [[ ! -d $CURSOR_THEME_PATH && ! -L $CURSOR_THEME_PATH ]]; then
echo "Cursor theme '$CURSOR_THEME_NAME' could not be found in $GLOBAL_CURSOR_THEME_PATH or $LOCAL_CURSOR_THEME_PATH"
exit 2
fi

if [[ ! -f "$CONFIG_FILE" ]]; then
echo "Cursor theme '$CURSOR_THEME_NAME' could not be applied. The config file $CONFIG_FILE does not exist"
exit 3
fi

# hyprcursor and xcursor are case sensitive so its
# important that the cursor theme name is the same
# as the path name
CURSOR_THEME_NAME=$(basename "$CURSOR_THEME_PATH")

if grep -q "^$HYPR_ENV_LINE," "$CONFIG_FILE"; then
sed -i "s|^$HYPR_ENV_LINE,.*|$HYPR_ENV_LINE,$CURSOR_THEME_NAME|" "$CONFIG_FILE"
else
echo "$HYPR_ENV_LINE,$CURSOR_THEME_NAME" >>"$CONFIG_FILE"
fi

if grep -q "^$X_ENV_LINE," "$CONFIG_FILE"; then
sed -i "s|^$X_ENV_LINE,.*|$X_ENV_LINE,$CURSOR_THEME_NAME|" "$CONFIG_FILE"
else
echo "$X_ENV_LINE,$CURSOR_THEME_NAME" >>"$CONFIG_FILE"
fi

hyprctl setcursor $CURSOR_THEME_NAME $CURSOR_SIZE

gsettings set org.gnome.desktop.interface cursor-theme "$CURSOR_THEME_NAME"
12 changes: 11 additions & 1 deletion bin/omarchy-menu
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ show_learn_menu() {
}

show_style_menu() {
case $(menu "Style" "󰸌 Theme\n Font\n Background\n󱄄 Screensaver\n About") in
case $(menu "Style" "󰸌 Theme\n Font\n󰇀 Cursor\n Background\n󱄄 Screensaver\n About") in
*Theme*) show_theme_menu ;;
*Font*) show_font_menu ;;
*Cursor*) show_cursor_menu ;;
*Background*) omarchy-theme-bg-next ;;
*Screensaver*) edit_in_nvim ~/.config/omarchy/branding/screensaver.txt ;;
*About*) edit_in_nvim ~/.config/omarchy/branding/about.txt ;;
Expand All @@ -95,6 +96,15 @@ show_font_menu() {
fi
}

show_cursor_menu() {
theme=$(menu "Cursor" "$(omarchy-cursor-list)" "-w 350" "$(omarchy-cursor-current)")
if [[ "$theme" == "CNCLD" || -z "$theme" ]]; then
show_main_menu
else
omarchy-cursor-set "$theme"
fi
}

show_capture_menu() {
case $(menu "Capture" " Screenshot\n Screenrecord\n󰃉 Color") in
*Screenshot*) show_screenshot_menu ;;
Expand Down