LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2012, 01:07 PM   #1
Vryali
LQ Newbie
 
Registered: Oct 2010
Location: Columbia, SC
Distribution: Arch Linux
Posts: 11

Rep: Reputation: Disabled
xdotool - intercept keystroke for only one window class.


Hey folks - I'm trying to make a switch to chrome and one of the things I didn't want to give up was some of my functionality with tabmix plus, so I thought I'd try to script it with xbindkeys and xdotools. I'm okay with doing this any way possible to achieve the end I'm looking for.

My xbindkeysrc line:
Code:
"/home/xxxx/.scripts/chrome_duptab.sh"
    m:0x14 + c:28
    Control+Mod2 + t
That works as expected, and it calls the script. The script works as expected in Chrome, but doesn't 'pass through' ctrl+t to other applications like I was expecting/hoping, hence the post!

Code:
#!/bin/sh
# To get the window class of Chrome - run this and then click on chrome:
# xprop -id $(xdotool selectwindow) | awk '/WM_CLASS/{print $4}'
which xdotool >/dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "xdotool must be installed to use this program."
    exit 1
fi

ActiveWindow="$(xdotool getactivewindow)"
ActiveClass="$(xprop -id ${ActiveWindow} | awk '/WM_CLASS/{print $4}' | sed 's/\"//g')"
SearchClass="Chromium"
if [ "${ActiveClass}" = "${SearchClass}" ]; then
    xdotool keydown alt
    sleep 0.1
    xdotool key d
    sleep 0.1
    xdotool key Return
    sleep 0.1
    xdotool keyup alt
else
    xdotool key ctrl+t
fi
exit
I've tried a few variations, and I'm not seeing an infinite loop like I was worried about, but it's certainly not working... Thanks in advance for any help!

Edit: Have a more immediate hack of just sending that key combo to firefox as well, so they both work as expected, but still would prefer to know how I should have done this

Last edited by Vryali; 07-27-2012 at 01:19 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
xdotool, XSendEvent or something like them jovie Linux - Software 1 01-09-2012 11:06 AM
Gnome kill/destroy window keystroke? Pathian Linux - Newbie 5 10-20-2011 03:14 PM
python: writing to a curses window from a class daweefolk Programming 1 03-24-2011 12:24 PM
how to send with xdotool a window to another Desktop X number? frenchn00b Linux - General 1 10-23-2009 01:31 PM
QEMU Automation / Send Keystroke to Window nemti Linux - Software 1 11-17-2006 03:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:29 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration