-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivitylog
More file actions
executable file
·53 lines (43 loc) · 2.44 KB
/
activitylog
File metadata and controls
executable file
·53 lines (43 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#Probably running from crontab.
#Skip the whole "figure out the proper runtime environment" crap! This is so stupid to have to set two dozen variables to connect to crap.
# Instead, just find the currently running screensaver, and pirate it's evironment settings! Cheap, quick, easy, future-proof, and stupid.
# I can't believe I'm doing this.o
#First, find the userID and PID of the gnome-screensaver process
#If there's more than one, abort w/ error
if [ `ps axu | grep 'gnome-screensaver$' | wc -l` -gt 1 ]; then
#TODO: figure out which virtual terminal is active, and which screensaver process is running for that
#X instance. To much work for now.
logger -t activitylog -p local4.info "ERROR: More than one screensaver?"
exit
fi
XUSER=`ps axu | grep 'gnome-screensaver$' | sed 's/ \+/\t/g'| cut -f 1`
PID=`ps axu | grep 'gnome-screensaver$' | sed 's/ \+/\t/g'| cut -f 2`
#Second, read in the processes environment. Don't use "LS_COLORS" b/c it causes parse errors later.
#we need the "export" b/c the gnome-screensaver-command etc needs these vars.
SetEnvironment=`cat /proc/$PID/environ | tr '\0' '\n' | grep -v COLORS | sed 's/^/export /'`
runprog='
#singlequote is FORBIDDEN in this area!
#Check status of screensaver - if it%s running, do nothing.
#gnome-screensaver-command -q
if gnome-screensaver-command -q | grep inactive > /dev/null; then
#If the screensaver isn%t running, log the title of the active window
ACTIVE=`xdotool getactivewindow`
TITLE=`xwininfo -id $ACTIVE | grep "xwininfo:" | cut -c 32-`
if echo "$TITLE" | grep "\"Minecraft\"" >/dev/null ; then
#If minecraft is being played via my launch script (which displays the usename in the titlebar of the shell)
#Log that instead of the active window%s title
MINE=`xdotool search --title "minecraft being played by\:"`
if [ -n "$MINE" ]; then
#If we can figure out which user, log that windows% title.
TITLE=`xwininfo -id $MINE | grep "xwininfo:" | cut -c 32-`
fi
fi
logger -t activitylog -p local4.info -- "$TITLE"
fi
'
#This command lists the tabs that have been opened in the current firefox session.
#grep -Eo '"entries":\[{"url":"[^"]*"' /home/jgilmore/.mozilla/firefox/*.default/sessionstore.js | sed 's/^.*:"//; s/"$//'
#Saved here for possible future reference
#Actually execute the program in a custom environment where we
sudo -u $XUSER sh -c "$SetEnvironment;$runprog"