Refactor toggles and notifications
This commit is contained in:
@@ -10,34 +10,44 @@ MIRROR_TOGGLE="internal-monitor-mirror"
|
|||||||
# Get internal monitor name dynamically
|
# Get internal monitor name dynamically
|
||||||
INTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | contains("eDP")).name' | head -n 1)
|
INTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | contains("eDP")).name' | head -n 1)
|
||||||
|
|
||||||
enable() {
|
on() {
|
||||||
if omarchy-hyprland-toggle-enabled "$TOGGLE"; then
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
||||||
omarchy-hyprland-toggle --disabled-notification " Laptop display enabled" "$TOGGLE"
|
omarchy-hyprland-toggle $TOGGLE off
|
||||||
|
omarchy-notification-send -g "Laptop display enabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
off() {
|
||||||
if ! omarchy-hw-external-monitors; then
|
if ! omarchy-hw-external-monitors; then
|
||||||
notify-send -u low " Can't disable the only active display"
|
omarchy-notification-send -g "Can't disable the only active display"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if omarchy-hyprland-toggle-disabled "$TOGGLE" && omarchy-hyprland-toggle-disabled "$MIRROR_TOGGLE"; then
|
|
||||||
|
if omarchy-hyprland-toggle-disabled $TOGGLE && omarchy-hyprland-toggle-disabled $MIRROR_TOGGLE; then
|
||||||
echo "monitor=$INTERNAL,disable" >"$TOGGLE_FLAG"
|
echo "monitor=$INTERNAL,disable" >"$TOGGLE_FLAG"
|
||||||
notify-send -u low " Laptop display disabled"
|
omarchy-notification-send -g "Laptop display disabled"
|
||||||
hyprctl reload
|
hyprctl reload
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
recover() {
|
recover() {
|
||||||
if ! omarchy-hw-external-monitors && omarchy-hyprland-toggle-enabled "$TOGGLE"; then
|
if ! omarchy-hw-external-monitors; then
|
||||||
omarchy-hyprland-toggle "$TOGGLE"
|
omarchy-hyprland-toggle $TOGGLE off
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle() {
|
||||||
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
||||||
|
on
|
||||||
|
else
|
||||||
|
off
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
on) enable ;;
|
on) on ;;
|
||||||
off) disable ;;
|
off) off ;;
|
||||||
toggle) if omarchy-hyprland-toggle-enabled "$TOGGLE"; then enable; else disable; fi ;;
|
toggle) toggle ;;
|
||||||
recover) recover ;;
|
recover) recover ;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
|
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
|
||||||
|
|||||||
@@ -12,44 +12,48 @@ INTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | contains("eDP")).na
|
|||||||
# Get the first available external monitor
|
# Get the first available external monitor
|
||||||
EXTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | contains("eDP") | not).name' | head -n 1)
|
EXTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | contains("eDP") | not).name' | head -n 1)
|
||||||
|
|
||||||
enable() {
|
on() {
|
||||||
if [[ -z "$EXTERNAL" ]]; then
|
if [[ -z $EXTERNAL ]]; then
|
||||||
notify-send -u low " No external monitors found for mirror"
|
omarchy-notification-send -g "No external monitors found for mirror"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$INTERNAL" ]]; then
|
if [[ -z $INTERNAL ]]; then
|
||||||
notify-send -u low " No laptop monitor found to mirror"
|
omarchy-notification-send -g "No laptop monitor found to mirror"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if omarchy-hyprland-toggle-enabled "$DISABLE_TOGGLE"; then
|
omarchy-hyprland-toggle $DISABLE_TOGGLE off
|
||||||
omarchy-hyprland-toggle "$DISABLE_TOGGLE"
|
echo "monitor=$EXTERNAL, preferred, auto, 1, mirror, $INTERNAL" >"$TOGGLE_FLAG"
|
||||||
fi
|
omarchy-notification-send -g "Mirroring enabled ($EXTERNAL)"
|
||||||
|
hyprctl reload
|
||||||
|
}
|
||||||
|
|
||||||
if omarchy-hyprland-toggle-disabled "$TOGGLE"; then
|
off() {
|
||||||
echo "monitor=$EXTERNAL, preferred, auto, 1, mirror, $INTERNAL" > "$TOGGLE_FLAG"
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
||||||
notify-send -u low " Mirroring enabled ($EXTERNAL)"
|
omarchy-hyprland-toggle $TOGGLE off
|
||||||
hyprctl reload
|
omarchy-notification-send -g "Extended mode restored"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
toggle() {
|
||||||
if omarchy-hyprland-toggle-enabled "$TOGGLE"; then
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
||||||
omarchy-hyprland-toggle --disabled-notification " Extended mode restored" "$TOGGLE"
|
off
|
||||||
|
else
|
||||||
|
on
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
recover() {
|
recover() {
|
||||||
if ! omarchy-hw-external-monitors && omarchy-hyprland-toggle-enabled "$TOGGLE"; then
|
if ! omarchy-hw-external-monitors; then
|
||||||
omarchy-hyprland-toggle "$TOGGLE"
|
omarchy-hyprland-toggle $TOGGLE off
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
on) enable ;;
|
on) on ;;
|
||||||
off) disable ;;
|
off) off ;;
|
||||||
toggle) if omarchy-hyprland-toggle-enabled "$TOGGLE"; then disable; else enable; fi ;;
|
toggle) toggle ;;
|
||||||
recover) recover ;;
|
recover) recover ;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
|
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
|
||||||
|
|||||||
+36
-23
@@ -1,32 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Toggle permanent Hyprland flags by copying them into a directory that's sourced entirely.
|
# omarchy:summary=Toggle permanent Hyprland flags by copying them into a directory that's sourced entirely.
|
||||||
# omarchy:args=[--enabled-notification <text>] [--disabled-notification <text>] <flag-name>
|
# omarchy:args=<flag-name> [on|off]
|
||||||
|
|
||||||
ENABLED_NOTIFICATION=""
|
|
||||||
DISABLED_NOTIFICATION=""
|
|
||||||
|
|
||||||
while [[ $# -gt 1 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--enabled-notification) ENABLED_NOTIFICATION="$2"; shift 2 ;;
|
|
||||||
--disabled-notification) DISABLED_NOTIFICATION="$2"; shift 2 ;;
|
|
||||||
*) break ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
FLAG_NAME="$1"
|
FLAG_NAME="$1"
|
||||||
|
ACTION="${2:-toggle}"
|
||||||
FLAG="$HOME/.local/state/omarchy/toggles/hypr/$FLAG_NAME.conf"
|
FLAG="$HOME/.local/state/omarchy/toggles/hypr/$FLAG_NAME.conf"
|
||||||
FLAG_SOURCE="$OMARCHY_PATH/default/hypr/toggles/$FLAG_NAME.conf"
|
FLAG_SOURCE="$OMARCHY_PATH/default/hypr/toggles/$FLAG_NAME.conf"
|
||||||
|
|
||||||
if [[ -f $FLAG ]]; then
|
on() {
|
||||||
rm $FLAG
|
if [[ -f $FLAG_SOURCE ]]; then
|
||||||
[[ -n $DISABLED_NOTIFICATION ]] && notify-send -u low "$DISABLED_NOTIFICATION"
|
mkdir -p "$(dirname "$FLAG")"
|
||||||
elif [[ -f $FLAG_SOURCE ]]; then
|
cp "$FLAG_SOURCE" "$FLAG"
|
||||||
cp $FLAG_SOURCE $FLAG
|
echo "on"
|
||||||
[[ -n $ENABLED_NOTIFICATION ]] && notify-send -u low "$ENABLED_NOTIFICATION"
|
else
|
||||||
else
|
echo "Flag not found: $FLAG_NAME"
|
||||||
echo "Flag not found: $FLAG_NAME"
|
exit 1
|
||||||
exit 1
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
hyprctl reload
|
off() {
|
||||||
|
rm -f "$FLAG"
|
||||||
|
echo "off"
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle() {
|
||||||
|
if [[ -f $FLAG ]]; then
|
||||||
|
off
|
||||||
|
else
|
||||||
|
on
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case $ACTION in
|
||||||
|
on) on ;;
|
||||||
|
off) off ;;
|
||||||
|
toggle) toggle ;;
|
||||||
|
*)
|
||||||
|
echo "Usage: omarchy-hyprland-toggle <flag-name> [on|off]"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
hyprctl reload >/dev/null
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# omarchy:summary=Toggle single-window square aspect ratio.
|
# omarchy:summary=Toggle single-window square aspect ratio.
|
||||||
|
|
||||||
omarchy-hyprland-toggle \
|
case $(omarchy-hyprland-toggle single-window-aspect-ratio) in
|
||||||
--enabled-notification " Enable single-window square aspect ratio" \
|
on) omarchy-notification-send -g "Enable single-window square aspect ratio" ;;
|
||||||
--disabled-notification " Disable single-window square aspect ratio" \
|
off) omarchy-notification-send -g "Disable single-window square aspect ratio" ;;
|
||||||
single-window-aspect-ratio
|
esac
|
||||||
|
|||||||
@@ -1,32 +1,51 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Send a desktop notification with Omarchy glyph and body spacing
|
# omarchy:summary=Send a desktop notification with Omarchy glyph and body spacing
|
||||||
# omarchy:args=<glyph> <headline> [description] [notify-send options]
|
# omarchy:args=<headline> [description] [-g <glyph>] [-u <low|normal|critical>] [notify-send options]
|
||||||
# omarchy:examples=omarchy notification send "" "Reminder" "5 minutes are up" -u critical
|
# omarchy:examples=omarchy notification send "Reminder" "5 minutes are up" -g -u critical
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if (($# < 2)); then
|
if (($# < 1)); then
|
||||||
echo "Usage: omarchy-notification-send <glyph> <headline> [description] [notify-send options]"
|
echo "Usage: omarchy-notification-send <headline> [description] [-g <glyph>] [-u <low|normal|critical>] [notify-send options]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
glyph=$1
|
headline=$1
|
||||||
headline=$2
|
description=""
|
||||||
description=${3:-}
|
glyph=""
|
||||||
shift 2
|
urgency="low"
|
||||||
|
args=()
|
||||||
|
shift
|
||||||
|
|
||||||
if (($# > 0)) && [[ $1 != -* ]]; then
|
if (($# > 0)) && [[ $1 != -* ]]; then
|
||||||
|
description=$1
|
||||||
shift
|
shift
|
||||||
else
|
|
||||||
description=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
while (($# > 0)); do
|
||||||
|
case $1 in
|
||||||
|
-g|--glyph)
|
||||||
|
glyph="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-u|--urgency)
|
||||||
|
urgency="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
args+=("$1")
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
summary="$glyph $headline"
|
summary="$glyph $headline"
|
||||||
|
args+=("-u" "$urgency")
|
||||||
|
|
||||||
if [[ -n $description ]]; then
|
if [[ -n $description ]]; then
|
||||||
description=$(sed 's/^/ /' <<<"$description")
|
description=$(printf '%b' "$description" | sed 's/^/ /')
|
||||||
notify-send "$@" "$summary" "$description"
|
notify-send "${args[@]}" "$summary" "$description"
|
||||||
else
|
else
|
||||||
notify-send "$@" "$summary"
|
notify-send "${args[@]}" "$summary"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ show_reminders() {
|
|||||||
done < <(systemctl --user list-timers --all --output=json "omarchy-reminder-*.timer" 2>/dev/null | jq -r '.[] | [.unit, .next] | @tsv')
|
done < <(systemctl --user list-timers --all --output=json "omarchy-reminder-*.timer" 2>/dev/null | jq -r '.[] | [.unit, .next] | @tsv')
|
||||||
|
|
||||||
if [[ -z $body ]]; then
|
if [[ -z $body ]]; then
|
||||||
omarchy-notification-send "" "Upcoming reminders" "No outstanding reminders" -u low
|
omarchy-notification-send -g "Upcoming reminders" "No outstanding reminders"
|
||||||
else
|
else
|
||||||
omarchy-notification-send "" "Upcoming reminders" "${body%$'\n'}" -u low
|
omarchy-notification-send -g "Upcoming reminders" "${body%$'\n'}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ clear_reminders() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$reminder_dir"/omarchy-reminder-*.message 2>/dev/null || true
|
rm -f "$reminder_dir"/omarchy-reminder-*.message 2>/dev/null || true
|
||||||
omarchy-notification-send "" "All reminders have been cleared" -u low
|
omarchy-notification-send -g "All reminders have been cleared"
|
||||||
}
|
}
|
||||||
|
|
||||||
case ${1:-} in
|
case ${1:-} in
|
||||||
@@ -131,6 +131,6 @@ if [[ -n $custom_message ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
systemd-run --user --quiet --collect --on-active="${minutes}m" --unit="$unit" \
|
systemd-run --user --quiet --collect --on-active="${minutes}m" --unit="$unit" \
|
||||||
bash -c 'omarchy-notification-send "" "Reminder" "$1" -u critical; rm -f "$2"' bash "$message" "$message_file"
|
bash -c 'omarchy-notification-send -g "Reminder" "$1" -u critical; rm -f "$2"' bash "$message" "$message_file"
|
||||||
|
|
||||||
omarchy-notification-send "" "$confirmation_title" "$confirmation" -u low
|
omarchy-notification-send -g "$confirmation_title" "$confirmation"
|
||||||
|
|||||||
@@ -193,14 +193,14 @@ main() {
|
|||||||
output=$(output_path "$input" "$format" "$resolution")
|
output=$(output_path "$input" "$format" "$resolution")
|
||||||
|
|
||||||
if [[ $type == "video" ]]; then
|
if [[ $type == "video" ]]; then
|
||||||
omarchy-notification-send "" "Transcoding video…" "$(basename -- "$input") to $format ($resolution)"
|
omarchy-notification-send -g "Transcoding video…" "$(basename -- "$input") to $format ($resolution)"
|
||||||
transcode_video "$input" "$format" "$resolution" "$output"
|
transcode_video "$input" "$format" "$resolution" "$output"
|
||||||
copy_to_clipboard "$output"
|
copy_to_clipboard "$output"
|
||||||
omarchy-notification-send "" "Transcoded to $resolution $format" "Saved and copied to clipboard."
|
omarchy-notification-send -g "Transcoded to $resolution $format" "Saved and copied to clipboard."
|
||||||
else
|
else
|
||||||
transcode_picture "$input" "$format" "$resolution" "$output"
|
transcode_picture "$input" "$format" "$resolution" "$output"
|
||||||
copy_to_clipboard "$output"
|
copy_to_clipboard "$output"
|
||||||
omarchy-notification-send "" "Transcoded to $resolution $format" "Saved and copied to clipboard."
|
omarchy-notification-send -g "Transcoded to $resolution $format" "Saved and copied to clipboard."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user