LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-18-2021, 04:15 PM   #1
Johannes33
Member
 
Registered: Jul 2015
Distribution: manjaro Xfce
Posts: 80

Rep: Reputation: Disabled
Scripting help: listen if window exist then send F6 to wine application.


Hi,
I run manjaro kde-plasma.
I would like to use a key combination to play/pause all my audio/media outputs.

In wine I run a program that I have to send F6 to to make it play/pause.

I think the best way is to write a script that looks if my wine app is active and then changes the media key to be sent as F6 to the program in wine.

I have a couple of questions:

1) blunt and simple: could someone help me create a scrip that does that or hint me in the direction on where I can find information on how to do that?



I have created a xdotool command that sends F6 to the wine program when executed in the terminal, but I have not been able to make it work reliably using xbindkeys.

here is my attempt in ~/.xbindkeysrc

Quote:
#Create a media key:
"xdotool key --clearmodifiers XF86AudioPlay"
Control + F5 + release

#send F6 to balabolka
"xdotool search --onlyvisible --name 'Balabolka.*' windowactivate key --window %@ F6"
XF86AudioPlay
2) Could you see what is wrong?

Also to get xbindkeys to start automatically I should place ‘xbindkeys’ in ~/.xinitrc before the line that starts my window manager or DE.

3) But where is that?
here is the file. I tried on line 12 but that screwed up my login screen:
Quote:
1 #!/bin/bash
2 #
3 # ~/.xinitrc
4 #
5 # Executed by startx (run your window manager from here)
6
7
8 userresources=$HOME/.Xresources
9 usermodmap=$HOME/.Xmodmap
10 sysresources=/etc/X11/xinit/.Xresources
11 sysmodmap=/etc/X11/xinit/.Xmodmap
12
13 DEFAULT_SESSION=startplasma-x11
14
15 # merge in defaults and keymaps
16
17 if [ -f $sysresources ]; then
18 xrdb -merge $sysresources
19 fi
20
21 if [ -f $sysmodmap ]; then
22 xmodmap $sysmodmap
23 fi
24
25 if [ -f "$userresources" ]; then
26 xrdb -merge "$userresources"
27 fi
28
29 if [ -f "$usermodmap" ]; then
30 xmodmap "$usermodmap"
31 fi
32
33 # start some nice programs
34
35 if [ -d /etc/X11/xinit/xinitrc.d ] ; then
36 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
37 [ -x "$f" ] && . "$f"
38 done
39 unset f
40 fi
41
42 get_session(){
43 local dbus_args=(--sh-syntax --exit-with-session)
44 case $1 in
45 awesome) dbus_args+=(awesome) ;;
46 bspwm) dbus_args+=(bspwm-session) ;;
47 budgie) dbus_args+=(budgie-desktop) ;;
48 cinnamon) dbus_args+=(cinnamon-session) ;;
49 deepin) dbus_args+=(startdde) ;;
50 enlightenment) dbus_args+=(enlightenment_start) ;;
51 fluxbox) dbus_args+=(startfluxbox) ;;
52 gnome) dbus_args+=(gnome-session) ;;
53 i3|i3wm) dbus_args+=(i3 --shmlog-size 0) ;;
54 jwm) dbus_args+=(jwm) ;;
55 kde) dbus_args+=(startplasma-x11) ;;
56 lxde) dbus_args+=(startlxde) ;;
57 lxqt) dbus_args+=(lxqt-session) ;;
58 mate) dbus_args+=(mate-session) ;;
59 xfce) dbus_args+=(xfce4-session) ;;
60 openbox) dbus_args+=(openbox-session) ;;
61 *) dbus_args+=($DEFAULT_SESSION) ;;
62 esac
63
64 echo "dbus-launch ${dbus_args[*]}"
65 }
66 nvidia-settings --load-config-only
67 exec $(get_session "$1")

Last edited by Johannes33; 10-19-2021 at 01:37 AM.
 
Old 10-19-2021, 05:25 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
As side note, maybe you don't known, but this is already possible in KDE in "System Settings / Shortcuts". You can define global shortcut, when pressed it will send specific keystroke to specified window.
 
Old 10-19-2021, 08:18 AM   #3
Johannes33
Member
 
Registered: Jul 2015
Distribution: manjaro Xfce
Posts: 80

Original Poster
Rep: Reputation: Disabled
Thanks for the reply,
I have used that solution for some time before. Currently I have not tried it since I do not like the implementation:

It is not possible to use the same key press for all.

I have to go in to the system settings and reassign the shortcuts every time I use a different program. Even if I press 'Apply' after I have reassigned, a lot of times I have to reboot because some bug does not send the keystroke to the program unless I do that (on kde-neon).

So now I was after a more permanent solution.

Last edited by Johannes33; 10-19-2021 at 08:26 AM.
 
Old 10-19-2021, 07:49 PM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,237

Rep: Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321Reputation: 5321
Sending F6 to the kernel and not to a specific window is also an option. The Python interface for that is actually really nice. See my post here:

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


Reply

Tags
scripting



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
suddenly vlc audio chunky. got sound then no sound then got sound then no sound.. andrewysk Linux - Newbie 4 04-21-2021 08:19 PM
[SOLVED] cannot login to funtoo linux. UID 0 does not exist. no users or groups seem to exist. whansard Linux - Security 1 12-19-2018 03:40 AM
Postfix : mail cannot send to send outside ( can send/receive locally) bobbinsupport Linux - Networking 3 12-15-2007 10:40 PM
apache security for intranet: "listen 80" vs. "listen 127.0.0.1:80" pulper Linux - Software 3 09-27-2006 06:24 AM
Javascript - what to use rather than window.close() then window.open() davee Programming 2 04-11-2005 08:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:37 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