Skip to content

Instantly share code, notes, and snippets.

@bodqhrohro
Created April 22, 2023 07:32
Show Gist options
  • Save bodqhrohro/12eaaacbde88c32a7e1e4d4c6ed81da2 to your computer and use it in GitHub Desktop.
Save bodqhrohro/12eaaacbde88c32a7e1e4d4c6ed81da2 to your computer and use it in GitHub Desktop.
Simple anal probe
[Unit]
Description=Spies on me
[Service]
ExecStart=/data/progs/shell/analprobe.sh
#!/bin/bash
export DISPLAY=:0
wnd_focus=$(xdotool getwindowfocus)
wnd_title=$(xprop -id "$wnd_focus" WM_NAME)
wnd_class=$(xprop -id "$wnd_focus" WM_CLASS)
active_vt=$(fgconsole)
dpms_state=$(xset q |grep Monitor)
title_regex='(".*")'
class_regex='(".*"), (".*")'
dpms_regex='([^ ]+)$'
if [[ "$wnd_title" =~ $title_regex ]]; then
wnd_title=${BASH_REMATCH[1]}
else
wnd_title='""'
fi
if [[ "$wnd_class" =~ $class_regex ]]; then
wnd_class="${BASH_REMATCH[1]},${BASH_REMATCH[2]}"
else
wnd_class='"",""'
fi
if [[ "$dpms_state" =~ $dpms_regex ]]; then
dpms_state="${BASH_REMATCH[1]}"
else
dpms_state='On'
fi
echo $(date '+%d-%m-%Y,%H:%M:%S,')"$active_vt,$dpms_state,$wnd_class,$wnd_title" >> ~/.var/log/anallog
[Unit]
Description=Probe my anus every 5 seconds
Wants=dbus.service
[Timer]
OnBootSec=5
OnUnitActiveSec=5
AccuracySec=1
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment