Created
February 23, 2018 15:10
-
-
Save kwhitefoot/8381f8a74798ea3146e3539e8c46f8da to your computer and use it in GitHub Desktop.
Record active window titles to assist in writing time sheets. Should work on most Unix-like, X-windows systems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Kevin Whitefoot <[email protected]> | |
# 2018-02-23 | |
# | |
# Record the foreground window title every 30 seconds. | |
# Used to help write time sheets | |
# Output is lines of: | |
# ISO 8601 date space hh:mm:ss space hostname space title | |
# The purpose of the host name is so that we can merge files from | |
# several machines and just sort them to have a complete log in | |
# date-time order. | |
# See | |
# https://unix.stackexchange.com/questions/38867/is-it-possible-to-retrieve-the-active-window-process-title-in-gnome#122870, | |
# specifically the answer by | |
# https://unix.stackexchange.com/users/64271/eric edited by | |
# https://unix.stackexchange.com/users/33055/anthon. | |
# Dependencies: | |
# - date | |
# - xdotool | |
# - shell (bash is presumably overkill) | |
h="$(hostname)" | |
while [ 0 ] | |
do | |
d=$(date '+%F %T') | |
n=$(xdotool getactivewindow getwindowname) | |
if [ "$n" != "$p" ] | |
then | |
echo "$h $d $n" | |
p="$n" | |
fi | |
sleep 30s | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment