SliTaz SliTaz Forum

You are not logged in.

#1 2012-10-10 19:22:22

llev
Member
Registered: 2011-12-09
Posts: 568

magic sysrq keys + power button

Hi,

How can I activate the "magic keys" (Alt+SysRq+letter)? They don't work, so I guess they're not active by default.

Also, I would like the power button to do a shutdown, as it does in some other distributions. Is it possible?

Thanks a lot.

Offline

#2 2012-10-11 08:29:26

lexeii
Administrator
Registered: 2012-03-21
Posts: 1,853

Re: magic sysrq keys + power button

Hi there!

Magic SysRq key

[*]googling for linux sysrq enable

[*]found Magic SysRq key Wikipedia page

[*]read this:

The feature is controlled both by a compile-time option in the kernel configuration, CONFIG_MAGIC_SYSRQ

[*]search 'SYSRQ' in your own current kernel configuration:

[c]tux@slitaz:~$ zcat /proc/config.gz | grep 'SYSRQ'

# CONFIG_MAGIC_SYSRQ is not set

tux@slitaz:~$ [/c]

[*]so, magic key will not work without recompiling the kernel; the end.

Power button

[*]install xbindkeys package

[*]open terminal, run xbindkeys once to generate default config file ~/.xbindkeysrc (here is hidden file in your home folder)

[*]open SliTaz menu → Settings → Auto started applications → Configuration → add this text to the end of file, save & quit:

[c]# Fn Keys

xbindkeys &

[/c]

Now xbindkeys will start at your every logging on

[*]in terminal:

[c]xbindkeys -k[/c]

Press your Power button (or any other key that you can associate with any command).

In my case it shows:

[c]tux@slitaz:~$ xbindkeys -k

Press combination of keys or/and click under the window.

You can use one of the two lines after "NoCommand"

in $HOME/.xbindkeysrc to bind a key.

"(Scheme function)"

    m:0x0 + c:124

    XF86PowerOff

[/c]

[*]open ~/.xbindkeysrc in your preferred text editor:

[c]nano ~/.xbindkeysrc

or

leafpad ~/.xbindkeysrc[/c]

or open PCManFM, press ‹Ctrl+H› to see hidden files and double click on .xbindkeysrc file

[*]copy last three lines from terminal above into your text editor, do not close text editor (we do not know the command!)

[*]to show logoff/reboot/shutdown menu I press icon on bar, go to /usr/share/applications and search for this icon; right click on it → open in text editor; see command in this line:

[c]Exec=tazbox logout[/c]

Open comand [c]tazbox logout[/c] in terminal. Yes, it works! But if I want only shutdown?

[*]Where is located tazbox script? here is the answer (in /usr/bin/tazbox), open this file in text editor and search for appropriate command

[*]Lines from 291 to 304:

[c]    logout)

        # Logout window with actions

        main=[/c][c]logout_main[/c]

        # Deal with --button values

        case $? in

            1) exit 0 ;;

            *) continue ;;

        esac

        # Deal with $main values

        case "$main" in

            *exit) openbox --exit || jwm -exit ;;

            *reboot) reboot ;;

            *halt) poweroff ;;

        esac ;;

So, to halt the your computer, you must command poweroff! Ok, ok… Now back to our text editor with .xbindkeysrc (now we know the command)

[*]Final edition:

[c]

#power off button

"poweroff"

    m:0x0 + c:124

    XF86PowerOff

[/c]

[*]That's all! (If you have frugal SliTaz installation then save your system before). Press your Power button to poweroff. Start your machine and press Power button again. All work.

Offline

#3 2012-10-11 17:40:42

llev
Member
Registered: 2011-12-09
Posts: 568

Re: magic sysrq keys + power button

Hi Aleksej,

Thanks a lot for your detailed explanation! Alas the power button isn't detected (neither by xev), so I bound poweroff to Ctrl-Alt-Del instead.

Maybe I'll consider recompiling the kernel. The Sysrq keys are useful to avoid a mere unplugging when the computer is frozen.

Thanks again.

Offline

#4 2012-10-11 17:53:02

lexeii
Administrator
Registered: 2012-03-21
Posts: 1,853

Re: magic sysrq keys + power button

Any response from Power key? No key code & no key name?

Wikipedia says about SysRq key:

Some people view this key as giving access to dangerous system-level commands to anyone who has physical access to the keyboard or serial console.

wink

Offline

#5 2012-10-11 19:44:18

llev
Member
Registered: 2011-12-09
Posts: 568

Re: magic sysrq keys + power button

Absolutely nothing. I just noticed that "Power button" is reported in Xorg's log (and it's supposed to be configured!). But I have no idea if something can be put in xorg.conf for it to work.

Offline

#6 2012-10-12 09:13:31

lexeii
Administrator
Registered: 2012-03-21
Posts: 1,853

Re: magic sysrq keys + power button

It is good that you can configure your keys using xbindkeys, but it is not right way while we using power/suspend/hibernate keys!

I want to find right way, and I started here: Shutdown Pressing Power Button - ArchWiki.

Here is acpi package file list in the SliTaz stable. I have installed acpid package. And opened their files in text editor.

For example, /etc/acpi/events/buttons:

[c]# /etc/acpi/event/button

# lid, sleep or power button events

event=button.*

action=/etc/acpi/acpi_handler.sh "%e"[/c]

Start of file /etc/acpi/button.sh:

[c]#!/bin/sh

# button.sh - Managing button events for SliTaz

#

source /etc/acpi/key-constants

...[/c]

But we have not file key-constants in any SliTaz package! But button.sh is designed exclusively for SliTaz! Hmm...

Here is acpid branch in the wok-stable (with receipt and other stuff).

I found key-constants here. Now my experiments suspended (I close my lid wink )

Seems like acpid is broken and have not all parts of its body to work properly...

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.020 seconds, 7 queries executed - Memory usage: 1.55 MiB (Peak: 1.77 MiB) ]