Assign key strokes to script not working

I’m on XFCE and try to assign keyboard shortcut to this script in /usr/local/bin

[john1@manjaro Dokumente]$ cat /usr/local/bin/my_playnext.sh 
#! /bin/bash
#spielt next song im mediaplayer
xdotool key XF86AudioNext

I assigned it to ctrl+alt+n

But nothing happens, no error messages in journal …

If i execute this script in terminal it works just fine.

What’s wrong …

SysInfo:

Generated on 2023-08-19 14:44:1692449066

#################### inxi -Fxzc0 ########################

System:
  Kernel: 6.1.44-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 13.2.1 Desktop: Xfce v: 4.18.1
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 81RS v: Lenovo Yoga S740-14IIL serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0J40709 WIN serial: <superuser required> UEFI: LENOVO
    v: BYCN39WW date: 05/28/2021
Battery:
  ID-1: BAT0 charge: 64.6 Wh (98.9%) condition: 65.3/62.0 Wh (105.3%) volts: 17.1 min: 15.4
    model: LGC L19L4PD2 status: full
CPU:
  Info: quad core model: Intel Core i7-1065G7 bits: 64 type: MT MCP arch: Ice Lake rev: 5 cache:
    L1: 320 KiB L2: 2 MiB L3: 8 MiB
  Speed (MHz): avg: 1472 high: 1500 min/max: 400/3900 cores: 1: 1500 2: 1500 3: 1500 4: 1276
    5: 1500 6: 1500 7: 1500 8: 1500 bogomips: 23968
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
  Device-1: Intel Iris Plus Graphics G7 vendor: Lenovo driver: i915 v: kernel arch: Gen-11
    bus-ID: 00:02.0
  Device-2: NVIDIA GP108M [GeForce MX250] vendor: Lenovo driver: nvidia v: 535.98 arch: Pascal
    bus-ID: 2b:00.0
  Device-3: Chicony Integrated Camera driver: uvcvideo type: USB bus-ID: 3-5:5
  Display: x11 server: X.Org v: 21.1.8 driver: X: loaded: modesetting,nvidia unloaded: nouveau
    dri: iris gpu: i915 resolution: 1: 1920x1080~60Hz 2: N/A
  API: OpenGL v: 4.6 Mesa 23.1.5 renderer: Mesa Intel Iris Plus Graphics (ICL GT2)
    direct-render: Yes
Audio:
  Device-1: Intel Ice Lake-LP Smart Sound Audio vendor: Lenovo driver: sof-audio-pci-intel-icl
    bus-ID: 00:1f.3
  API: ALSA v: k6.1.44-1-MANJARO status: kernel-api
  Server-1: sndiod v: N/A status: off
  Server-2: PipeWire v: 0.3.77 status: active
Network:
  Device-1: Intel Ice Lake-LP PCH CNVi WiFi driver: iwlwifi v: kernel bus-ID: 00:14.3
  IF: wlp0s20f3 state: up mac: <filter>
  Device-2: Realtek RTL8153 Gigabit Ethernet Adapter driver: r8152 type: USB bus-ID: 2-1.4:4
  IF: enp0s13f0u1u4 state: up speed: 1000 Mbps duplex: full mac: <filter>
  IF-ID-1: pan1 state: down mac: <filter>
Bluetooth:
  Device-1: Intel AX201 Bluetooth driver: btusb v: 0.8 type: USB bus-ID: 3-10:8
  Report: rfkill ID: hci0 rfk-id: 2 state: up address: see --recommends
Drives:
  Local Storage: total: 1.86 TiB used: 428.94 GiB (22.6%)
  ID-1: /dev/nvme0n1 vendor: Micron model: MTFDHBA1T0TCK size: 953.87 GiB temp: 44.9 C
  ID-2: /dev/sda vendor: Western Digital model: WD10EARX-00N0YB0 size: 931.51 GiB type: USB
  ID-3: /dev/sdb vendor: Kingston model: DataTraveler 2.0 size: 14.54 GiB type: USB
Partition:
  ID-1: / size: 57.85 GiB used: 38.49 GiB (66.5%) fs: ext4 dev: /dev/nvme0n1p8
  ID-2: /boot/efi size: 259.5 MiB used: 114.8 MiB (44.2%) fs: vfat dev: /dev/nvme0n1p1
Swap:
  ID-1: swap-1 type: partition size: 16.67 GiB used: 0 KiB (0.0%) dev: /dev/nvme0n1p9
Sensors:
  System Temperatures: cpu: 44.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Info:
  Processes: 286 Uptime: 1h 11m Memory: total: 16 GiB note: est. available: 15.19 GiB
  used: 3.02 GiB (19.9%) Init: systemd Compilers: gcc: 13.2.1 clang: 15.0.7 Packages: 2007
  Client: Unknown Client: wrapper-2.0 inxi: 3.3.29

I want to tell strawberry mediaplayer play next song!

Too complicated, i’m out

XFCE-FAQ

You’re getting the modifiers as well as XF86AudioNext. Add a small delay using sleep, like this:

#! /bin/bash

# can be 0.5 or lower but you'll have to 
# release the keys quickly
sleep 1  

#spielt next song im mediaplayer
xdotool key XF86AudioNext

Thats it, thank you very much!!!

But seems to be only strawberry should be running. But that doesn’t matter now, i go back to television football Spain against england and the field is full of nice girls :slight_smile:

1 Like

I think you can specify the window as well using xdotool.

From man xdotool:

--window window
               Send  keystrokes  to  a specific window id. You can use "WINDOW STACK" references like "%1" and "%@" here. If there is a window stack, then "%1" is
               the default, otherwise the current window is used.

               See also: "SENDEVENT NOTES" and "WINDOW STACK"

--clearmodifiers
               Clear modifiers before sending keystrokes. See CLEARMODIFIERS below.

You should be able to use --clearmodifiers instead of the delay.

Yes, much more to learn :slight_smile:

First lection: keyboard mute key superceeds all XFCE settings , even after reboot you have to klick unmute key again to hear sound.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.