LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-26-2008, 08:42 PM   #1
narc
Member
 
Registered: Aug 2004
Location: Montréal
Distribution: Linux from scratch
Posts: 68

Rep: Reputation: 15
Getting the name of the top-level or focused window in KDE


Hello.

I want to send into a file the top-level window, or the focused window currently in use under KDE. Is there a way to capture such informaton at any time ?

Thanks.
 
Old 08-30-2008, 12:31 AM   #2
aus9
Guru
 
Registered: Oct 2003
Posts: 5,056

Rep: Reputation: Disabled
I am not sure what your question is and as no-one has replied forgive me for my attempt.

If you want to capture the output of a command in a window ...generally this is achieved by

Code:
command > /pathwaytosavefile/newfilename
eg

$ ls > /home/gordy/ls
gordy@siduxbox:~$ cat ls
01dox
2008-08-27-09-03-31.011-VirtualBox-3329.log
Desktop
firefox
ls
 
Old 08-30-2008, 05:19 AM   #3
narc
Member
 
Registered: Aug 2004
Location: Montréal
Distribution: Linux from scratch
Posts: 68

Original Poster
Rep: Reputation: 15
Thank you for your reply but I'm already familiar with stream redirection.

I want to know if the focused window in KDE (or in X for that matter), say my web browser currently used to respond to you, is available by some command that would put its name into a file. Of course, it would be a background job (by cron for instance) because if I actually used the command line, I'd always have "xterm" or "konsole" on the ouput. ;-)

(Using Firefox)
% some_script_running_by_cron > my_file.
% cat my_file
Firefox.

A list of the windows stack would be interesting.

I found a more generic command that helped me:
% ps -A | cut -c25- | sort | uniq

But I need to clean up the final list by removing non-X processes. And it doesn't tell me which is the current one (i.e. top-level) used in X.

Cheers.
 
Old 08-30-2008, 06:44 AM   #4
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
Maybe dcop can do what you want?
http://www.linuxformat.co.uk/wiki/in...9.tut_dcop.pdf
 
Old 08-30-2008, 08:38 AM   #5
narc
Member
 
Registered: Aug 2004
Location: Montréal
Distribution: Linux from scratch
Posts: 68

Original Poster
Rep: Reputation: 15
I suspected that KDE had the power to do that through DCOP.

Don't know how to control it to get what I want but I'll try.

Cool tutorial, BTW. Thanks.
 
Old 08-30-2008, 08:55 AM   #6
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,846

Rep: Reputation: 128Reputation: 128
Perhaps this is of some use? http://www.oreillynet.com/linux/blog...y_time_go.html

The C code in its current form outputs the name of the window which has focus to standard output once a second. For example, I just ran it for a little while, and got this output:
Code:
pwc101@example:~> watch_focus
Focus in window 'Yakuake'
Focus in window 'Yakuake'
Focus in window 'Yakuake'
Focus in window 'Getting the name of the top-level or focused window in KDE - LinuxQuestions.org - Mozilla Firefox'
Focus in window 'Getting the name of the top-level or focused window in KDE - LinuxQuestions.org - Mozilla Firefox'
Focus in window 'Getting the name of the top-level or focused window in KDE - LinuxQuestions.org - Mozilla Firefox'
Focus in window 'Yakuake'
Focus in window 'Yakuake'
Focus in window 'Yakuake'
Focus in window 'Yakuake'
Focus in window 'Getting the name of the top-level or focused window in KDE - LinuxQuestions.org - Mozilla Firefox'
Focus in window 'Getting the name of the top-level or focused window in KDE - LinuxQuestions.org - Mozilla Firefox'
Focus in window 'Getting the name of the top-level or focused window in KDE - LinuxQuestions.org - Mozilla Firefox'
Focus in window 'Yakuake'
Focus in window 'Yakuake'
Focus in window 'Yakuake'
pwc101@example:~>
 
Old 08-30-2008, 09:17 AM   #7
narc
Member
 
Registered: Aug 2004
Location: Montréal
Distribution: Linux from scratch
Posts: 68

Original Poster
Rep: Reputation: 15
Impressive. Right on the button. The author also gives an *actual legitimate use for it* ;-)

Cheers.
 
  


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
How to create a top level makefile rushadrenaline Mandriva 3 12-10-2007 10:16 PM
LXer: ‘it’s Linux’s Time’: So Says IBM’s Top Executive Focused ... LXer Syndicated Linux News 0 11-27-2006 09:54 PM
Top Level Domain Names wwnexc Linux - Networking 3 03-12-2006 02:03 PM
"The KDE Window Manager" box keeps poping up at the top left... HELP HOLLYW00D Suse/Novell 2 04-23-2005 11:26 AM
FTP - setting top level dir donokono Linux - Networking 2 06-18-2002 06:17 PM


All times are GMT -5. The time now is 09:45 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration