Skip to content

Commit f3da0d9

Browse files
wyu71Zeno-sole
authored andcommitted
fix: improve -r flag handling in fcitx5-start script
- Optimize -r flag detection with regex pattern matching - Remove force kill behavior in favor of smarter process handling - Improve process state detection logic Log: improve -r flag handling in fcitx5-start script pms: BUG-311649
1 parent 4af67be commit f3da0d9

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
fcitx5 (5.1.11-2deepin5) unstable; urgency=medium
2+
3+
* improve -r flag handling in fcitx5-start script
4+
5+
-- Wang Yu <wangyu@uniontch.com> Wed, 09 Apr 2025 10:40:27 +0800
6+
17
fcitx5 (5.1.11-2deepin4) unstable; urgency=medium
28

39
* add log management for fcitx5-start script.

debian/patches/0011-add-log-management-for-fcitx5-start-script.patch

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Index: fcitx5-community/data/fcitx5-start.sh
2424
===================================================================
2525
--- /dev/null
2626
+++ fcitx5-community/data/fcitx5-start.sh
27-
@@ -0,0 +1,44 @@
27+
@@ -0,0 +1,45 @@
2828
+#!/usr/bin/env bash
2929
+
3030
+# Log management function
@@ -48,16 +48,17 @@ Index: fcitx5-community/data/fcitx5-start.sh
4848
+
4949
+run_fcitx5() {
5050
+ if which fcitx5 > /dev/null 2>&1; then
51-
+ # If fcitx5 is running and no -r flag, try to force kill it first
52-
+ if pgrep -u "$USER" fcitx5 >/dev/null && [[ ! "$@" =~ "-r" ]]; then
53-
+ pkill -9 -u "$USER" fcitx5
54-
+ sleep 0.1 # Give some time for the process to be killed
55-
+ # If process still exists, use -r flag
56-
+ if pgrep -u "$USER" fcitx5 >/dev/null; then
51+
+ # Check if fcitx5 is running
52+
+ if pgrep -u "$USER" fcitx5 >/dev/null; then
53+
+ # If -r flag doesn't exist in args (either alone or in combinations like -rd, -dr), add it
54+
+ if [[ ! "$*" =~ (^|-)[[:space:]]*[a-z]*r[a-z]* ]]; then
5755
+ exec fcitx5 -r "$@" >> "$FCITX_LOG" 2>&1
56+
+ else
57+
+ exec fcitx5 "$@" >> "$FCITX_LOG" 2>&1
5858
+ fi
59+
+ else
60+
+ exec fcitx5 "$@" >> "$FCITX_LOG" 2>&1
5961
+ fi
60-
+ exec fcitx5 "$@" >> "$FCITX_LOG" 2>&1
6162
+ fi
6263
+}
6364
+

0 commit comments

Comments
 (0)