# detecting Z to power of z

## mounty1

Hello, I have an MSI S270 laptop which like many such machines, has some keys with a blue legend which is activated/enabled by holding down the Fn key at the same time as the key in question.  For example, The F7 key also has a small loudspeaker symbol and a down-arrow key, and (since enabling MSI_LAPTOP in the kernel) it has the effect of reducing the audio level.

The F12 key has a Z to the power of z symbol, clearly representing sleep, and it would be nice to have this key initiate a hibernate.  I know how to make the power button do this (alter /etc/acpi/default.sh) but the Fn-Zz combination doesn't appear to be passed to /etc/acpi/default.sh so the question is:  how can I intercept/detect Fn-Zz ?

----------

## Poedel

i e17 you can simply use the wm´s keybinder to caputre a keycombo and let it follow a disired command.

If your WM does not support this feature you should google for xbindkeys.

There you can bind keys to a command like the name tells you.

I can´t remember the name of the little programm that tells you the keycode while hitting it.

But "xbindkeys" should give you some usefull google hits.

hth poedel

----------

## mounty1

xbindkeys showed that the key is returned as XF86Sleep, so I then looked in /etc/acpi in a Ubuntu installation to see where that appeared.

----------

## Akkara

When I saw that title I thought it was going to be regarding an algorithm to determine whether a number is of the form, z^z.  (In this context, '^' means power, not exclusive or).

So I clicked excitedly to read what ideas have been posted.  But it wasn't about that.  :Smile: 

<silly_math_geeking>

But in case someone happens to wonder about such an algorithm, here's one idea: The quantity z^z grows extremely rapidly with z.  As such, there are only a small number of numbers of this form that can be represented in a computer.  So just checking your number against a table suffices.

For 32-bit integers these range from 1^1 to 9^9, and also include (-1)^(-1): -1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489

For 64-bit integers, there's also 10^10 through 15^15 in addition to the above: 10000000000, 285311670611, 8916100448256, 302875106592253, 11112006825558016, 437893890380859375

</silly_math_geeking>

----------

## mounty1

... now anyone who might actually have been able to help will see that the question has had three replies, and will move on, assuming that the matter has been dealt-with.

----------

## Poedel

yeah true. I hate this if there was no solution.. but you got it, don't ya.

You got the output of the key-pressed.

You know what it should do in your opinion.

use xbindkeys to let pressing this key follow your desired command.

Or probably all of the three people answering didn't quite get the point.

----------

## eccerr0r

Since the key press apparently just generates a keycode versus an ACPI event, it looks like the expected way to initiate a suspend is through the window manager through X.  Xbindkeys is a good choice, or you could do through your window manager.

Course this won't work if you're not running X.

The other way is to hack kernel keyboard.c to write code to tell it to tell init to initiate a suspend.  Which is quite a bit more work... might be something to suggest on Linux Kernel Mailing List but I think they'd prefer people to do the first option.

----------

## mounty1

Thanks, something to work-on.

----------

