Visit Our UNIX and Linux User Community

How can I push an X app to the front by PID?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can I push an X app to the front by PID?
# 1  
Old 01-25-2009
How can I push an X app to the front by PID?

I'm trying to write a script that will start an X application if it's not already running, but will find it and pop it to the front if it is already running (maybe it's lost on a busy desktop).

Is there such a mechanism?

Here is part of the logic:
VRDP="$(ps ax|grep "rdesktop .* $SERVER[:]$PORT")"
if [ -z "$VRDP" ]; then
    rdesktop $SERVER:$PORT &
    PID="$(echo $VRDP | sed 's/ *\([0-9]*\) .*/\1/')"
    # Pop $PID to the front here

# 2  
Old 01-28-2009
The X primitive you want, I believe, is "raise". Window managers (KDE, Gnome, Xface, etc) might have some customizable interface so that you can ask window with a certain title to be raise()d.

I found one command that might give you what you need... it's called wmctrl, and according to the man page you can do:
wmctrl -a rdesktop

# 3  
Old 03-05-2009
BTW, thank you otheus. That does just what I wanted.

I now have a shell script that starts my selected VirtualBox virtual machine if it's not running, opens an RDP window to it if it's not open, and takes me to it if it's already running and open.
# 4  
Old 03-05-2009
Hey -- anytime.... though did it really take all of February to get this done?? Smilie

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Programming

Wuhan Coronavirus Status App for China - Rapid Prototype using MQTT and the IoT OnOff IOS App

With a little bit of work, was able to build a nice "Wuhan Coronavirus Status" app using MQTT and the IoT-OnOff app. More on this technique here: ESP32 (ESP-WROOM-32) as an MQTT Client Subscribed to Linux Server Load Average Messages The result turned out nice, I think. I like the look and... (10 Replies)
Discussion started by: Neo
10 Replies

2. Shell Programming and Scripting

Script to Push Files

Hey Guys, Thanks for always being helpful, I have another issue that I need a little insight on how to fix. See the below script I have and the error I get. I don't understand why it does that, am I not using the continue correctly? #!/bin/bash -x # @(#) File: #... (5 Replies)
Discussion started by: gkelly1117
5 Replies

3. UNIX for Dummies Questions & Answers

Rsync push or pull?

We have a cluster of 3 web servers. I'll be updating a single master server and copying info to the other 2 slave servers. What's the best way of synching all of them? Run rsync on each of the slave servers to pull the updates from the master? Or run rsync on the master to push the updates to the... (1 Reply)
Discussion started by: gaspol
1 Replies

4. Linux

FTP push

Hi I am trying to send a file form one linux server into an another linux server. I cannot do ftp get. Can anyone please assist me how can I push the file to the other server ? Thanks. (2 Replies)
Discussion started by: sureshcisco
2 Replies

5. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

6. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

7. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies

Featured Tech Videos