Ssss: Some Small Slim Secrets


lomaxx

Active Member
Joined
Sep 22, 2008
Messages
747
Some small slim secrets (Try to say that as quickly as you can 10 times in a row! ;) )

Slim, the login-manager which is used in the Pandora-OS, has a few options that are quite helpful.

You can type in several strings instead of writing your username to call internally configured functions:

- type "exit" and slim will exit, leaving you with the tty. This is extremely helpful if you messed something up in your Xorg or/and xfce-configuration so you still have the chance to fix it.
- type "console" and X will start with a small terminal-window. It's nearly as helpful as "exit" but requires X to be properly configured.

Additionally the manual and /etc/slim.conf mentions some more commands that SHOULD work, but do not on the Pandora:

"halt","reboot","suspend" are supposed to do what they say. However i didn't manage to get them going even though i tried to add the "sudo"-command in /etc/slim.conf. (Edit: wejp told me on EFNET, that it works once you set a root-password. Read my reply below for details.) Since i still wanted to have an option to reboot and shutdown my system from within slim and without having the knowledge to modify and recompile the slim-sourcecode, i came up with a little workaround:

Slim does have a shortkey for making a screenshot (F11). While i do not get the idea why i would want to make a screenshot of my login-manager (oh wait, might be helpful if a errormessage shows up?), i am now mis-using this shortcut to call a bash-script i wrote. After saving the script and configuring slim you can press F11 once to make the Pandora reboot and press it twice to make it halt. The latter you have to do within 2 seconds. Otherwise rebooting initializes.

First of all the script. It's probably written in bad bash-style, but it works:

Code:
#!/bin/bash
# by Lomaxx 20101003
# free for any use, but without any warranty

if ! [ -f /tmp/slim_shutdown-trigger ]
        then
        echo "reboot" > /tmp/slim_shutdown-trigger
        # the following is run in a subshell so the script continues
        # after 2 seconds the file is checked and either reboots or halts your system.
        (sleep 2s
        if [ "$(cat /tmp/slim_shutdown-trigger)" = "reboot" ]
                then
                /sbin/shutdown -r now
        elif [ "$(cat /tmp/slim_shutdown-trigger)" = "halt" ]
                then
                /sbin/shutdown -h now
                fi
        )&
        # the subshell ends here
else
        echo "halt" > /tmp/slim_shutdown-trigger
fi

I saved the file as root in /usr/pandora/scripts/slim_trigger_shutdown.sh. If you saved as normal user you still can move it and change the owner by using

Code:
chown root:root /usr/pandora/scripts/slim_trigger_shutdown.sh

also i removed all rights for other users than root:

Code:
chmod go-rwx /usr/pandora/scripts/slim_trigger_shutdown.sh

Now as root edit the file /etc/slim.conf, find the line for the screenshot-command (you can let your editor search for "screenshot"), write a # in the beginning, copy the whole line one row below and modify it so that the screenshot-related lines look like this:

Code:
# Executed when pressing F11 (requires imagemagick)
#screenshot_cmd      import -window root /slim.png
screenshot_cmd      /usr/pandora/scripts/slim_trigger_shutdown.sh

Save the file, log out of xfce and try pressing F11 (Fn+O) once. After 2 seconds the system should reboot. After that you can also try pressing it twice, if you like to.
 
Thanks to wejp for this:

the command "reboot" and "halt" within slim work if you set a root-password. You can do that by starting xfce, opening a terminal, switching to root by typing "sudo su" and then type "passwd". Then enter the new password and verify it. After that you can run the mentioned commands in slim. Note that the keymapping is different in slim and thus you have to use a rather weak password without special characters. Some few more notes about the changes:

- i tried login in as root from slim to start xfce -> doesn't work. It's not a good idea to do that anyway since it is a security issue.
- i exit slim and tried to log in as root from tty -> works.
- logging as root via ssh by using the rootpassword works now too. You have to decide on your own if that is something you like (considering you probably will use a weak password).
- if you log in as normal user and then want to switch to root by using "sudo su" then you still have to use your user-password, the root-password does not work there.

In anyway: Someone still might find the script handy since you can reboot/halt by pressing not more than 3 keys instead of deleting your username, writing the command and entering the rootpassword.
 
Back
Top