Discussion:
[systemd-devel] Howto get the original TTY in a service
Martin Vogt
2016-01-26 13:31:11 UTC
Permalink
Hello list,

in a desktop session it is common behaviour to have a pop up dialog
if the user presses CTRL+ALT+DEL.
If the user press cancel, the original desktop is resumed.

I like to have the same functionality on a virtual console.
If the user hits CTRL+ALT+DEL on /dev/tty2 I can display a dialog:

[ ] reboot
[ ] halt
[ok] [cancel]

and if the user hits cancel the focus should switch back to the virtual
console, where
CTRL+ALT+DEL was pressed.

I need the console in a shutdownselect.service file (and in the script)
where the user pressed CTRL+ALT+DEL.

I cannot figure out how to do it.

The script started from systemd gets for the tty command "not a tty"

best regards,

Martin

PS: The implemenation goes like this "shutdownselect.sh":

#!/bin/bash
CURR_TTY=`/usr/bin/tty`
case "$CURR_TTY" in
/dev/tty*)
;;
*)
echo "err: $CURR_TTY" >>/tmp/debug.txt
exit 0
esac
CURR_TTY_N=${CURR_TTY#/dev/tty}

** switch to tty 63**
** display dialog **

chvt $CURR_TTY_N


shutdownselect.service (which is required in ctrl-alt-del.target)

[Unit]
Description=Reboot GUI
DefaultDependencies=no
AllowIsolate=yes
JobTimeoutSec=30min
JobTimeoutAction=reboot-force

[Service]
ExecStart=/tmp/shutdownselect
Mantas Mikulėnas
2016-01-26 13:35:01 UTC
Permalink
Post by Martin Vogt
Hello list,
in a desktop session it is common behaviour to have a pop up dialog
if the user presses CTRL+ALT+DEL.
If the user press cancel, the original desktop is resumed.
I like to have the same functionality on a virtual console.
[ ] reboot
[ ] halt
[ok] [cancel]
and if the user hits cancel the focus should switch back to the virtual
console, where
CTRL+ALT+DEL was pressed.
I need the console in a shutdownselect.service file (and in the script)
where the user pressed CTRL+ALT+DEL.
I cannot figure out how to do it.
The script started from systemd gets for the tty command "not a tty"
StandardOutput=tty? /sys/class/tty/tty0/active?
--
Mantas Mikulėnas <***@gmail.com>
Martin Vogt
2016-01-26 15:33:00 UTC
Permalink
Post by Mantas Mikulėnas
Post by Martin Vogt
I need the console in a shutdownselect.service file (and in the script)
where the user pressed CTRL+ALT+DEL.
I cannot figure out how to do it.
The script started from systemd gets for the tty command "not a tty"
StandardOutput=tty? /sys/class/tty/tty0/active?
Ok, thanks.
The /sys/class/tty/tty0/active entry works for me.

Loading...