summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Moeller <jan.moeller0@gmail.com>2021-12-08 00:32:56 +0100
committerJoe Hillenbrand <joehillen@gmail.com>2021-12-12 16:18:08 -0800
commitc74aa81181136d6a5a90b248743a6a69b5c4b617 (patch)
treead04b5f4cc84bc44e6310b6ecbf6a04fe4e48ece
parent0890e9261a6da411c6652d8f2acf7e4694245ab6 (diff)
Fix journalctl command for user session units
`--unit=<unit>` does not show messages for user session units. Instead use '--user-unit=<unit>' in this case.
-rwxr-xr-xsysz26
1 files changed, 10 insertions, 16 deletions
diff --git a/sysz b/sysz
index 2fcb88a..854b507 100755
--- a/sysz
+++ b/sysz
@@ -103,24 +103,18 @@ _sysz_systemctl() {
}
_sysz_journalctl() {
- # remove --system from journalctl
- if [[ $1 = --system ]]; then
- shift
+ if [[ $1 = --user ]]; then
+ # use --user-unit flag if it's a user unit
+ _sysz_run journalctl --user-unit="$2" "${@:3}"
+ else
if [[ $EUID -ne 0 ]]; then
- # only run sudo if we aren't root and it's a system unit
- _sysz_run sudo journalctl "$@"
- return
+ # only run sudo if we aren't root
+ _sysz_run sudo journalctl --unit="$2" "${@:3}"
+ else
+ _sysz_run journalctl --unit="$2" "${@:3}"
fi
fi
- # remove --user flag from journalctl
- # --user and --system don't work the same on journalctl
- # as they do for systemctl
- if [[ $1 = --user ]]; then
- shift
- fi
-
- _sysz_run journalctl "$@"
}
_sysz_manager() {
@@ -557,10 +551,10 @@ for PICK in "${UNITS[@]}"; do
for CMD in "${CMDS[@]}"; do
case ${CMD%% *} in
journal)
- _sysz_journalctl "$MANAGER" -xe "--unit=$UNIT" "${ARGS[@]}"
+ _sysz_journalctl "$MANAGER" "$UNIT" -xe "${ARGS[@]}"
;;
follow)
- _sysz_journalctl "$MANAGER" -xef "--unit=$UNIT" "${ARGS[@]}"
+ _sysz_journalctl "$MANAGER" "$UNIT" -xef "${ARGS[@]}"
;;
status)
# shellcheck disable=2086