Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
0 answers
38 views
Automatic backup on a second internal hidden disk when files are moved to a first disk
Summary: I need to automatically backup files on a hidden hard disk whenever the user copy files on a specific hard disk. Long explanation: Context: My father (70 years old) is very bad at computers. He barely knows how to copy and paste with a graphical interface, nothing more. I have installed him...
Summary: I need to automatically backup files on a hidden hard disk whenever the user copy files on a specific hard disk. Long explanation: Context: My father (70 years old) is very bad at computers. He barely knows how to copy and paste with a graphical interface, nothing more. I have installed him a linux mint distro which I have tailored so he doesn't crash it and understand easily. He use his computer mostly to save his photographies: around 2TB now... I plan to install him an extra hard disk called "photos" so he can discharge his photos on it. I also plan to put another disk ("photocopie") as a backup so in case the first hard disk crash, he will not lost his photographies. I will make this second hard disk hidden so my dad doesn't fuss with it. I would like to know how to automatically copy the new photos he adds on the hard disk "photos" to the second one "photocopies"; he only do how to do this using caja (Mate file manager). I had first read about using raid 1 but it doesn't seems to be the proper solution. Some suggested using rsync with cron, however cron work at specific times, and since my dad doesn't use his computer often, it may not work properly. I was trying to find an app that would start at a specific event such as "if files are written on hard disk photos, then run rsync as incremental on the hard disk photocopie", but I couldn't find an app detecting events. I have read about inotifywait, could it be the solution? How to implement that? PS: the photo sources could be anything than can be plugged by USB: a camera, an smartphone (Apple). My dad usually run caja and copy past from the phone to the proper directory/hard disk.
Some old geek (1 rep)
Jun 18, 2025, 02:59 PM
0 votes
0 answers
113 views
When HDMI is plugged into computer, run script
**Setup** Headless single board computer [(this one)][1] which has an HDMI **in**put *(To clarify, this is a port which takes in HDMI like a monitor would. It will* **receive** *HDMI feed, not export it, like a computer normally would. Most computers don't have an HDMI-in port, so it's necessary to...
**Setup** Headless single board computer (this one) which has an HDMI **in**put *(To clarify, this is a port which takes in HDMI like a monitor would. It will* **receive** *HDMI feed, not export it, like a computer normally would. Most computers don't have an HDMI-in port, so it's necessary to specify that this one does and that's what we're talking about.)* Android device with HDMI output **Goal** As soon as the HDMI output cable gets plugged into the headless computer, a script is triggered which records the video stream. When it's disconnected, another script is triggered (to process the recorded video). I haven't been able to nail down how to access an HDMI input programmatically, or how to edit the default behavior when one starts to receive input. I'm guessing that Linux will have a way to do this, but if there's a solution with Android, Orange Pi Droid, or OpenWRT, I'll take it. Thanks! (I've read some other posts, but none of them had conclusive answers. Here are some of them: Run a script on monitor connection/disconnection event Triggering a script when I plug in an HDMI in Raspberry Pi 4 Commands to run when Connecting HDMI )
EthanL (1 rep)
Dec 13, 2024, 03:09 PM • Last activity: Dec 13, 2024, 05:07 PM
0 votes
0 answers
13 views
Can X11 pass the identifiers/names of the involved pointers/keyboards when passing/generating input events? Do Tk/Gtk/Qt do too?
If I type `xinput` I get the following output: ``` ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Logitech USB Optical Mouse id=12 [slave pointer (2)] ⎜ ↳ WingCoolTouch WingCoolTouch id=13 [slave pointer (2)] ⎜ ↳ WingCoolTouch WingCoolTou...
If I type xinput I get the following output:
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech USB Optical Mouse                id=12   [slave  pointer  (2)]
⎜   ↳ WingCoolTouch WingCoolTouch               id=13   [slave  pointer  (2)]
⎜   ↳ WingCoolTouch WingCoolTouch               id=14   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ Chicony USB Keyboard                      id=9    [slave  keyboard (3)]
    ↳ Chicony USB Keyboard Consumer Control     id=10   [slave  keyboard (3)]
    ↳ Chicony USB Keyboard System Control       id=11   [slave  keyboard (3)]
in other words, individual input devices have individual IDs & names. When receiving an input event, it is usually possible to differentiate whether it came from a mouse or a keyboard. But is it also possible to differentiate from *which* mouse or keyboard it came from? If possible in X11, does this carry over to Tk/Gtk/Qt?
mo FEAR (157 rep)
Aug 4, 2024, 07:59 AM
2 votes
0 answers
120 views
Can I simulate power supply getting offline using udev or in other ways under Linux?
I have created the rule `/etc/udev/rules.d/80.power.rules`: ``` SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/root/test.sh" ``` Then I execute the command `udevadm trigger /sys/class/power_supply/ACAD -c offline -v ` (note **offline**) and I see that `/root/test.sh` _is not_ execu...
I have created the rule /etc/udev/rules.d/80.power.rules:
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/root/test.sh"
Then I execute the command `udevadm trigger /sys/class/power_supply/ACAD -c offline -v (note **offline**) and I see that /root/test.sh` _is not_ executed. If I set ENV{POWER_SUPPLY_ONLINE}=="1" and execute udevadm trigger /sys/class/power_supply/ACAD -c online -v (note **online**), then /root/test.sh _is_ executed. Is there any way to simulate the power unplug event so that udev would execute my script? If there are ways without udev, it's also okay. The point is that I need to simulate power plug/unplug situation on Linux. Thank you for attention!
JenyaKh (346 rep)
Jan 15, 2024, 01:29 PM
2 votes
1 answers
1396 views
What could cause a missing mouse scroll event just after reversing scroll direction?
I'm using Ubuntu 22.04.2 on an x86_64 system, with Xorg and libinput. I have a Logitech MX Master mouse (the first model), and I've noticed some unusual behaviour with scrolling. The mouse has a free-wheeling scroll wheel which can be set to "notched" mode, allowing distinct tactile feedback for eac...
I'm using Ubuntu 22.04.2 on an x86_64 system, with Xorg and libinput. I have a Logitech MX Master mouse (the first model), and I've noticed some unusual behaviour with scrolling. The mouse has a free-wheeling scroll wheel which can be set to "notched" mode, allowing distinct tactile feedback for each scroll event. The problem is that sometimes a scroll event is missed. E.g. scrolling through Firefox, or an IDE window, sometimes moving the wheel a single notch has no visual effect, but subsequent notches work OK. Narrowing it down, it seems that the *first notch in the alternate direction* is always dropped. I.e. if I scroll down three notches, the visual response corresponds to three scroll events, then if I scroll up one notch, there is no response. The second up event does cause a visual response. I used xev -event button and it clearly shows no ButtonPress or ButtonRelease events if I move the scroll wheel up/down a single notch. I have to reverse direction and move it two notches to see any new events. I used evtest and libinput debug-events and the device itself is definitely generating correct low-level messages for scroll wheel movements - so the low level and hardware are working properly. From [this](https://unix.stackexchange.com/questions/403616/how-can-i-debug-x11-missing-mouse-buttonrelease-events-that-are-present-in-usbmo) question, I think this suggests the issue is somewhere above libinput - what would be the next component in the stack to look at? EDIT: Given that xev shows the problem, and libinput debug-events does not, I'm thinking that the obvious first place to look is xf86-input-libinput, so I've built my own version and will start debugging it shortly... EDIT2: after putting in debug for xf86-input-libinput I have confirmed that the data coming into this layer from libinput is intact, and seemingly correct, but the conversion to X11 input events seems to drop some of the data. Unfortunately, having live debug output in the log causes the problem to disappear, so I'm wondering if this is some kind of timing related situation, perhaps with regards to scroll wheel position estimation? I'll dig deeper when I have time.
davidA (181 rep)
Apr 24, 2023, 01:13 AM • Last activity: Apr 30, 2023, 11:22 PM
2 votes
1 answers
122 views
Verifiy if a mouse is defective
I have only Linux machines (Ubuntu 22.04) and I've just received a 3D Connexion CadMouse Pro that officially does not support Linux. But I guess it's about the control software, as an HID mouse it should at least move the pointer. I'm afraid it may be defective. I'm looking for a way to understand i...
I have only Linux machines (Ubuntu 22.04) and I've just received a 3D Connexion CadMouse Pro that officially does not support Linux. But I guess it's about the control software, as an HID mouse it should at least move the pointer. I'm afraid it may be defective. I'm looking for a way to understand if the mouse itself is working or not. Here some debugging I made: $ lsusb Bus 002 Device 003: ID 05e3:0723 Genesys Logic, Inc. GL827L SD/MMC/MS Flash Card Reader Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 014: ID 1ea7:002c SHARKOON Technologies GmbH USB Gaming Mouse Bus 003 Device 010: ID 0a5c:2148 Broadcom Corp. BCM92046DG-CL1ROM Bluetooth 2.1 Adapter Bus 003 Device 009: ID 0a5c:4503 Broadcom Corp. Mouse (Boot Interface Subclass) Bus 003 Device 008: ID 0a5c:4502 Broadcom Corp. Keyboard (Boot Interface Subclass) Bus 003 Device 006: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) Bus 003 Device 015: ID 256f:c656 3Dconnexion CadMouse Pro Bus 003 Device 005: ID 04d9:a061 Holtek Semiconductor, Inc. USB Keyboard Bus 003 Device 004: ID 256f:c635 3Dconnexion SpaceMouse Compact $ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ HID 0a5c:4503 Mouse id=13 [slave pointer (2)] ⎜ ↳ USB Gaming Mouse id=15 [slave pointer (2)] ⎜ ↳ USB Gaming Mouse Consumer Control id=16 [slave pointer (2)] ⎜ ↳ 3Dconnexion CadMouse Pro id=19 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Power Button id=8 [slave keyboard (3)] ↳ USB Keyboard id=9 [slave keyboard (3)] ↳ USB Keyboard System Control id=10 [slave keyboard (3)] ↳ USB Keyboard Consumer Control id=11 [slave keyboard (3)] ↳ HID 0a5c:4502 id=12 [slave keyboard (3)] ↳ USB Gaming Mouse id=14 [slave keyboard (3)] ↳ USB Gaming Mouse System Control id=17 [slave keyboard (3)] ↳ USB Gaming Mouse Consumer Control id=18 [slave keyboard (3)] [10193.373908] usb 3-4.5: new full-speed USB device number 16 using xhci_hcd [10193.488391] usb 3-4.5: New USB device found, idVendor=256f, idProduct=c656, bcdDevice= 1.08 [10193.488397] usb 3-4.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [10193.488399] usb 3-4.5: Product: CadMouse Pro [10193.488400] usb 3-4.5: Manufacturer: 3Dconnexion [10193.497577] input: 3Dconnexion CadMouse Pro as /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4.5/3-4.5:1.0/0003:256F:C656.0015/input/input47 [10193.497760] hid-generic 0003:256F:C656.0015: input,hidraw8: USB HID v1.11 Mouse [3Dconnexion CadMouse Pro] on usb-0000:00:14.0-4.5/input0 [10193.499613] input: 3Dconnexion CadMouse Pro as /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4.5/3-4.5:1.1/0003:256F:C656.0016/input/input48 [10193.499687] hid-generic 0003:256F:C656.0016: input,hiddev2,hidraw9: USB HID v1.11 Multi-Axis Controller [3Dconnexion CadMouse Pro] on usb-0000:00:14.0-4.5/input1 $ ls -l /dev/input/by-id/ totale 0 lrwxrwxrwx 1 root root 9 mar 17 09:21 usb-04d9_USB_Keyboard-event-if01 -> ../event5 lrwxrwxrwx 1 root root 9 mar 17 09:21 usb-04d9_USB_Keyboard-event-kbd -> ../event4 lrwxrwxrwx 1 root root 10 mar 17 09:21 usb-0a5c_4502-event-kbd -> ../event12 lrwxrwxrwx 1 root root 10 mar 17 09:21 usb-0a5c_4503-event-mouse -> ../event13 lrwxrwxrwx 1 root root 9 mar 17 09:21 usb-0a5c_4503-mouse -> ../mouse1 lrwxrwxrwx 1 root root 9 mar 17 12:00 usb-1ea7_USB_Gaming_Mouse-event-if02 -> ../event9 lrwxrwxrwx 1 root root 9 mar 17 12:00 usb-1ea7_USB_Gaming_Mouse-event-kbd -> ../event7 lrwxrwxrwx 1 root root 9 mar 17 12:00 usb-1ea7_USB_Gaming_Mouse-if01-event-mouse -> ../event8 lrwxrwxrwx 1 root root 9 mar 17 12:00 usb-1ea7_USB_Gaming_Mouse-if01-mouse -> ../mouse0 lrwxrwxrwx 1 root root 10 mar 17 12:10 usb-3Dconnexion_CadMouse_Pro-event-if01 -> ../event24 lrwxrwxrwx 1 root root 10 mar 17 12:10 usb-3Dconnexion_CadMouse_Pro-event-mouse -> ../event23 lrwxrwxrwx 1 root root 9 mar 17 12:10 usb-3Dconnexion_CadMouse_Pro-mouse -> ../mouse2 lrwxrwxrwx 1 root root 9 mar 17 09:21 usb-3Dconnexion_SpaceMouse_Compact-event-if00 -> ../event3 Hence it seems it recognizes my mouse on /dev/input/mouse2 and /dev/input/event23 / /dev/input/event24. I also tried to cat those files while moving the mouse, but there is no output. Instead if I sudo cat /dev/input/mouse0 (the mouse that I'm using right now) I see some output. Can I assume the mouse is not working at all? Or is there anything else I can try?
Mark (815 rep)
Mar 17, 2023, 11:19 AM • Last activity: Mar 17, 2023, 04:11 PM
2 votes
0 answers
696 views
/dev/input/event doesn't report keys being pressed
I have an usb keyboard connected to a linux box. I need to capture all keys that have been pressed and released. [![enter image description here][1]][1] My keyboard n-key rollover meaning that it doesn't have limits on number of concurrent keys being held. They are all detected and reported. They ke...
I have an usb keyboard connected to a linux box. I need to capture all keys that have been pressed and released. enter image description here My keyboard n-key rollover meaning that it doesn't have limits on number of concurrent keys being held. They are all detected and reported. They keyboard works fine in terminal and x-windows. I can press and hold keys one after another and each time a new character appears on the screen. I tried ten and they are all detected. HOWEVER: when I read data from /dev/input/eventX corresponding to keyboard the data stops coming after 6 keys has been pressed. I wrote a small program in node.js, but I can observe the same behaviour even by doing "cat /dev/input/eventX". It's very puzzling, because I would assume that there is a same driver that is used to read keycodes and display them in terminal. Anyone has any idea where and why event file is not receiving any data past 6 keys? What would be a way around this problem ? Tried with RPI (Debian and Ubuntu), OrangePI (Ubuntu) and PC (LinuxMint). Thanks, M here is the node.js code * const InputEvent = require('input-event'); const input = new InputEvent('/dev/input/event0'); function keyReleased(input) { console.log(input.code); } const keyboard = new InputEvent.Keyboard(input); keyboard.on('data' , function(input) { console.log("DATA:" + input.code); }); *
Misha Mikhail (21 rep)
Sep 16, 2022, 06:43 PM • Last activity: Sep 17, 2022, 08:10 PM
22 votes
5 answers
65429 views
Execute a shell command upon a click event in a web page
Is there a way to execute a bash command when I click on a text in a browser? The web page is on computer A, the browser is on computer B : I want to execute the code on computer B, e.g `hsetroot` to change the wallpaper when clicking an image.
Is there a way to execute a bash command when I click on a text in a browser? The web page is on computer A, the browser is on computer B : I want to execute the code on computer B, e.g hsetroot to change the wallpaper when clicking an image.
bob dylan (2002 rep)
Jun 21, 2015, 10:15 AM • Last activity: Jul 4, 2022, 01:57 PM
3 votes
1 answers
1593 views
Prevent Multiple Mouse Middle Click Events
For some weird reason, my mouse is sending `multiple middle click events` when I do a middle click at times. Happens once in a while - but not always. I'm fairly certain its a `hardware issue`. Its a major annoyance as I paste using middle click a lot - and the same text get pasted 2-3 times. I'm tr...
For some weird reason, my mouse is sending multiple middle click events when I do a middle click at times. Happens once in a while - but not always. I'm fairly certain its a hardware issue. Its a major annoyance as I paste using middle click a lot - and the same text get pasted 2-3 times. I'm trying to get over the issue without having to buy another mouse. > Is it possible to disable multiple middle click event if they happen in quick succession? > > xinput has a 'Evdev Middle Button Timeout' - but setting that to 1000 or so makes no difference.
Binny V A (131 rep)
Nov 6, 2015, 12:29 PM • Last activity: Jun 3, 2022, 09:02 PM
1 votes
1 answers
444 views
Not understanding the use of EVIOCGRAB for touchscreen devices
I am looking at a userspace library which handles touchscreen events from the Linux kernel. The following line of code, I can't understand what it does. What is the purpose of `EVIOCGRAB` when passed to ioctl here with the touchscreen file descriptor ,and why exactly is it required? ioctl(fd, EVIOCG...
I am looking at a userspace library which handles touchscreen events from the Linux kernel. The following line of code, I can't understand what it does. What is the purpose of EVIOCGRAB when passed to ioctl here with the touchscreen file descriptor ,and why exactly is it required? ioctl(fd, EVIOCGRAB, (void *)1); Google searches of EVIOCGRAB don't give me much i'm afraid. Thanks in advance.
Engineer999 (1233 rep)
Jun 2, 2022, 08:26 PM • Last activity: Jun 2, 2022, 10:29 PM
51 votes
2 answers
8790 views
How do I find out what program 'owns' a hotkey?
I'm running XFCE 4.12 on top of Gentoo with a 4.2.0 kernel. My PlayPause button on my keyboard used to work as a global hotkey for VLC. Now VLC won't even recognize the key. It does see "Alt + Media Play Pause" but not the key alone. Is there a way to see if and what program might be capturing that...
I'm running XFCE 4.12 on top of Gentoo with a 4.2.0 kernel. My PlayPause button on my keyboard used to work as a global hotkey for VLC. Now VLC won't even recognize the key. It does see "Alt + Media Play Pause" but not the key alone. Is there a way to see if and what program might be capturing that key? When I run xdotool key "XF86LogGrabInfo" the tail /var/log/Xorg.0.log file reads [ 10138.690] (II) Printing all currently active device grabs: [ 10138.690] (II) End list of active device grabs
Andrew Redd (1329 rep)
Feb 10, 2016, 09:56 PM • Last activity: May 21, 2022, 01:35 PM
1 votes
0 answers
1561 views
How to access gpio-keys from a shell script
In my embedded linux system, I defined some GPIOs as keys in the device tree so I can use them as keys in my application. This works fine so far. Now I want to add an early startup script to respond to one of those keys before my application starts, but I can't access the gpios via `/sys/class/gpio`...
In my embedded linux system, I defined some GPIOs as keys in the device tree so I can use them as keys in my application. This works fine so far. Now I want to add an early startup script to respond to one of those keys before my application starts, but I can't access the gpios via /sys/class/gpio anymore, because they are already keys (trying to export them gives write error: Device or resource busy). I could install evtest or simply read /dev/input/event0 where I can see key presses and releases, but I can't see a straight forward way to detect a long key press that way in a shell script. Any suggestion how this should be done?
Philippos (13680 rep)
May 13, 2022, 08:13 AM
0 votes
0 answers
569 views
Interpreting variations in LOCal timer interrupts number
Running a given workload in different CPU isolation (IRQs & processes) configurations, I do not observe significant differences among values (grand total) reported in `/proc/interrupts` & `/proc/stats` apart from the number of Local Timer Interrupts which I find varying by around 20%. A. From what I...
Running a given workload in different CPU isolation (IRQs & processes) configurations, I do not observe significant differences among values (grand total) reported in /proc/interrupts & /proc/stats apart from the number of Local Timer Interrupts which I find varying by around 20%. A. From what I knew, when current_clocksource = hpet, local timer interrupts are generated by comparators that will fire an interrupt following an = comparison (and not a >=) This having the consequence under heavy load to "forget" firing interrupts because current time has gone greater than the targeted value. From this, I would conclude that, for a given workload, the more LOCs the better. (less dropped events) B. From what I knew, the system can "coalesce" events and fire a single interrupt for several events that should occur within a timerslack_ns period of time. From this, I would conclude that, for a given workload and a given timerslack_ns, the less LOCs the better. (More opportunities offered to the system to coalesce) 1. Is my knowledge outdated or not appropriately used? (running under linux 5.4) 2. How can I determine the number of "forgotten" timer events ? 3. How can I determine the number of "coalesced" timer events? 4. Finally, given an identical workload and ignoring power consumption considerations, with only latency & throughput considerations (yes I am aware this is somehow contradictory, this being the reason for my CPU isolation testings) what configuration should I prefer between one offering high numbers (grand total) of LOCs interrupts and one offering much less? 5. In the same context, I have tried disabling kernel.timer_migration but failed to notice any significant change. I presume this is evidence that my IRQs & tasks are appropriately marshaled (no need for timer migration => no thread migration) but I could well be wrong and not read the correct set of data.
MC68020 (8557 rep)
Dec 28, 2021, 10:58 PM • Last activity: Jan 10, 2022, 05:04 PM
11 votes
2 answers
14935 views
`xdotool` does not send keys
I am trying to send keystrokes via `xdotool`. However, sending does not work properly. Below is the log of a script that should select all the text in Gedit and copy it (but it does nothing instead), along with its output (captured by redirecting both stdout and stderr): + xdotool getwindowname 2936...
I am trying to send keystrokes via xdotool. However, sending does not work properly. Below is the log of a script that should select all the text in Gedit and copy it (but it does nothing instead), along with its output (captured by redirecting both stdout and stderr): + xdotool getwindowname 29360262 *Unsaved Document 1 - gedit + xdotool key --window 29360262 ctrl+a + sleep 1 + xdotool key --window 29360262 ctrl+c + sleep 1 I have tried with Thunderbird, and the script does send the keys, but without modifiers (no Control, that is). By the way, in the script, keys are surrounded by ", like "ctrl+a". The difference between Gedit and Thunderbird may be that Gedit is a GTK3 application, whilst Thunderbird seems a GTK2 application (but Firefox, which seems a GTK3 application, behaves like Thunderbird). xdotool version 3.20141006.1 Operating System: Debian GNU/Linux 8.1 (Linux kernel 3.16.0-4-amd64) Desktop Manager: GNOME Shell 3.14.4
Eleno (1859 rep)
Jul 9, 2015, 05:10 PM • Last activity: Dec 8, 2021, 08:16 PM
2 votes
1 answers
1118 views
get event when user has selected a text in any window in X11
I want to write an app that shows a popup-menu after a user has selected a text in any window in Linux (debian based). Mac users may know "PopClip" (https://pilotmoon.com/popclip/) and as I was not able to find anything comparable on Linux, I started writing it on my own for Linux. But I am quite ne...
I want to write an app that shows a popup-menu after a user has selected a text in any window in Linux (debian based). Mac users may know "PopClip" (https://pilotmoon.com/popclip/) and as I was not able to find anything comparable on Linux, I started writing it on my own for Linux. But I am quite new to programming in X11 and I am wondering how to be notified in a c programm, when the user has selected a text in any window? I found several examples to be notified on e.g. mouse events like
window = DefaultRootWindow(display);
    XMapWindow(display, window); 
    
    XAllowEvents(display, AsyncBoth, CurrentTime);
    
    XGrabPointer(display, window, True, 
		PointerMotionMask | ButtonPressMask | ButtonReleaseMask , GrabModeAsync, GrabModeAsync, None, None, CurrentTime);

    while(1) {
        XNextEvent(display, &xevent);        
        switch (xevent.type) {
        ...
and I also found that one can be notified on SelectionNotify but that really does not do what I am looking for. Any examples known?
dirkc (31 rep)
Sep 28, 2021, 07:17 AM • Last activity: Sep 28, 2021, 09:06 AM
0 votes
1 answers
1650 views
Is it possible to dynamically update systemd-timer's onCalendar?
`sytemd-timer` has a feature "onCalendar" using which we can execute a script on points of time (on calendar). Is it possible to dynamically (programmatically) update or mutate that field? For example consider this application: 1- Executing a script (as a pre-task) and finding out the new date inter...
sytemd-timer has a feature "onCalendar" using which we can execute a script on points of time (on calendar). Is it possible to dynamically (programmatically) update or mutate that field? For example consider this application: 1- Executing a script (as a pre-task) and finding out the new date intervals that the main script should be run. 2- Updating the corresponding systemd-timer to use the new date (calendar) intervals. If it's not possible with systemd, how can we do it?
Zeta.Investigator (1190 rep)
Sep 22, 2021, 10:37 AM • Last activity: Sep 22, 2021, 12:15 PM
0 votes
0 answers
321 views
Side mouse buttons doesn't work
I switched to Pop! OS, but side mouse buttons doesn't work. On windows they were button 4 & 5, but here I used `xev` and it turns out button 4 & 5 were assigned to the scroll wheel. When I clicked side buttons it didn't say anything and didn't register it. My mouse is TUF GAMING M5. How can I enable...
I switched to Pop! OS, but side mouse buttons doesn't work. On windows they were button 4 & 5, but here I used xev and it turns out button 4 & 5 were assigned to the scroll wheel. When I clicked side buttons it didn't say anything and didn't register it. My mouse is TUF GAMING M5. How can I enable the side buttons?
Ali (1 rep)
Sep 14, 2021, 05:50 AM • Last activity: Sep 17, 2021, 11:00 AM
2 votes
1 answers
1268 views
script with `read` in bash while loop causing high CPU usage when run as a systemd service
I wrote a script to run specific actions conditional on input events informed by an event monitor, which looks something like ``` $ cat script.sh ----------------------------------------------------------- #!/usr/bin/bash stdbuf -oL /usr/bin/event_monitor | while IFS= read LINE do something with $LI...
I wrote a script to run specific actions conditional on input events informed by an event monitor, which looks something like
$ cat script.sh
-----------------------------------------------------------
#!/usr/bin/bash

stdbuf -oL /usr/bin/event_monitor | while IFS= read LINE
do
    something with $LINE
done
When run as a script from a bash terminal, the script consumes a normal amount of CPU, and executes the action only when a new line is printed. However, when run as a service with the following setup
$ cat event.service
-----------------------------------------------------------
[Unit]
Description=Actions upon events

[Service]
Type=simple
ExecStart=/path/to/script.sh

[Install]
WantedBy=default.target
The event_monitor command now takes over an entire logical core, and strace reveals that read is read()ing nothing as often as the processor allows:
$ strace -p $event_monitor_pid
-----------------------------------------------------------
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
read(0, "", 1)                          = 0
................ad nauseum
while the service still registers events and executes the conditional commands when real events do occur. What went wrong here? p.s. this happens with cras_monitor but not with acpi_listen. I tried to ensure that the while loop only starts after ensuring the underlying service successfully starts, but to no avail. Update: here are some potentially relevant bits of event_monitor's code:
...
#include 
...
# Print to console function:
static void event_occurrence(void *context, int32_t attribute)
{
	printf("Some attribute has changed to %d.\n", attribute);
}
...
int main(int argc, char **argv)
{
	struct some_service_client *client # defined in headers
	int rc
...
# Some routine
...
    some_service_client_set_event_occurence_callback(client,event_occurence)
...
	rc = some_func(client)
...
	while (1) {
		int rc;
		char c;
		rc = read(STDIN_FILENO, &c, 1);
		if (rc < 0 || c == 'q')
			return 0;
	}
...
}
seamux (168 rep)
Jun 22, 2021, 10:21 AM • Last activity: Jun 25, 2021, 12:00 AM
0 votes
1 answers
433 views
Linux on-exit (Ctrl-C) action
This is an interesting scenario and I'm relatively new in writing shell scripts. I have a case where I want the user to enter a password at a prompt. That works fine. The PROBLEM is if the user should `Ctrl-C` exit at that point. Because the password prompt turns off text entry to the terminal, if t...
This is an interesting scenario and I'm relatively new in writing shell scripts. I have a case where I want the user to enter a password at a prompt. That works fine. The PROBLEM is if the user should Ctrl-C exit at that point. Because the password prompt turns off text entry to the terminal, if the users exits there, text entry to the terminal is still turned off, leaving a frustrated user. In PHP programming we have a register_shutdown_function() which will be called on exit, regardless of where or when that happens in the program. Is there an equivalent in Bash for the Ctrl-C command?
Oliver Williams (1425 rep)
Apr 11, 2021, 07:21 PM • Last activity: Apr 11, 2021, 10:54 PM
1 votes
0 answers
25 views
How would a GUI widget differentiate between the semantic- and absolute direction of a touchpad event?
I've recently been trying out Ubuntu 20.10 with Gnome desktop on Wayland, using a touchpad that supports precision scrolling, i.e. which *does not emulate a mousewheel*. After enabling **natural scrolling** for the touchpad the scroll gestures I make with my fingers map naturally to the movement of...
I've recently been trying out Ubuntu 20.10 with Gnome desktop on Wayland, using a touchpad that supports precision scrolling, i.e. which *does not emulate a mousewheel*. After enabling **natural scrolling** for the touchpad the scroll gestures I make with my fingers map naturally to the movement of all the scrollable content on screen (moving my fingers upwards moves the content upwards). This is opposed to mapping the physical gesture to the movement of the "scrollbar thumb" (the handle) where moving my fingers upwards would move the thumb upwards, but the content downwards. However when hovering over a GUI element with an ***unambiguous* mapping** from physical to visual movement, such as the system's volume slider, the mapping between gesture and widget movement is surprisingly broken. In other words, an upwards gesture results in a downwards adjustment of the slider handle (let's ignore that the slider is horizontal -- if it were vertical it would undoubtedly literally have moved downwards). Obviously the widget is using the wrong abstraction to determine the direction of its movement. ### Quick overview (precision scrolling) In this post I'm focusing on precision scrolling events from modern touchpads since I get the impression that that is the most modern scrolling API. - **Natural scrolling** - Physical movement: **down** - Scrollable content movement: **down** (match) - Slider movement: **up** (mismatch) - **"Normal" scrolling** - Physical movement: **down** - Scrollbar "thumb" movement: **down** (match) - Slider movement: **down** (match) As mentioned, the slider has an unambiguous mapping between its movement and gesture movement but still manages to do the wrong thing. (It's unambiguous since a slider only has one moving part, as opposed to scrollable views which have two moving parts: content, and scrollbar thumb) Could you explain to me **how** a widget like this could determine the correct gesture direction instead of using the wrong abstraction as it does currently? How would it go about getting the absolute direction of movement? **Why** doesn't it already do this? I'm not asking as a developer in this case, but as someone interested in interaction design and in this problem. It seems like a simple thing to use the absolute direction of movement in all widgets that don't incorporate a scrollbar, since there is no ambiguity. I'm currently not very familiar with the intricacies of event handling in various Linux desktop environments.
Andreas (573 rep)
Nov 11, 2020, 07:40 PM • Last activity: Nov 11, 2020, 10:40 PM
Showing page 1 of 20 total questions