You are not logged in.
I would like to be able to use use my touchpad to scroll through the journalctl output, like I can do with normal less. I figured out that I can configure the less options that journalctl uses by setting $SYSTEMD_LESS. By default it is set to "FRSXMK". By removing the X (so "FRSMK"), I am able to scroll through the output. However, if the output is very short (like for systemctl --user status), there is no output at all with this setting. Is there a way to configure systemctl and journalctl, to both display short outputs and enable mouse scrolling in long outputs?
I know, I can call systemctl/journalctl with --no-pager, but that requires me to know beforehand how long the output will be.
Last edited by stupidus (2017-06-27 08:27:52)
Offline
So, if you use
journalctl -xeThen what exactly are your issues with what happens next?
Offline
Without setting $SYSTEMD_LESS then journalctl -xe show the journalctl output using less, but I can only scroll with j/k or the arrow keys. If I set $SYSTEMD_LESS to "FRSMK", then it shows the same output, but I can also scroll using the touchpad, which is what I prefer. However, calling "systemctl --user status" with the same value for $SYSTEMD_LESS shows no output. To see the output, I have either to set $SYSTEMD_LESS back to the default or use the --no-pager option. Basically, I think that I am looking for the right options for less to be able to scroll using the mouse, but still have short output being shown.
BTW, I am using termite as my terminal emulator, though I don't think that it matters, as the behaviour is the same with xterm.
Offline
I don't use the X, F and K options:
$ echo $SYSTEMD_LESS
j.25MqRSW#.25Does this change something for you?
Offline
Thank you. Removing the F option did the trick, I kept the K option though, because else less becomes unresponsive if you scroll above the beginning or below the end of the output.
However, I kind of liked the idea, that it would just display the output if it is short, without going into the alternate screen.
I tried to solve this with a wrapper script:
#!/bin/bash
length=$(wc -l $1)
if (("$length" > "40")); then
echo $1 | less -RSMK
else
echo $1 | less -FRSMKX
fiUsing `journalctl --no-pager | my-script` will open less without any output, whereas `systemctl --user status --no-pager | my-script` will not display anything. So, if detects the number of lines correctly, but the `echo $1 | less` part does not work.
Offline
Your script will not work as you expect it to.
This one should do what you want:
#!/bin/bash
TMPDIR=$HOME/tmp
length=$(wc -l $TMPDIR/systemdout.txt|cut -d' ' -f1)
if ((length > 40)); then
less -RSMK $TMPDIR/systemdout.txt
else
less -FRSMKX $TMPDIR/systemdout.txt
fiThe script is $HOME/tmp/systemdless and you use it like that:
journalctl --no-pager -b >$HOME/tmp/systemdout.txt && $HOME/tmp/systemdless
systemctl --user status --no-pager >$HOME/tmp/systemdout.txt && $HOME/tmp/systemdless
Last edited by berbae (2017-06-27 07:58:18)
Offline
Thanks for the input.
However, as I would like to avoid using temporary files I managed to find a way to make my script work:
#!/bin/bash
input=$(tee)
length=$(echo "$input" | wc -l)
if (("$length" > "40")); then
echo "$input" | less -RSMK
else
echo "$input"
fiThis solution may not be very elegant, but it seems to work.
Offline