Skip to content

Commit f487468

Browse files
committed
fix display getting from who output
who output differs between systemd and normal shell: in systemd some columns contain spaces in the values (date format is different)
1 parent 738f663 commit f487468

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

systemd/system/codam-web-greeter-idler.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ WHO_OUTPUT=$(/usr/bin/who)
1010
while IFS= read -r line; do
1111
# Get username
1212
USERNAME=$(echo "$line" | awk '{print $1}')
13-
# Get display
14-
DISPLAY=$(echo "$line" | awk '{print $5}' | sed 's/[(|)]//g')
13+
# Get display (everything between () and remove the ())
14+
# Cannot use awk here to print a specific column because columns might contain spaces...
15+
DISPLAY=$(echo "$line" | sed -n 's/.*(\(.*\))/\1/p')
1516
# Go to next line if display does not start with :
1617
if ! [[ "$DISPLAY" =~ ^: ]]; then
1718
continue

0 commit comments

Comments
 (0)