LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-21-2022, 03:49 PM   #1
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Rep: Reputation: 51
Question Questions about a possible project I want to make


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?

Thank you all in advance.
 
Old 09-21-2022, 04:01 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,141
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
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.

Let me see...

Here is a qt6 one, webengine.
https://aur.archlinux.org/packages/weaver-fossil
I have not built that because I dont fancy that idea.

There was a python one...

Here, Qt5 Qt6, webkit
https://aur.archlinux.org/packages/qutebrowser-git

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.
 
2 members found this post helpful.
Old 09-21-2022, 04:11 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,675

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by dedec0 View Post
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.

Aside from that you throw out C, bash, and Python....which one are you going to use? Not really sure what you're looking for, but you may want to put "linux arrow keys mouse" into your favorite search-engine, because this capability has been around a good while.
https://help.ubuntu.com/stable/ubunt...sekeys.html.en
https://linuxreviews.org/HOWTO_use_t..._mouse_in_XOrg
https://superuser.com/questions/1221...oard-in-ubuntu
https://www.youtube.com/watch?v=OkOb...annel=gotbletu

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.
 
1 members found this post helpful.
Old 09-21-2022, 07:27 PM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,240

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
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.
 
1 members found this post helpful.
Old 09-22-2022, 07:35 AM   #5
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554

I guarantee you can already control the mouse cursor with the keyboard.

A quick search reveals the answer: https://en.wikipedia.org/wiki/Mouse_keys

 
2 members found this post helpful.
Old 09-22-2022, 01:16 PM   #6
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by dugan View Post
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:

$ sleep 1; xdotool click 1
 
Old 09-22-2022, 02:08 PM   #7
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,141
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
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.

Last edited by teckk; 09-22-2022 at 02:10 PM.
 
Old 09-22-2022, 02:12 PM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,675

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by dedec0 View Post
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.
 
Old 09-22-2022, 04:41 PM   #9
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,240

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
Quote:
Originally Posted by dedec0 View Post
A program without the focus will not receive keyboard messages, will it?
This program would:

https://www.linuxquestions.org/quest...1/#post6287133

It's a test from when I was experimenting with writing my own gamepad-to-keyboard mapper.

Last edited by dugan; 09-22-2022 at 04:43 PM.
 
1 members found this post helpful.
Old 09-22-2022, 09:36 PM   #10
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by teckk View Post
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).

Quote:
Originally Posted by teckk View Post
Let me see...

Here is a qt6 one, webengine.
https://aur.archlinux.org/packages/weaver-fossil
I have not built that because I dont fancy that idea.

There was a python one...

Here, Qt5 Qt6, webkit
https://aur.archlinux.org/packages/qutebrowser-git

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.
 
Old 09-22-2022, 09:51 PM   #11
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by TB0ne View Post
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.


Quote:
Originally Posted by TB0ne View Post

Aside from that you throw out C, bash, and Python....which one are you going to use? Not really sure what you're looking for, but you may want to put "linux arrow keys mouse" into your favorite search-engine, because this capability has been around a good while.
https://help.ubuntu.com/stable/ubunt...sekeys.html.en
https://linuxreviews.org/HOWTO_use_t..._mouse_in_XOrg
https://superuser.com/questions/1221...oard-in-ubuntu
https://www.youtube.com/watch?v=OkOb...annel=gotbletu

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. >,<

Last edited by dedec0; 09-22-2022 at 09:57 PM.
 
Old 09-22-2022, 10:49 PM   #12
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by boughtonp View Post
I guarantee you can already control the mouse cursor with the keyboard.

A quick search reveals the answer: https://en.wikipedia.org/wiki/Mouse_keys

About what this article mentions:

1. My Debian 11 does not have 'xmousekeys'

2. I have mentioned and I use 'xdotool', and how.

3. The command 'setxkbmap -option keypad:pointerkeys' does not seem to do what is taught in that article.

For statement 1 and 3, I can show some terminal output:


$ xm
xmag xmlcatalog xmlpatternsvalidator
xmahjongg xmlindent xmodmap
xman xmllint xmore
xmessage xmlparse
xmkmf xmlpatterns

$ setxkbmap -option keypad:pointerkeys

$ 1232123~~~~~1232123

[...]

$ 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.
 
Old 09-23-2022, 01:13 AM   #13
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by dugan View Post
This program would:

https://www.linuxquestions.org/quest...1/#post6287133

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?

Last edited by dedec0; 09-23-2022 at 01:16 AM.
 
Old 09-23-2022, 08:48 AM   #14
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,675

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by dedec0 View Post
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.
 
Old 09-23-2022, 12:00 PM   #15
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,240

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
Quote:
Originally Posted by dedec0 View Post
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?
Sure.
 
  


Reply

Tags
keyboard



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Judges Want To Make Life Harder On Patent Trolls: Want Them To Actually Have To Explain What I LXer Syndicated Linux News 0 10-17-2014 03:20 PM
i want to edit this project http://www.linuxquestions.org/questions/programming-9/tc user1999 Linux - Newbie 2 12-06-2012 02:25 PM
i have a Elive comp, i want to format it and make it debian, want to keep macish gui nickmon Linux - Newbie 5 10-19-2006 05:27 PM
Questions, Questions, Questions Nappa Slackware 6 11-18-2003 02:56 PM
questions,questions,questions harddrive37 Linux - Networking 1 07-21-2003 10:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration