Remap key within remmina doesn't work - keyboard

I am running x-window on my linux pc, with remmina to remote access windows xp PC
I've swapped capslock and left ctrl in my Xmodmap file, and load it in xsession file.
Here is my Xmodmap file, located at ~/.Xmodmap
#!/bin/bash
SYSMODMAP="/etc/X11/Xmodmap"
USRMODMAP="$HOME/.Xmodmap"
if [ -x /usr/bin/X11/xmodmap ]; then
if [ -f "$SYSMODMAP" ]; then
xmodmap "$SYSMODMAP"
fi
fi
if [ -x /usr/bin/X11/xmodmap ]; then
if [ -f "$USRMODMAP" ]; then
xmodmap "$USRMODMAP"
fi
fi
This is my xsession file, located at ~/.xsession
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
It worked in my x-window environment, however, it doesn't work in my remote windows PC.
I have modified registry in windows to swap capslock and ctrl, and it worked if I use windows's physical keyboard.
I have searched a lot on web, someone seems having solving this problem by enable "using client key map" in remmina's configuration tab, however, it doesn't work for me.
I wander which keymap file does remmina load, so I can modify them to fit my need. Does any one has the same problem?

Related

Replace login prompt with interactive bash script on serial port linux

I am working on a CentOS box.
What I expect: To run my own CLI/setup on startup instead of login prompt on serial console (telnet).
What I did so far:-
I changed call to "agetty" command in serial.conf and serial-ttyUSB0.conf files under /etc/init/, as follows:-
exec /sbin/agetty -n -l <path-to-my-custom-script> ........
My custom.sh script is:-
#!/bin/bash
LOOP_FLAG=0
while [ $LOOP_FLAG -eq 0 ]; do
for TTY in /dev/ttyS0 /dev/tty0; do
echo "Please choose to enter in 'setup' or 'cli'. (s/c)? " > $TTY
done
read sc
case $sc in
[Ss]* ) LOOP_FLAG=1; <some-executable-cli-file-path>; break;;
[Cc]* ) LOOP_FLAG=1; <some-executable-setup-file-path>; break;;
* ) for TTY in /dev/ttyS0 /dev/tty0; do
echo "Please press 's' or 'c'." >$TTY
done;;
esac
done
But when system boots, on a telnet session, I could only see the "Please choose to enter.." question on screen and after that I couldn't able to type anything on console.
One more update:
If I run the above agetty command on shell prompt as it is (say from ssh session), then it works fine on serial console (telnet). But, from the above startup scripts, it doesn't work.
Can anybody help me out with this?
Thanks in advance.
-Neo
Sorry I'm a few years late. Hopefully this will be of help for people searching for solution to this problem in the future.
The issue lies here:
-n, --skip-login Do not prompt the user for a login name. This can be used in connection with -l option to invoke a non-standard login
process such as a BBS system. Note that with the -n option, agetty
gets no input from user who logs in and therefore won't be able to
figure out parity, character size, and newline processing of the
connection. It defaults to space parity, 7 bit characters, and ASCII
CR (13) end-of-line character. Beware that the program that agetty
starts (usually /bin/login) is run as root.
So you need to initialize the terminal yourself in the script you are replacing the login prompt with. I found the settings below work well:
/bin/stty -F /dev/ttyO0 115200 cs8 sane
Remember to replace the baud rate and terminal name to your own.

How to disable a specific usb port permanently in linux?

Is it possible to permanently disable a usb port in linux?
I have already figured out how to disable it:
echo -n "0000:00:12.0" > /sys/bus/pci/drivers/ohci_hcd/unbind
BUT after restart it is enabled.
I have placed this script :
#!/bin/sh
case "$1" in
resume|thaw)
echo -n "0000:00:12.0" > /sys/bus/pci/drivers/ohci_hcd/unbind
;;
esac
in /etc/pm/sleep.d/0_disable_usb2
But again without success. I also thought that i could disable it through bios but as i could see i can disable the whole pci.
Is there any way of doing this?
.. My Operating system is Debian 7.7 64bit. The reason i want to do this is I am trying to configure my system for realtime capabilities and my usb soundcard sharing the same IRQ with this port.
For me usb mounting is handle by a service udisk2.service if you would like to stop usb mounting then stop below service
root#mahasan-Inspiron-5537:~# systemctl start udisks2.service
root#mahasan-Inspiron-5537:~# systemctl disable udisks2.service
First of all you should find your USB number of your device, Simply by using lsusb.
And in Linux everything is a file, So you can manage all of your hardware using the files.
As it describes Here if your kernel is > 2.6.38 you should use this keywords:
echo "0" > "/sys/bus/usb/devices/usb2/power/autosuspend_delay_ms"
Then:
echo "auto" > "/sys/bus/usb/devices/usb1/power/control"
echo "0" > /sys/bus/usb/devices/usb{x}/authorized

Detecting the presence/absence of a numeric keypad?

Is it possible to determine whether there is a numeric keypad connected to the system? Desktop keyboards typically have numpads, while laptops typically don't (though they put numpad keys in the normal keyboard, activated with Num Lock). Does the operating system know whether the numpad keys are physically separate? And if so, is that information exposed to programs somehow?
It would be useful to know this to determine appropriate default key-bindings. If it's not available then I'll either have to pick a conservative default (not using the numpad), which means a slightly irritating extra configuration step to get nicer behaviour for people with separate numpads, or I'll have to pick a non-conservative default and irritate the people without numpads...
I don't believe you can query for keyboard capabilities but iirc there is a "numpad" key. ;)
You should be able to query if Num is on or off, but it being off won't be a foolproof way to know that there is no numeric keypad.
What you could probably do is detect keys being pressed on a numpad and subliminaly trick the user into doing so, which would identify said characteristic.
install these packages
sudo apt-get install -y numlockx xdotool x11-utils
then use a script like this
#!/bin/bash
cd
numlockx off &
rm -f s1.sh s2.sh out
echo -e "#\041/bin/bash
sleep 2
xdotool key KP_5 | xev > out
exit 0" >> s1.sh
chmod +x s1.sh
echo -e "#\041/bin/bash
sleep 9
killall -9 xev
sleep 5
xdotool key BackSpace
exit 0" >> s2.sh
chmod +x s2.sh
bash s1.sh &
bash s2.sh
rm -f s1.sh s2.sh
if [[ "$(cat out | grep "keycode 84" | grep "KP_Begin" )" != "" ]]; then
echo "Separated Numpad Detected!"
fi
rm out
exit 0
because KP_Begin is the keycode for the numpad key KP_5 when numlock isn't active, in a real keyboard with a real keypad.
Tested on 3 PCs, one with a separated keypad e 2 without it.

Can tmux pane remote ssh-connection

Can I run tmux locally and connect via ssh to remote machine.. and after that any new pane and/or screen to be with the remote-machine-shell...
What I'm saying I can't install tmux on the remote machine, but I don't want to do a ssh connection from every pane, but ssh-login just once.
Is such thing possible..
thanks
If you want to login just once, you can use ControlMaster feature of ssh. Add some config like this to your ~/.ssh/config:
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
If you login to the same server (as the same user) multiple times (either in one tmux or not), ssh will reuse the connection so that you don't need to make connection and login again.
lilydjwg explained something I never really understood before. Knowing about the ControlMaster setting makes the following much more reasonable, as it simplifies making multiple ssh connections. You only need to authenticate once, and the remote host doesn't need to have an sshd process running for each connection.
In your .tmux.conf file:
# What host do you usually log in to?
# We'll ssh there by default each time a new window or pane is opened.
REMOTE_HOST=your.usual.host
set-option -g default-command "ssh $REMOTE_HOST"
# Simple interface to change which host is connected to when you create
# a new window or pane.
bind-key C-h command-prompt -p "Set remote host: " -I $REMOTE_HOST "set-option default-command 'ssh %%'"
# In case you really do want a new window with a local shell.
bind-key C new-window ""
I don't think tmux can. One workaround would be to add something like this to tmux.conf.
bind-key X new-window "ssh HOST"
Then new windows would start at the remote host.
I am using tmux 1.8 and did not find a built-in solution. These workarounds fit at least for my common use cases:
Capture the full pane content and search for the last ssh command in it (I use the knowledge about the ending of my prompt to detect the command more or less reliably)
If this fails I check the command the pane might have been created with by using the shell-command option of tmux new-window or split-window commands
My reconnect.sh script looks like this. The most dirty thing about it is the way to get the last ssh command from the buffer. Up to now "> ssh " was enough for my situations to reliably detect a line containing a ssh connection request but any better solution would be appreciated.
#!/bin/bash
# #TODO: change this according to your own prompt
# This is used to find lines connect ssh command in the pane buffer
PROMPT_SEPARATOR="> "
# get current pane buffer size and dimensions
HISTORY_LIMIT=`tmux display-message -p "#{history_limit}"`
VISIBLE_LINES=`tmux display-message -p "#{pane_height}"`
# search last ssh command in pane content
LINE=`tmux capture-pane -p -J -S -$HISTORY_LIMIT -E $VISIBLE_LINES | grep "${PROMPT_SEPARATOR}ssh " | tail -1`
if [ -n "$LINE" ]; then
echo $LINE | sed "s/.*$PROMPT_SEPARATOR//;"
else
# fall back to the command that might have been used to create the pane
# (not necessarily ssh but helpful anyway)
tmux list-panes -F "#{pane_active} #{pane_start_command}" | grep "^1 " | tail -1 | cut -d ' ' -f2-
fi
I saved this script in my ~/.tmux directory and changed key bindings for various split-window and new-window shortcuts in my .tmux.conf similar to this:
# try to reconnect to remote host when creating new window
bind c run-shell 'CMD=`~/.tmux/reconnect.sh`; tmux new-window "$CMD"'

linux shell : how to call programs after a while

when start virtual box if I remap my key, that key will not pass to virtualbox, so I must set the xkbmap to default us, then start vm, then wait a moment call xmodmap ~/.Xmodmap
setxkbmap us
VirtualBox --startvm XP &
#wait a moment
xmodmap ~/.Xmodmap
how to write this shell script?
sleep # where # is number of seconds to wait
setxkbmap us
VirtualBox --startvm XP &
#wait 5 seconds
sleep 5
xmodmap ~/.Xmodmap
Just sleep:
sleep N
A better way to do this would be to wait until the server is not started. You might be able to do below to find this out:
echo `VirtualBox status | grep started | wc -l`

Resources