@@ -144,7 +144,7 @@ user_action() {
144
144
fi
145
145
fi
146
146
elif [[ $cmd == stop ]]; then
147
- if [[ $svc_running == running ]]; then
147
+ if [[ $svc_running -eq 1 ]]; then
148
148
systemctl --user stop $NAME .service
149
149
echo " $NAME stopped as a user service."
150
150
fi
@@ -191,7 +191,7 @@ user_action() {
191
191
echo " $NAME is set up as a desktop application."
192
192
fi
193
193
194
- if [[ $svc_running == running ]]; then
194
+ if [[ $svc_running -eq 1 ]]; then
195
195
echo " $NAME is currently running as a user service."
196
196
else
197
197
if pgrep -u $USER -f " $NAME \$ |$NAME " & > /dev/null; then
@@ -201,7 +201,7 @@ user_action() {
201
201
fi
202
202
fi
203
203
204
- if [[ $svc_enabled == enabled ]]; then
204
+ if [[ $svc_enabled -eq 1 ]]; then
205
205
echo " $NAME is set to autostart as a user service."
206
206
rm -fv $AUTDIR /$NAME .desktop
207
207
else
@@ -222,6 +222,15 @@ user_action() {
222
222
fi
223
223
}
224
224
225
+ # Test if given systemd property is set for service
226
+ sysd_prop () {
227
+ if systemctl --user show -p $1 $NAME .service | grep -q " =$2 $" ; then
228
+ echo 1
229
+ else
230
+ echo 0
231
+ fi
232
+ }
233
+
225
234
if [[ $cmd == install || $cmd == uninstall ]]; then
226
235
DESTDIR=" ${DESTDIR%% +(/ )} "
227
236
if [[ -z $DESTDIR && $( id -un) != root ]]; then
@@ -285,12 +294,12 @@ else
285
294
# Test if systemd is installed
286
295
if type systemctl & > /dev/null; then
287
296
has_sysd=1
288
- svc_enabled=$( systemctl --user show -P UnitFileState $NAME .service )
289
- svc_running=$( systemctl --user show -P SubState $NAME .service )
297
+ svc_enabled=$( sysd_prop UnitFileState enabled )
298
+ svc_running=$( sysd_prop SubState running )
290
299
else
291
300
has_sysd=0
292
- svc_enabled=" no "
293
- svc_running=" no "
301
+ svc_enabled=0
302
+ svc_running=0
294
303
fi
295
304
296
305
if [[ $cmd == restart ]]; then
0 commit comments