Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6724089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:38:49+00:00 2026-05-26T09:38:49+00:00

Apologies in advance if this has already been asked – it’s really hard to

  • 0

Apologies in advance if this has already been asked – it’s really hard to search for this as bash and terminal show up together in so many places.

Basically what I’d like to be able to do is have a bash script be aware of whether or not the terminal it’s running in is currently active (selected) so that I could use notify-send to inform the user something has completed only if it’s not currently the active window. I’m guessing it would be possible to do something that can at least detect whether the active window is a terminal window by accessing gnome somehow, but I have no idea how and I imagine it would likely be a hack, but any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:38:49+00:00Added an answer on May 26, 2026 at 9:38 am

    After some more digging I’ve found a workable solution so I’m going to post it as an answer, but it’s not very portable so I’d still appreciate any better solutions.

    What I’ve found is that when using Gnome you have access to a $WINDOWID variable from the gnome-terminal (this doesn’t work if you’ve ssh’ed to another box unfortunately and so isn’t ideal). This can be combined with xprop like this:

    activeWindow=$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')
    thisWindow=$(printf '0x%x\n' $WINDOWID)
    

    Which can then be compared for equality. A more suitable way of getting the current window id would be good however.

    Edit: Having seen Zaytzev’s answer I guess this could be combined so instead of using $WINDOWID I could set the terminal title and check whether xprop -id $activeWindow WM_NAME is equal to my window title.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this has already been asked and answered so I apologize in advance
Apologies if this has already been asked and solved but through numerous searches and
OK, Apologies if this has already been asked and/or Answered but I'm struggling to
First off, let me apologize if this has been asked already, but I can’t
I apologize if this has already been asked a different way but I couldn't
If this question has already been asked I appologies, please point me in the
First off, apologies if this question has been asked before but I couldn't find
I apologize in advance if folks think this has been beaten to death. I've
It feels like this question has been asked before, but no questions seem to
A highly similar question has been asked already, and it has partly solved my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.