LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-07-2023, 07:41 PM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,689
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
need alternative to "xdotool"


i need to feed some keyboard input into the X based desktop as part of a broad setup script that is run after my laptop boots into Xubuntu 20.04 LTS. i have tried "xdotool" for this purpose but it is not suitable.

i am running with "LightDM" as the display manager with multiple userids set to not prompt for password at the desktop. the allows "LightDM" to rapidly switch between users. each user is run under a separate instance of "Xorg". only one instance of "Xorg" is connected to the display, keyboard, and mouse at a time. "Xorg" is programmed to deal with being connected and disconnect when it is signaled to do so. this signalling is done by the kernel when a console change key is pressed. alternatively "LightDM" can make these switches. i don't know the API involved, but i suspect "LightDM" uses a kernel interface to have the kernel do it.

this console switching appears to be the cause of the problems i am having with "xdotool". when i use "xdotool" to virtually type in a command, it fails to type in anything, unless the instance of "Xorg" it is running under is connected. so this feature involves more than just "xdotool" interfacing with a particular instance of "Xorg". it appears to not be a case of sending to the wrong instance of "Xorg" as i have no cases of displaced commands.

my needs include some virtual typing input (done by components of the setup script) to the desktop independently for each user at times that user is disconnected from the desktop. the only real way to do this is for a typed input tool to communicate with "Xorg" directly, at least when it is disconnected from the desktop.

an alternate typed input tool is what i am looking for to replace "xdotool". this will allow my setup script to complete much faster by allowing the user setup part to run in parallel while disconnected, instead of waiting for each user's setup to be carried out while connected to the display. the user setup parts vary by user but typically take around 30 seconds each. with 18 users involved this can be 9 minutes of time. time i want to shorten.

has anyone who understands this issue heard of, know of, or written an alternative tool that can work with "Xorg" even while it is in a disconnected state (it is still running in this state as many other X-related setups do work)?
 
Old 04-09-2023, 06:17 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,153
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
How about this:
https://github.com/ReimuNotMoe/ydotool

I haven't used it.
 
Old 04-10-2023, 04:22 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,066

Rep: Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353
if you want to run a setup script just connect it to a pipe or similar and you can send any command to it using that pipe and without Xorg.
 
Old 04-10-2023, 02:12 PM   #4
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,689

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by teckk View Post
How about this:
https://github.com/ReimuNotMoe/ydotool

I haven't used it.
i haven't used it, either. to test if it can send input to the selected instance of X or the X it is running in (how to detect this?) among many instances or X that are disconnected from the physical console. can the /dev/uinput system determine this? maybe an X server is suppose it "unhook" from whatever input it is using so another (or virtual console) can "hook" to it. i need to read up on /dev/uinput to see what it handles. the need for root can be worked around in my case.
 
Old 04-10-2023, 06:11 PM   #5
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,689

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by pan64 View Post
if you want to run a setup script just connect it to a pipe or similar and you can send any command to it using that pipe and without Xorg.
some of the input goes to apps that have a window open on X. the setup involves how things are arranged in the GUI environment of most users.

suppose with 3 users, 2 are disconnected from the console and "admin" is connected (it has sudo powers). both of the disconnected users have their pointer inside a window. now feed up/down key actions to the 2nd user sending "foobar\r". can the 2nd user be identified? this is the kind of thing i am worried about.

i was hoping X had a secret port to listen for input. maybe this is what /dev/uinput does (it could register its identity). then there a security issues and maybe even denial of service issues in all of this.

i might have to run X via VNC and intercept that protocol to inject input. i would have to leave each X connected and have the interception fake the connect/disconnect activity.
 
Old 04-11-2023, 12:32 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,066

Rep: Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353Reputation: 7353
Quote:
Originally Posted by Skaperen View Post
some of the input goes to apps that have a window open on X. the setup involves how things are arranged in the GUI environment of most users.

suppose with 3 users, 2 are disconnected from the console and "admin" is connected (it has sudo powers). both of the disconnected users have their pointer inside a window. now feed up/down key actions to the 2nd user sending "foobar\r". can the 2nd user be identified? this is the kind of thing i am worried about.

i was hoping X had a secret port to listen for input. maybe this is what /dev/uinput does (it could register its identity). then there a security issues and maybe even denial of service issues in all of this.

i might have to run X via VNC and intercept that protocol to inject input. i would have to leave each X connected and have the interception fake the connect/disconnect activity.
X has its own console. (or terminal). X does not handle itself the keyboard events, but the console (where it is attached to) (You can see it for example with ps). Inside X you can create [almost] any number of pseudo terminals, which will connected to terminal emulators or apps running inside, but actually the events of the original console will be redirected to those ptys (depending on the focus). When you switch X, the server will not be detached from that terminal, just it will not be displayed any more (and also that terminal will not get any input, because those events will be sent to another one).
What I suggested is: use IPC (inter-process communication) (or something similar) which is the common way to send data between apps. For example you can use
Code:
echo "text" > /dev/pts/12
to send text to that pseudo terminal. Obviously it does not work with mouse events. But in general you don't need to identify the user, but the process.
by the way xdotool needs the DISPLAY variable, so it can always send the event to the named X, if it is allowed (to access that display). It does not depend on the screen.
 
  


Reply



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
[SOLVED] FC35+KDE: need xdotool functionality, does it means I need to disable wayland? kaza Linux - Desktop 7 08-14-2022 12:39 PM
[SOLVED] application "wine"; target for using windows hotkeys with the help of xdotool; issues for now floppy_stuttgart Linux - Software 3 04-16-2022 08:26 AM
[SOLVED] Programmatically moving the mouse with the "xdotool" PaulExordium Debian 10 01-28-2021 12:39 PM
Need to offline install xdotool on red hat 4.8 yllawwally Linux - Newbie 8 01-29-2020 06:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 01:53 PM.

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