Mailinglist Archive: opensuse-factory (188 mails)

< Previous Next >
Re: [opensuse-factory] Start displaymanager only if monitor is connected
On Mon, 3 Dec 2018 at 14:05, Joachim Wagner <jwagner@xxxxxxxxxxxxxxxx> wrote:

Generally, I'd say it's a bug in KDE if widget placement gets messed up just
because one forgets to switch on the screen.

Indeed this is a bug. If this bug wasn't there, I wouldn't have been
trying out this complicated scheme.

[...] I have not figured out a way to boot to graphical target
automatically when monitor is switched on and boot to
multi-user.target when monitor is switched off.

Have you considered something like
currernt_target=get_current_runlevel_target
desired_target=get_desired_runlevel_target

if [ "$current_target" = "$desired_target" ]; then
echo "continuing boot..."
else
echo "wrong runlevel target; switching..."
set_runlevel_target $desired_target
shutdown -r now
fi

No. I did not consider this and this gives me a thought to try this
out. Thank you for the idea.
I could try the command "init 3" in place of "shutdown -r now" above.
This is in case monitor-get-edid turns non-zero. Ultimately I want to
do something where the graphical target waits till I switch on the
monitor. So when I want the PC in headless mode, I don't switch on the
monitor. In case I change my mind, all I need to do is switch on the
monitor and the PC should boot into graphical mode (runlevel 5). So
there are three scenarious

1. I power on the PC without the monitor switched on, the PC should
boot into runlevel 3
2. I power on the PC with the monitor switched on, the PC should boot
into runlevel 5 with autologin
3. I power on the PC without the monitor switched on, the PC should
boot into runlevel 3. But any moment after the PC is booted, if I
switch on the monitor, the PC should switch to runlevel 5 with
autologin.

I guess, I will have to deep dive into systemd scripts. At the moment
I am going to try out this. monitor-check.service

[Unit]
Description=Monitor Check Service
Before=display-manager.service

[Service]
ExecStart=/home/mbhanguin/bin/monitor_check
Type=simple

[Install]
WantedBy=graphical.target

The script /home/mbhangui/bin/monitor_check will be. Though I am not
sure if this will work.

#!/bin/sh
file=/etc/sysconfig/displaymanager
/usr/sbin/monitor-get-edid >/dev/null 2>&1
if [ $? -eq 0 ] ; then
sed -i
's}#DISPLAYMANAGER_AUTOLOGIN=.*}DISPLAYMANAGER_AUTOLOGIN="mbhangui"}g'
$file
else
sed -i
's}DISPLAYMANAGER_AUTOLOGIN=.*}#DISPLAYMANAGER_AUTOLOGIN="mbhangui"}g'
$file
fi


--
Regards Manvendra - http://www.indimail.org
GPG Pub Key
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC7CBC760014D250C
--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-factory+owner@xxxxxxxxxxxx

< Previous Next >