1

I'm working on a python project where I'm displaying a graphical window with a login screen. I've disabled the close, re-size and minimize buttons. The OS is Ubuntu.

I have to disable all the interrupts, including disabling system shortcuts like Alt+Tab, Alt+F4, etc. so that a user can log in only after entering the username and passwords on the screen.

1

I think you can use the trap command to do this. You can see more about it here in the docs titled: Bash Guide for Beginners - 12.2. Traps.

Example

Here's an example that catches Ctrl + C.

#!/bin/bash
# traptest.sh

trap "echo Booh!" SIGINT SIGTERM
echo "pid is $$"

while :         # This is the same as "while true".
do
        sleep 60    # This script is not really doing anything.
done

Signal Info

You can give the names of the signals to trap. The list of signal names is available via the kill -l command.

$ kill -l
 1) SIGHUP   2) SIGINT   3) SIGQUIT  4) SIGILL
 5) SIGTRAP  6) SIGABRT  7) SIGBUS   8) SIGFPE
 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT
17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG  24) SIGXCPU
25) SIGXFSZ 26) SIGVTALRM   27) SIGPROF 28) SIGWINCH
29) SIGIO   30) SIGPWR  31) SIGSYS  34) SIGRTMIN
35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3  38) SIGRTMIN+4
39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6
59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX    
  • but will it work for keynote shortcuts, for ex : ctr + apt +t – pavan Oct 27 '13 at 5:57
  • @pavan - can't say on those, likely no. I'd test it however. To override the switching windows in X you'll most likely not be able to do this from the trap anyway, you'll need to do those up higher in the stack, in X, or perhaps in a programming lang. like Python. – slm Oct 27 '13 at 6:04
  • This only affects what happens in the terminal, which shouldn't even be running bash. – Gilles 'SO- stop being evil' Oct 27 '13 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.