1

I want to develop an script that it is able to detect when a window (by its name) is opened and, send an email (or any other action).

How must I proceed?

I've read about skx/Pkie but I am not sure it is what I need.

Any idea to do something like that?

Thank you.

2
  • Window by it's name . . . so it's by title . . . it's not for specific application like firefox . . . . For example firefox with title "Whatever" is present, ignore that. If firefox with title "DoStuff" is present, then do something. Correct ? Nov 27, 2015 at 0:59
  • Perform an action a single time, and then break, or perform an action every time a specific window appears? It makes quite a difference. Nov 27, 2015 at 5:58

1 Answer 1

0

From your description, you seem to require checking window titles, not necessarily program type. Here's a script that does that. It requires wmctrl so be sure to install it with sudo apt-get intall wmctrl

Adjust the TRIGGERTITLE and the commands after if statement as needed.

#!/bin/bash

TRIGGERTITLE="enter title to search for"

while [ 1 ];do
   wmctrl -lx | grep -q "$TRIGGERTITLE"
   if [  $? -eq 0 ]; then
       # put one or more commands of what you wanna do if the title is found
     exit 1  # make sure you exit the script once the window is found, because
             # it will keep on doing stuff, if sending email - it will keep spamming
             # emails
   fi
sleep 0.250 # delay, so that the script doesn't hoag CPU
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .