From 6423eaa29d158eff46ff91b04986aaf33de533b0 Mon Sep 17 00:00:00 2001 From: Tri Vo Khac Date: Thu, 29 Oct 2026 00:02:43 +0700 Subject: [PATCH] =?UTF-8?q?feat(tray-icons):=20add=20Breeze-style=20Ng?= =?UTF-8?q?=C3=B3=20Sen=20icons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++ .../.local/share/ngosen-breeze-icons/apply.sh | 24 ++++++++++++++ .../icons/fcitx-ngosen-default-black.svg | 5 +++ .../icons/fcitx-ngosen-default.svg | 5 +++ .../fcitx-ngosen-emoji-default-black.svg | 5 +++ .../icons/fcitx-ngosen-emoji-default.svg | 5 +++ .../icons/fcitx-ngosen-off-default-black.svg | 5 +++ .../icons/fcitx-ngosen-off-default.svg | 5 +++ .../share/ngosen-breeze-icons/install.sh | 33 +++++++++++++++++++ .../ngosen-breeze-icons.hook | 10 ++++++ .../ngosen-breeze-icons/restart-fcitx5.sh | 7 ++++ .../share/ngosen-breeze-icons/restore.sh | 14 ++++++++ tray-icons/README.md | 32 ++++++++++++++++++ 13 files changed, 155 insertions(+) create mode 100755 tray-icons/.local/share/ngosen-breeze-icons/apply.sh create mode 100644 tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default-black.svg create mode 100644 tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default.svg create mode 100644 tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default-black.svg create mode 100644 tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default.svg create mode 100644 tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default-black.svg create mode 100644 tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default.svg create mode 100755 tray-icons/.local/share/ngosen-breeze-icons/install.sh create mode 100644 tray-icons/.local/share/ngosen-breeze-icons/ngosen-breeze-icons.hook create mode 100755 tray-icons/.local/share/ngosen-breeze-icons/restart-fcitx5.sh create mode 100755 tray-icons/.local/share/ngosen-breeze-icons/restore.sh create mode 100644 tray-icons/README.md diff --git a/README.md b/README.md index a5fc3c4..2872ced 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,11 @@ git -C $HOME clone https://github.com/vokhactri/.dotfiles.git && cd $HOME/.dotfi exec zsh ``` +### `tray-icons` (tray icons that match Breeze) + +Some icons need an extra step after `stow tray-icons` (a root step for +Ngó Sen); see [`tray-icons/README.md`](tray-icons/README.md). + ## Credit - [Machfiles](https://github.com/ChristianChiarulli/Machfiles/) diff --git a/tray-icons/.local/share/ngosen-breeze-icons/apply.sh b/tray-icons/.local/share/ngosen-breeze-icons/apply.sh new file mode 100755 index 0000000..02fd243 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/apply.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copy the Breeze-style icons over Ngó Sen's monochrome tray icons. +# Runs as root; the pacman hook re-runs it after every fcitx5-ngosen install/upgrade. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +ROOT=${ROOT:-} # for dry-run testing only + +# Ngó Sen points at hicolor, but Plasma looks the icon up by name in breeze/breeze-dark +dirs=(usr/share/icons/hicolor/scalable/{apps,status} + usr/share/icons/breeze{,-dark}/status/{22,24}) +mtree=$(zcat "$ROOT"/var/lib/pacman/local/fcitx5-ngosen-*/mtree 2>/dev/null || true) + +for d in "${dirs[@]}"; do + for f in "$here"/icons/*.svg; do + n=$(basename "$f"); t=$ROOT/$d/$n + [[ -f $t ]] || continue + # Still the file the package installed: keep it as the original for restore.sh + sum=$(grep -F "./$d/$n " <<<"$mtree" | grep -o 'sha256digest=[0-9a-f]*' | cut -d= -f2 || true) + if [[ -n $sum && $(sha256sum <"$t" | cut -d' ' -f1) == "$sum" ]]; then + install -Dm644 "$t" "$here/orig/$d/$n" + fi + install -m644 "$f" "$t" + done +done diff --git a/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default-black.svg b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default-black.svg new file mode 100644 index 0000000..ec275b8 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default-black.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default.svg b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default.svg new file mode 100644 index 0000000..c465d87 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-default.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default-black.svg b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default-black.svg new file mode 100644 index 0000000..92ec556 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default-black.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default.svg b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default.svg new file mode 100644 index 0000000..41fd9da --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-emoji-default.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default-black.svg b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default-black.svg new file mode 100644 index 0000000..68f2608 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default-black.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default.svg b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default.svg new file mode 100644 index 0000000..7ace9ca --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/icons/fcitx-ngosen-off-default.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/tray-icons/.local/share/ngosen-breeze-icons/install.sh b/tray-icons/.local/share/ngosen-breeze-icons/install.sh new file mode 100755 index 0000000..85b2418 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/install.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Install Breeze-style tray icons for Ngó Sen. Usage: sudo ./install.sh +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +ROOT=${ROOT:-} # for dry-run testing only +[[ $EUID -eq 0 || -n $ROOT ]] || { echo "Must be run with sudo"; exit 1; } +owner=${SUDO_USER:-$(id -un "${PKEXEC_UID:-0}")} +dest=$ROOT/usr/local/share/ngosen-breeze-icons + +install -d "$dest/icons" +install -m644 "$here"/icons/*.svg "$dest/icons/" +install -m755 "$here/apply.sh" "$dest/apply.sh" +install -Dm644 "$here/ngosen-breeze-icons.hook" "$ROOT/etc/pacman.d/hooks/ngosen-breeze-icons.hook" +# Older versions used NoUpgrade in pacman.conf; the hook replaces it +sed -i '/^# ngosen-breeze-icons$/,+1d' "$ROOT/etc/pacman.conf" +ROOT=$ROOT "$dest/apply.sh" + +# Ngó Sen: use the monochrome icons (not the lotus ones), white for a dark panel +conf=$ROOT$(getent passwd "$owner" | cut -d: -f6)/.config/fcitx5/conf/ngosen.conf +as_owner() { if [[ -n $ROOT ]]; then "$@"; else runuser -u "$owner" -- "$@"; fi; } +if [[ -f $conf ]]; then + for kv in UseLotusIcons=False IconTheme=Dark; do + k=${kv%%=*} + if grep -q "^$k=" "$conf"; then as_owner sed -i "s/^$k=.*/$kv/" "$conf" + elif grep -q "^# $k=" "$conf"; then as_owner sed -i "s/^# $k=.*/$kv/" "$conf" + else as_owner sh -c "echo '$kv' >> '$conf'"; fi + done +else + as_owner install -Dm600 /dev/stdin "$conf" <<<$'UseLotusIcons=False\nIconTheme=Dark' +fi + +echo "Done. Restart fcitx5 and plasmashell (without sudo):" +echo " $here/restart-fcitx5.sh; systemctl --user restart plasma-plasmashell" diff --git a/tray-icons/.local/share/ngosen-breeze-icons/ngosen-breeze-icons.hook b/tray-icons/.local/share/ngosen-breeze-icons/ngosen-breeze-icons.hook new file mode 100644 index 0000000..fdd6b03 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/ngosen-breeze-icons.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = fcitx5-ngosen + +[Action] +Description = Applying Breeze-style tray icons for Ngó Sen... +When = PostTransaction +Exec = /usr/local/share/ngosen-breeze-icons/apply.sh diff --git a/tray-icons/.local/share/ngosen-breeze-icons/restart-fcitx5.sh b/tray-icons/.local/share/ngosen-breeze-icons/restart-fcitx5.sh new file mode 100755 index 0000000..e4deef5 --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/restart-fcitx5.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Restart fcitx5 through KWin (KDE Wayland) so it keeps the Wayland input method frontend. +L=$(kreadconfig6 --file kwinrc --group Wayland --key InputMethod) +[[ -n $L ]] || L=/usr/share/applications/fcitx5-wayland-launcher.desktop +pkill -x fcitx5; sleep 1 +kwriteconfig6 --notify --file kwinrc --group Wayland --key InputMethod --delete; sleep 1 +kwriteconfig6 --notify --file kwinrc --group Wayland --key InputMethod "$L" diff --git a/tray-icons/.local/share/ngosen-breeze-icons/restore.sh b/tray-icons/.local/share/ngosen-breeze-icons/restore.sh new file mode 100755 index 0000000..e50276f --- /dev/null +++ b/tray-icons/.local/share/ngosen-breeze-icons/restore.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Put Ngó Sen's original icons back and remove the hook. Usage: sudo ./restore.sh +set -euo pipefail +ROOT=${ROOT:-} # for dry-run testing only +[[ $EUID -eq 0 || -n $ROOT ]] || { echo "Must be run with sudo"; exit 1; } +dest=$ROOT/usr/local/share/ngosen-breeze-icons +[[ -d $dest/orig/usr ]] || { echo "No original icons in $dest/orig"; exit 1; } +(cd "$dest/orig" && find usr -name '*.svg' -print0) | while IFS= read -r -d '' f; do + install -m644 "$dest/orig/$f" "$ROOT/$f" +done +rm -f "$ROOT/etc/pacman.d/hooks/ngosen-breeze-icons.hook" +rm -rf "$dest" +echo "Restored. To get the lotus icons back, turn them on in Ngó Sen Settings." +echo "Restart plasmashell (without sudo): systemctl --user restart plasma-plasmashell" diff --git a/tray-icons/README.md b/tray-icons/README.md new file mode 100644 index 0000000..370834a --- /dev/null +++ b/tray-icons/README.md @@ -0,0 +1,32 @@ +# Tray icons that match Breeze + +```sh +stow tray-icons +``` + +Some icons need one more step after stowing; see below. + +## Ngó Sen (fcitx5-ngosen) + +Replaces Ngó Sen's monochrome tray icons with a V/E inside a rounded frame. + +```sh +sudo ~/.local/share/ngosen-breeze-icons/install.sh +~/.local/share/ngosen-breeze-icons/restart-fcitx5.sh +systemctl --user restart plasma-plasmashell +``` + +- Ngó Sen points the tray at `/usr/share/icons/hicolor`, but Plasma looks + the icon up by name in the `breeze`/`breeze-dark` themes under + `/usr/share` and ignores `~/.local/share/icons`, so the system files have + to be replaced. +- `install.sh` copies the icons and `apply.sh` to + `/usr/local/share/ngosen-breeze-icons/`, installs the pacman hook + `/etc/pacman.d/hooks/ngosen-breeze-icons.hook` to re-apply them after + every package upgrade, and sets `UseLotusIcons=False` and + `IconTheme=Dark` in `~/.config/fcitx5/conf/ngosen.conf`. +- The original icons are kept in `/usr/local/share/ngosen-breeze-icons/orig/`; + `sudo ~/.local/share/ngosen-breeze-icons/restore.sh` puts them back and + removes the hook. +- On KDE Wayland don't start fcitx5 with `fcitx5 -d`; use + `restart-fcitx5.sh` so KWin launches it.