Skip to content

Commit be884e4

Browse files
try fix recentFile 03
1 parent f7cab7e commit be884e4

File tree

2 files changed

+29
-38
lines changed

2 files changed

+29
-38
lines changed

usr/share/biglinux/biglinux-settings/usability/recentFiles.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ toggle_state() {
4545
new_state="$1"
4646
if [[ "$XDG_CURRENT_DESKTOP" == *"KDE"* ]] || [[ "$XDG_CURRENT_DESKTOP" == *"Plasma"* ]];then
4747
if [[ "$new_state" == "true" ]];then
48-
$PWD/usability/recentFilesRun.sh "enable" "$USER" "$DISPLAY" "$XAUTHORITY" "$DBUS_SESSION_BUS_ADDRESS" "$LANG" "$LANGUAGE"
48+
$PWD/usability/recentFilesRun.sh "enable" #"$USER" "$DISPLAY" "$XAUTHORITY" "$DBUS_SESSION_BUS_ADDRESS" "$LANG" "$LANGUAGE"
4949
exit=$?
5050
else
51-
$PWD/usability/recentFilesRun.sh "disable" "$USER" "$DISPLAY" "$XAUTHORITY" "$DBUS_SESSION_BUS_ADDRESS" "$LANG" "$LANGUAGE"
51+
$PWD/usability/recentFilesRun.sh "disable" #"$USER" "$DISPLAY" "$XAUTHORITY" "$DBUS_SESSION_BUS_ADDRESS" "$LANG" "$LANGUAGE"
5252
return $?
5353
fi
5454
# elif [[ "$XDG_CURRENT_DESKTOP" == *"GNOME"* ]];then

usr/share/biglinux/biglinux-settings/usability/recentFilesRun.sh

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,22 @@ xbelFile="$HOME/.local/share/recently-used.xbel"
2222
kactivitymanagerdFile="$HOME/.config/kactivitymanagerd-pluginsrc"
2323
kactivitymanagerdDir="$HOME/.local/share/kactivitymanagerd/resources"
2424

25-
# # Helper function to run a command as the original user
26-
runAsUser() {
27-
# Single quotes around variables are a good security practice
28-
su "$originalUser" -c "export DISPLAY='$userDisplay'; export XAUTHORITY='$userXauthority'; export DBUS_SESSION_BUS_ADDRESS='$userDbusAddress'; export LANG='$userLang'; export LC_ALL='$userLang'; export LANGUAGE='$userLanguage'; $1"
29-
}
30-
31-
# Creates a named pipe (FIFO) for communication with Zenity
32-
pipePath="/tmp/recentfiles_pipe_$$"
33-
mkfifo "$pipePath"
34-
3525
# Starts Zenity IN THE BACKGROUND, as the user, with the full environment
3626
if [[ "$function" == "enable" ]]; then
3727
zenityTitle=$"Recent Files enabling...."
3828
zenityText=$"Recent Files enabling, Please wait..."
29+
elif [[ "$function" == "disable" ]]; then
30+
zenityTitle=$"Recent Files disabling...."
31+
zenityText=$"Recent Files disabling, Please wait..."
3932
fi
40-
runAsUser "zenity --progress --title=\"$zenityTitle\" --text=\"$zenityText\" --pulsate --auto-close --no-cancel < '$pipePath'" &
4133

42-
# Executes the root tasks.
34+
# Executes tasks.
4335
updateTask() {
4436
if [[ "$function" == "enable" ]]; then
45-
$balooCMD suspend
46-
$balooCMD disable
47-
killall baloo_file dolphin kactivitymanagerd kioworker kiod5 kiod6
48-
systemctl --user stop plasma-kactivitymanagerd.service
37+
$balooCMD suspend > /dev/null 2>&1
38+
$balooCMD disable > /dev/null 2>&1
39+
killall baloo_file dolphin kactivitymanagerd kioworker kiod6 > /dev/null 2>&1
40+
systemctl --user stop plasma-kactivitymanagerd.service > /dev/null 2>&1
4941

5042
# Remove trava off-the-record
5143
sed -i '/off-the-record-activities/d' "$kactivitymanagerdFile"
@@ -78,24 +70,21 @@ updateTask() {
7870
chmod 644 "$xbelFile"
7971

8072
# Reinicia serviços
81-
systemctl --user start plasma-kactivitymanagerd.service
73+
systemctl --user start plasma-kactivitymanagerd.service > /dev/null 2>&1
8274
sleep 2
8375

84-
$balooCMD enable
85-
$balooCMD resume
76+
$balooCMD enable > /dev/null 2>&1
77+
$balooCMD resume > /dev/null 2>&1
8678

87-
systemctl --user restart plasma-kactivitymanagerd.service
88-
killall kiod5 kiod6
79+
systemctl --user restart plasma-kactivitymanagerd.service > /dev/null 2>&1
80+
killall kiod6 > /dev/null 2>&1
8981

9082
sleep 1
91-
92-
echo "STATUS:Completed successfully!"
93-
echo "PROGRESS:100"
94-
echo "RESULT:success"
83+
echo "100" # Garante que o zenity feche
9584
else
9685
# Para serviços
97-
killall dolphin kactivitymanagerd kioworker kiod5 kiod6
98-
systemctl --user stop plasma-kactivitymanagerd.service
86+
killall dolphin kactivitymanagerd kioworker kiod6 > /dev/null 2>&1
87+
systemctl --user stop plasma-kactivitymanagerd.service > /dev/null 2>&1
9988

10089
# Desabilita rastreamento de atividades
10190
$kwriteConfig --file kactivitymanagerd-pluginsrc --group "Plugin-org.kde.ActivityManager.Resources.Scoring" --key "what-to-remember" "2"
@@ -121,28 +110,30 @@ updateTask() {
121110
chmod 644 "$xbelFile"
122111

123112
# Reinicia serviços
124-
systemctl --user start plasma-kactivitymanagerd.service
125-
killall kiod5 kiod6
113+
systemctl --user start plasma-kactivitymanagerd.service > /dev/null 2>&1
114+
killall kiod6 > /dev/null 2>&1
126115

127116
sleep 1
117+
echo "100" # Garante que o zenity feche
128118
fi
129-
exitCode=$?
119+
return 0
130120
}
131-
updateTask > "$pipePath"
121+
# updateTask > "$pipePath"
122+
updateTask | zenity --progress --title="$zenityTitle" --text="$zenityText" --pulsate --auto-close --no-cancel
132123

133-
# Cleans up the pipe
134-
rm "$pipePath"
124+
# CAPTURA O STATUS DA FUNÇÃO (o primeiro comando do pipe)
125+
exitCode=${PIPESTATUS[0]}
135126

136127
# Shows the final result to the user, also with the correct theme.
137128
if [[ "$exitCode" == "0" ]] && [[ "$function" == "enable" ]]; then
138129
zenityText=$"Recent Files successfully enabled!"
139-
runAsUser "zenity --info --text=\"$zenityText\""
130+
zenity --info --text="$zenityText"
140131
elif [[ "$exitCode" == "0" ]] && [[ "$function" == "disable" ]]; then
141132
zenityText=$"Recent Files successfully disable!"
142-
runAsUser "zenity --info --text=\"$zenityText\""
133+
zenity --info --text="$zenityText"
143134
else
144135
zenityText=$"Failed to activate Recent Files!"
145-
runAsUser "zenity --info --text=\"$zenityText\""
136+
zenity --info --text="$zenityText"
146137
fi
147138

148139
# Exits the script with the correct exit code

0 commit comments

Comments
 (0)