ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
People, I have been trying to use linux absolutely with no mouse. And it has been quite frustrating because several "details" in sites cannot be done without a mouse. They are possible to be, as far as I know about how sites work, before HTML5 or not, but sites hardly care about it. And several programs also have parts which are completely unaccessible to keyboard.
I have discovered a workaround: xdotool command and all its actions for doing what mouse does, from moving the cursor; clicking, double or n-tuple clicking; to scrolling the areas pointed. Everything is possible! More than I could not with my mouse before it died. Some command line tricks with Bash are much useful to make an almost reasonable and not too frustrating usage of the bad sites or parts of softwares.
But there is an idea: what if I make a daemon (?) to associate the commands without the need to keep using a terminal window for everything?
So, my questions are:
1. In my whole life, even before i met linux, i never saw the scroll lock being used for anything.
2. I am thinking about making a scroll lock activated program to do everything I can with the mouse.
3. I use Mate Desktop, so I think something for it is possible. But maybe something more generic is possible. Something that might run in any window manager, possibly.
4. Making the daemon (?) associated with keyboard is something i imagine to be in the most basic parts of X. I do not need to program the same things that xdotool does. Simply executing shell commands can be perfectly enough.
4.1. The daemon (?) can be activated/deactivated with scroll lock; have different cursor moving speeds with arrows alone, and with ctrl, alt, shift and their combinations (ctrl+alt+arrows is a shortcut in Mate Desktop and Gnome 2, at least; i would choose to deactivate or have priority over them while the daemon [?] is active).
I have some experience with programming, in general, but I have never done such kind of things in linux. You do not need to tell me every detail, so I learn it from what you say here. Pointing or naming the information or subject to read, and one or other detail about it, can be enough.
I want to do this in C, bash scripting or python.
Forum metaquestion: should I ask future doubts about this project in another thread? Depends? On what, if so?
Browsing a web page without a mouse depends more on the web browser that you are using. And on the key binding shortcuts that you have.
On many browsers you can move from link to link with the tab button, and get to the drop drop down menus. There have already been some web browsers developed with "vi keybindings" Just the idea you are talking about.
People, I have been trying to use linux absolutely with no mouse. And it has been quite frustrating because several "details" in sites cannot be done without a mouse. They are possible to be, as far as I know about how sites work, before HTML5 or not, but sites hardly care about it. And several programs also have parts which are completely unaccessible to keyboard.
I have discovered a workaround: xdotool command and all its actions for doing what mouse does, from moving the cursor; clicking, double or n-tuple clicking; to scrolling the areas pointed. Everything is possible! More than I could not with my mouse before it died. Some command line tricks with Bash are much useful to make an almost reasonable and not too frustrating usage of the bad sites or parts of softwares. But there is an idea: what if I make a daemon (?) to associate the commands without the need to keep using a terminal window for everything?
So, my questions are:
1. In my whole life, even before i met linux, i never saw the scroll lock being used for anything.
2. I am thinking about making a scroll lock activated program to do everything I can with the mouse.
3. I use Mate Desktop, so I think something for it is possible. But maybe something more generic is possible. Something that might run in any window manager, possibly.
4. Making the daemon (?) associated with keyboard is something i imagine to be in the most basic parts of X. I do not need to program the same things that xdotool does. Simply executing shell commands can be perfectly enough.
4.1. The daemon (?) can be activated/deactivated with scroll lock; have different cursor moving speeds with arrows alone, and with ctrl, alt, shift and their combinations (ctrl+alt+arrows is a shortcut in Mate Desktop and Gnome 2, at least; i would choose to deactivate or have priority over them while the daemon [?] is active).
I have some experience with programming, in general, but I have never done such kind of things in linux. You do not need to tell me every detail, so I learn it from what you say here. Pointing or naming the information or subject to read, and one or other detail about it, can be enough. I want to do this in C, bash scripting or python.
Forum metaquestion: should I ask future doubts about this project in another thread? Depends? On what, if so?
You haven't really asked any questions, aside from whether or not you should ask in another thread; and if you read the forum rules, you'd see that you need to keep one topic in one thread, so no...don't ask in another thread.
The "daemon" would poll scroll-lock regularly to see if it's been toggled, and if it detects that it's on, it would (if I'm understanding you right) execute xdotool.
You don't need a daemon for this. You can just leave it running in a terminal.
The "daemon" would poll scroll-lock regularly to see if it's been toggled, and if it detects that it's on, it would (if I'm understanding you right) execute xdotool.
You don't need a daemon for this. You can just leave it running in a terminal.
Is not necessary a special kind of program to do this? A program without the focus will not receive keyboard messages, will it? The actions I described with 'xdotool' are tricky because the terminal where I run it cannot be over the part i want to click (I can pass the window to click, but finding and keeping each window ID, among several ones, is not easy). And when the click happens, the window will also get focus, if it does not have it already. To solve the hidden part thing, I make a 'sleep 1' or 'sleep 2' command before the one which makes the click, and use this time to get the window shown, like:
It depends on the window manager you are using. In fluxbox, I have in my ~/.fluxbox/keys file this
Code:
#Move mouse/click with xdotool
Control Mod1 Up :Exec (xdotool mousemove_relative -- 0 -15)
Control Mod1 Down :Exec (xdotool mousemove_relative 0 15)
Control Mod1 Right :Exec (xdotool mousemove_relative 15 0)
Control Mod1 Left :Exec (xdotool mousemove_relative -- -15 0)
Control Mod1 x :Exec (xdotool click 1)
Control Mod1 v :Exec (xdotool click 3)
Control Mod1 c :Exec (xdotool click 2)
I can use CTRL+ALT+key to move the mouse curser with the keyboard anywhere that I want. And click all 3 mouse buttons over a spot. I don't need a terminal for that. Just mapped keys.
Look at your window manager config files, and see how you can do that with what you are using.
Is not necessary a special kind of program to do this? A program without the focus will not receive keyboard messages, will it? The actions I described with 'xdotool' are tricky because the terminal where I run it cannot be over the part i want to click (I can pass the window to click, but finding and keeping each window ID, among several ones, is not easy). And when the click happens, the window will also get focus, if it does not have it already. To solve the hidden part thing, I make a 'sleep 1' or 'sleep 2' command before the one which makes the click, and use this time to get the window shown, like:
$ sleep 1; xdotool click 1
Sorry, but are you not reading the other replies??? You can *ALREADY DO THIS* in several ways...you don't have to write your 'project' at all. Both boughtonp and I gave you several ways to do this already. Teckk gave you more.
Browsing a web page without a mouse depends more on the web browser that you are using. And on the key binding shortcuts that you have.
On many browsers you can move from link to link with the tab button, and get to the drop drop down menus. There have already been some web browsers developed with "vi keybindings" Just the idea you are talking about.
HTML 5 pages can have things that do not count for the cycle we do with TAB key. Some of them have the absurdly annoying thing of overriding my browser shortcuts, something I simply hate.
In this mouseless situation, I discovered a new way to focus those "away from TAB" things: I search their text. Problem: there are quite a few times they have no text, but simply an image (ironically, in an evil way, some of these images are simply coloured text).
I know that's for arch, but you can get the source from that, get it, install the depends form your distros repo, compile it yourself, try them out.
Nice. I never heard about these browsers. I will try them. But I want to solve my problem for all programs. Browser is an important one, but not the only one distinctly important.
You haven't really asked any questions, aside from whether or not you should ask in another thread; and if you read the forum rules, you'd see that you need to keep one topic in one thread, so no...don't ask in another thread.
My "question" is the wish for information about the kind of thing I want to do. And I understand your point about "topic/threads", it is natural for me, not my doubt. I am part of Linux Question for several years, and I think my ideas about our behaviour here are solid. What I imagined was eventual questions which answers could be useful here, but they would have no relation to any other discussion, including this one. So, they could be detached.
Look under the "Accessibility" options in your DE. And you can probably pick up a new mouse for less than $5 at your local thrift store.
I do not mind people giving me information in any of those languages or Bash, as long as I can do what I called a "daemon". I am not even sure this is possible with a Bash script, but I have fun doing them, and I know some advanced things with it. C is an old language which I have used to do pretty complex things, for a nice amount of years. Might be a bit rusty, but I will not mind solving that. And Python is a language I started learning since no more than one year. I like it, anyway. Can be a good thing to learn and train it, I imagine.
I am using Mate Desktop. And I checked accessibility item in the control panel. I did not find anything like my idea, though.
I did not check the links you sent. They seemed to be for getting a working solution of what I want to do. Not for doing it. Anyway, I will check them soon, just to...
A new mouse is cheap, I know. But this is something I have wished to do before. So, need+wish = me deciding to do something more seriously. >,<
$ setxkbmap -v 10 -option keypad:pointerkeys
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules: evdev
model: pc102
layout: br
options: keypad:pointerkeys
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+br+inet(evdev)+keypad(pointerkeys)
geometry: pc(pc102)
$
First part of the above output, shows everything that starts with "xm". Second part, makes the command to "turn on" numpad as mouse keys, according to the article. The next line is the output of my tests trying to use it:
1. I press numpad keys "123" in the sequence "abcbabc", respectively.
2. Hold ALT and press Num Lock. It is turned off normally.
3. I press the same numpad sequence in item 1: "abcbabc".
4. Hold ALT and press Num Lock. It is turned off normally.
5. I press numpad sequence of item 1 again: "abcbabc".
6. I checked the 'setxkbmap' manual for a "verbose" option, or something similar. I turned it on in the maximum. Output is shown. I am not sure about every detail written there, but the option I asked is written there. But I am unable to use it as described in the Wikipedia article.
I want to understand what is happening here. But this is not the "program it like this" kind of comment I expected.
It's a test from when I was experimenting with writing my own gamepad-to-keyboard mapper.
Code:
#!/usr/bin/env python3
import evdev
# Determine this before running the program
gamepad = '/dev/input/event6'
dev = evdev.InputDevice(gamepad)
with evdev.UInput() as ui:
for event in dev.read_loop():
# Of all gamepad events, this if looks for button A
if (event.code == evdev.ecodes.BTN_A):
# Event happened.
# https://python-evdev.readthedocs.io/en/latest/tutorial.html#injecting-input
# has a very similar code.
ui.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_A, event.value)
# event.value is to generate key up and key down events as the keyboard,
# specifically, as they happen in the gamepad? Holding the key there generates
# several symbols in the screen, like we do with the keyboard?
# What this function does? "SYNchronization"?
ui.syn()
A pretty short code. It associates the "A" gamepad key with the "a" in the keyboard, right? So, whenever we press gamepad "A", the focused program will receive the "a" key event. Shift, ctrl and alt to modify this event works? And would this work in TTY[1-6] screens?
But what you are suggesting for me, if I get it right, is to use the scroll lock key to toggle the behaviour of the program. So, pressing it one time, I associate some keys with keyboard events, as I want. Scroll lock again, undo it. Is this the path to experiment, dugan?
My "question" is the wish for information about the kind of thing I want to do. And I understand your point about "topic/threads", it is natural for me, not my doubt. I am part of Linux Question for several years, and I think my ideas about our behaviour here are solid. What I imagined was eventual questions which answers could be useful here, but they would have no relation to any other discussion, including this one. So, they could be detached.
I do not mind people giving me information in any of those languages or Bash, as long as I can do what I called a "daemon". I am not even sure this is possible with a Bash script, but I have fun doing them, and I know some advanced things with it. C is an old language which I have used to do pretty complex things, for a nice amount of years. Might be a bit rusty, but I will not mind solving that. And Python is a language I started learning since no more than one year. I like it, anyway. Can be a good thing to learn and train it, I imagine. I am using Mate Desktop. And I checked accessibility item in the control panel. I did not find anything like my idea, though.
I did not check the links you sent. They seemed to be for getting a working solution of what I want to do. Not for doing it. Anyway, I will check them soon, just to...A new mouse is cheap, I know. But this is something I have wished to do before. So, need+wish = me deciding to do something more seriously.
Still makes zero sense; you were given programs that already do what you want to do...yet you don't want to use them?? And if you're asking for advice on how to write such a thing, your first step is to actually pick a language. Saying "bash, python, or C" is meaningless, since implementation of such things will vary wildly between those languages.
Personally, I wouldn't waste my time duplicating what's already been done; I have enough work to do.
A pretty short code. It associates the "A" gamepad key with the "a" in the keyboard, right? So, whenever we press gamepad "A", the focused program will receive the "a" key event. Shift, ctrl and alt to modify this event works? And would this work in TTY[1-6] screens?
But what you are suggesting for me, if I get it right, is to use the scroll lock key to toggle the behaviour of the program. So, pressing it one time, I associate some keys with keyboard events, as I want. Scroll lock again, undo it. Is this the path to experiment, dugan?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.