FG
💻 Software

How do I detect when a terminal gets focus in Linux?

Fresh7 days ago
Mar 15, 20262634 views
Confidence Score0%
0%

Problem

I want to be able to time how long I spend in front of a terminal. I'm thinking the best way will be to have some sort of timer that starts and stops when the terminal gains/loses focus. And it will have to work with multiple terminals... Any ideas? I'm using GNOME.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I detect when a terminal gets focus in Linux?

Low Risk

If your terminal shell has easy access to its own X window ID, you're probably doing something wrong! They have nothing to do with each other - e.g. you could (and should) be running long jobs inside which could in theory be outputting to any number…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment