Tag Info

Hot answers tagged

87

I know this was already answered, but the answer doesn't explain what's going on. Characters like Ctrl+L are handled by the application. In the case of entering input into the shell, like bash, it clears the screen. Some applications, like emacs, use it to redraw the screen and/or recenter the cursor. Characters like Ctrl+U at a password prompt are ...


49

You just have to type ctrl+u. Enjoy =)


29

Those 'special' headphones or earphones which can be used on specialized devices to control media players, volume and mute usually have FOUR connections on the plug, versus the typical THREE a normal headphone output jack has. The usual three are Left Channel, Right Channel and Ground (common), while the fourth is often set up as a multi-value resistance, ...


23

#!/bin/bash stty -echo IFS= read -p 'Enter password: ' -r password stty echo printf '\nPassword entered: %s\n' "$password" stty -echo turns off the terminal echo, which is the display you're talking about; IFS= is necessary to preserve whitespace in the password; read -r turns off backslash interpretation. In bash you can also use read -s, but this ...


16

Try the following command : xdotool getmouselocation 2>&1 | sed -rn '${s/x:([0-9]+) y:([0-9]+) .*/\1 \2/p}' See http://www.semicomplete.com/projects/xdotool/


15

xinput test can report all keyboard events to the X server. On a GNU system: xinput list | grep -Po 'id=\K\d+(?=.*slave\s*keyboard)' | xargs -P0 -n1 xinput test If you want to get key names from the key codes, you could post-process that output with: awk 'BEGIN{while (("xmodmap -pke" | getline) > 0) k[$2]=$4} {print $0 "[" k[$NF] "]"}' Add ...


14

Assuming your GUI is X-based (as almost all UNIX GUIs are), use xinput. First, list your devices: $ xinput --list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Windows mouse id=6 [slave pointer (2)] ⎣ Virtual ...


14

There are numerous issues with that script, but the one thats causing your specific issue is because you're reading from a pipe (the output of ls). 1. Don't parse ls Use this instead for currentSong in *; do ... done Aside from the numerous reasons you shouldnt parse ls, the issue you're seeing is because STDIN is connected to the output of ls. So ...


11

If you're writing a real-world program that uses the mouse in Linux, you're most likely writing an X application, and in that case you should ask the X server for mouse events. Qt, GTK, and libsdl are some popular C libraries that provide functions for accessing mouse, keyboard, graphics, timers, and other features needed to write GUI programs. Ncurses is ...


9

One more option is xinput. For instance, xinput test 8 would write motion a[0]=496 a[1]=830 motion a[0]=496 a[1]=829 motion a[0]=496 a[1]=832 motion a[0]=496 a[1]=834 upon mouse movement, where "8" is my mouse device number. Use xinput --list to find out the number of your mouse among devices.


8

xinput --set-int-prop is deprecated. You should use --set-prop instead. Also, xinput --enable [device] and xinput --disable [device] can be used to enable and disable devices respectively. Here is a shell script I use to enable, disable, and toggle my laptop's touchpad: #!/bin/bash # Enables, disables, or toggles device device='AlpsPS/2 ALPS GlidePoint' ...


8

Use the uinput driver. I don't think there's a utility for that; you're going to have to write or adapt a bit of C code. In a nutshell: #include <fcntl.h> #include <ioctl.h> #include <unistd.h> #include <linux/input.h> #include <linux/uinput.h> /* Set up a fake keyboard device */ fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); ...


7

If I understand correctly, you're running the script directly from a GUI environment, not from inside a terminal. The terminal is what provides the script a way to receive input. If you run the script from the GUI via a menu entry or a keyboard shortcut, the script's input is connected to nothing (this nothing is called /dev/null), so when you ask to read a ...


7

If you are operating at the X level (as in Gilles' question), then use xdotool like so: xdotool key KEYSTROKE_SPECIFIER Where KEYSTROKE_SPECIFIER can be something like "a" or "F2" or "control+j" EDIT: I missed your response to Gilles' question, sorry. I'll leave this response here as a solution for the X-case.


7

The command vipe in the package moreutils allows you to launch $EDITOR in the middle of a pipeline. You can get the desired behaviour like so: $ </dev/null vipe |sort -nr | uniq -c


6

You may find useful xinput list and xinput test <device>. For example, $ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)] ⎣ Virtual core keyboard id=3 ...


6

I and friends of mine made some good experiences with the tablets from Wacom. The Bamboo series contains different tablets in different pricing categories. My Bamboo for example is connected via USB, the pen as 2 Buttons, the tablet is only sensitive to the pen, has some more buttons and works with my linux out of the box. So this should satisfy your ...


5

It is typical for programs to force the "some_string" part to be the last argument so that .abc.ksh "some_string" -a "sample text" is an error. If you do this, then after parsing the options, $OPTIND holds the index to the last argument (the "some_string" part). If that is not acceptable, then you can check at the beginning (before you enter the while to ...


5

As Michael suggests, the window manager is not responsible for managing the input method. First you will need to choose an input method, of which IBus, SCIM and uim appear to be the most popular. Next, you need to make sure it is started when X is launched. You've mentioned you are using a lightweight WM, therefore you'll likely want to add it to an X init ...


5

Try doing this : $ read -r -p 'Please enter a string >>> ' var $ printf '%q\n' "$var" \*\*\*\<\>\<\>\<\|\|\&\&\*\&\$PATH


5

If the program reads from standard input (as opposed to direct from the terminal), you could do something like echo -e "answer1\nanswer2\nanswer3\n" | your_program A here document may be more readable: your_program <<'EOF' answer1 answer2 answer3 EOF do_more_stuff (You can pick any string instead of EOF, just make sure to use the same in ...


5

Change the first line in 50-synaptics.conf to Section "InputClass" InputDevice was used to define rules and options for a specific device and I'm not sure if it's still supported. InputClass is a newer section that allows for matching a number of connected devices depending on various match rules. Because you have the line MatchIsTouchpad you should ...


5

GUI programs don't read from their standard input, they get their input from the X server. There are tools to inject a keystroke to a window. xdotool is fairly common and convenient. You'll need to find the window ID that you want to send the keystroke to. You can do that with xdotool. xdotool search --class Chrome returns the list of window IDs of all the ...


5

Have you considered using the script command?


4

The answered question using xinput is the right one, but here is a quick one if all you are looking for is a simple screensaver type lock. I wrote this back in the '90s, and all it does is eat the X server's keyboard and mouse events, until you type the password. No feedback at all other than exiting when you type it correctly. ...


4

If you're NOT working with X programs with windows that can be sent keys, you are probably looking for expect, a handy and very configurable program for running other interactive shell programs as if a user were controlling the terminal. You can setup programatic responses to respond to various output with different inputs.


4

I wrote some Python code that does that. You can find it in my open source project. http://code.google.com/p/pycopia/source/browse/trunk/core/pycopia/OS/Linux/event.py If you run that module as a script as root you can see a demo in action. This basic functionality was extended for another project, powerdroid, that provides more concrete implementation ...


4

I use Ratpoison WM. To type Chinese, I simply added IBUS to the ~/.ratpoisonrc file, which then starts IBUS when you start Ratpoison. The line looks like this: exec ibus-daemon --xim If you aren't using Ratpoison, arrange to launch ibus-daemon --xim when your X session start by whatever means your window manager or session manager provides. Then, to ...


4

You need to setup the two input devices manually in xorg.conf and specify the offset for each one so that they map to the correct location in your overall X screen setup. Each input driver will need to be specifically mapped by to the ID of the device it corresponds to. Not specifying this will cause the driver to take over ANY matching devices. After you ...


4

There is currently no standardized way to use your wired headset as input with Linux as far as i know. This means you won't be able to use your headset to control your music player - Bluetooth headsets on the other should work out of the box.



Only top voted, non community-wiki answers of a minimum length are eligible