0

Disclaimer:

I am a bit of a Linux noob :(

Problem:

I have an interesting problem that I could use some help with. Essentially, I want to overwrite the default actions for the "Print Screen" button in Linux. My reasons for doing so are that I have a homemade graphics card running attached to the computer and I'm trying to make a utility where I can capture what it is outputting to a separate monitor and send it back to the "host" computer. For purposes here, I only want to know: How can I execute a script upon pressing the Print Screen button? Note that I cannot install xbindkeys or any other software. Ideally I would like to be able to run a script to enable this behavior.

Current work-around:

Currently, I have a .bashrc script:

    #!/bin/bash
    export PATH=/home/username/bin:$PATH

In the /home/username/bin folder I have a script "gnome-screenshot" that, for now, just performs some arbitrary task (it actually does this: "cat /usr/share/icons// > /dev/dsp" -- try it! It's fun!).

I am working on school computers, so I first CTRL-ALT-F5 to open a terminal login, login, then source .bashrc. I then startx -- :1 to start a new X session. Now, if I hit the PrintScreen button, it uses my gnome-screenshot, not the default screencapture program.

Is there anyway to do this without all of the restarting X? In short, is there a way to source my .bashrc script, or otherwise modify my PATH variable, before or while I login?

Another Approach:

I also tried, briefly, to xmodmap and the keycode to execute a script, but couldn't figure out how to tie them together. I know the keycode (111) but can't figure out how to run a script on press. I believe it might be possible to make a sort of binding using this but can't figure out how.

Help!

I'd really appreciate some help or comments!

(Edit): Added Details About Distribution:

cat /etc/redhat-release tells me:

Red Hat Enterprise Linux Client release 5.8 (Tikanga)

4

1 回答 1

3

xmodmap不是您想要的工具;它不能将键绑定到程序,它将物理键码绑定到逻辑键符。 XGrabKey(3)就是你要找的。

在启动 X 会话时读取您的 shell 点文件取决于您使用的确切操作系统和桌面环境(包括版本;即使只考虑带有库存桌面的不同 Ubuntu 版本,您也可能需要使用 4 或 5 种不同的方式)。

于 2012-04-10T21:01:31.083 回答