{"id":13399048,"url":"https://github.com/selfspy/selfspy","last_synced_at":"2025-03-14T03:31:04.864Z","repository":{"id":2714465,"uuid":"3708934","full_name":"selfspy/selfspy","owner":"selfspy","description":"Log everything you do on the computer, for statistics, future reference and all-around fun!","archived":false,"fork":false,"pushed_at":"2019-03-06T13:30:04.000Z","size":302,"stargazers_count":2402,"open_issues_count":72,"forks_count":231,"subscribers_count":102,"default_branch":"master","last_synced_at":"2024-08-20T13:02:14.815Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/selfspy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-13T16:56:20.000Z","updated_at":"2024-08-13T04:09:05.000Z","dependencies_parsed_at":"2022-09-08T20:20:12.956Z","dependency_job_id":null,"html_url":"https://github.com/selfspy/selfspy","commit_stats":null,"previous_names":["gurgeh/selfspy"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfspy%2Fselfspy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfspy%2Fselfspy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfspy%2Fselfspy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfspy%2Fselfspy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selfspy","download_url":"https://codeload.github.com/selfspy/selfspy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243520539,"owners_count":20304162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T19:00:33.723Z","updated_at":"2025-03-14T03:31:02.202Z","avatar_url":"https://github.com/selfspy.png","language":"Python","funding_links":[],"categories":["Python","Open-Source","Time Tracking","Install from Source"],"sub_categories":["Packages","Troubleshooting"],"readme":"### What is this?\nSelfspy is a daemon for Unix/X11, (thanks to @ljos!) Mac OS X and (thanks to @Foxboron) Windows, that continuously monitors and stores what you are doing on your computer. This way, you can get all sorts of nifty statistics and reminders on what you have been up to. It is inspired by the [Quantified Self](http://en.wikipedia.org/wiki/Quantified_Self)-movement and [Stephen Wolfram's personal key logging](http://blog.stephenwolfram.com/2012/03/the-personal-analytics-of-my-life/).\n\nSee Example Statistics, below, for some of the fabulous things you can do with this data.\n\n### Windows\n\nDue to Windows libs needing a external compiler to compile libs, some libs won't compile on all computers.   \nThese are the sinners*:   \n`pyHook==1.5.1`   \n`pyCrypto==2.5 `   \nThey are added too the windows-requirements.txt, but IF you fail to build these libs, here are the precompiled binaries. pyWin32 is needed for some library dependency, pip can't install pyWin32, so please use the binary below.      \npyHook: http://sourceforge.net/projects/pyhook/files/pyhook/   \npyCrytpo: http://www.voidspace.org.uk/python/modules.shtml#pycrypto   \npyWin32: http://sourceforge.net/projects/pywin32/files/pywin32/  \n  \n*SQLAlchemy does compile without the external compiler, but it uses a clean Python version which might slow things down.  \n   \n### Installing Selfspy\n\nIf you run ArchLinux, here is an AUR package which may be up-to-date:\nhttps://aur.archlinux.org/packages/selfspy-git/\n\nTo install manually, either clone the repository from Github (git clone git://github.com/gurgeh/selfspy), or click on the Download link on http://github.com/gurgeh/selfspy/ to get the latest Python source.\n\nSelfspy is only tested with Python 2.7 and has a few dependencies on other Python libraries that need to be satisfied. These are documented in the requirements.txt file. If you are on Linux, you will need subversion installed for pip to install python-xlib. If you are on Mac, you will not need to install python-xlib at all. Python-xlib is currently a tricky package to include in the requirements since it is not on PyPi.\n```\npip install svn+https://python-xlib.svn.sourceforge.net/svnroot/python-xlib/tags/xlib_0_15rc1/ # Only do this step on Linux!\npython setup.py install\n```\n\nYou will also need the ``Tkinter`` python libraries. On ubuntu and debian\n\n```\nsudo apt-get install python-tk\n```\n\nOn FreeBSD\n\n```\ncd /usr/ports/x11-toolkits/py-tkinter/\nsudo make config-recursive \u0026\u0026 sudo make install clean\n```\n\n\nThere is also a simple Makefile. Run `make install` as root/sudo, to install the files in /var/lib/selfspy and also create the symlinks /usr/bin/selfspy and /usr/bin/selfstats.\n\nReport issues here:\nhttps://github.com/gurgeh/selfspy/issues\n\nGeneral discussion here:\nhttp://ost.io/gurgeh/selfspy\n\n#### OS X\nIn OS X you also need to enable access for assistive devices.\nTo do that in \u0026lt;10.9 there is a checkbox in `System Preferences \u003e Accessibility`,\nin 10.9 you have to add the correct application in\n`System Preferences \u003e Privacy \u003e Accessibility`.\n\n### Running Selfspy\nYou run selfspy with `selfspy`. You should probably start with `selfspy --help` to get to know the command line arguments. As of this writing, it should look like this:\n\n```\nusage: selfspy [-h] [-c FILE] [-p PASSWORD] [-d DATA_DIR] [-n]\n               [--change-password]\n\nMonitor your computer activities and store them in an encrypted database for\nlater analysis or disaster recovery.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -c FILE, --config FILE\n                        Config file with defaults. Command line parameters\n                        will override those given in the config file. The\n                        config file must start with a \"[Defaults]\" section,\n                        followed by [argument]=[value] on each line.\n  -p PASSWORD, --password PASSWORD\n                        Encryption password. If you want to keep your database\n                        unencrypted, specify -p \"\" here. If you don't specify\n                        a password in the command line arguments or in a\n                        config file, a dialog will pop up, asking for the\n                        password. The most secure is to not use either command\n                        line or config file but instead type it in on startup.\n  -d DATA_DIR, --data-dir DATA_DIR\n                        Data directory for selfspy, where the database is\n                        stored. Remember that Selfspy must have read/write\n                        access. Default is ~/.selfspy\n  -n, --no-text         Do not store what you type. This will make your\n                        database smaller and less sensitive to security\n                        breaches. Process name, window titles, window\n                        geometry, mouse clicks, number of keys pressed and key\n                        timings will still be stored, but not the actual\n                        letters. Key timings are stored to enable activity\n                        calculation in selfstats. If this switch is used,\n                        you will never be asked for password.\n  -r, --no-repeat       Do not store special characters as repeated\n                        characters.\n  --change-password     Change the password used to encrypt the keys columns\n                        and exit.\n```\n\nEverything you do is stored in a Sqlite database in your DATA_DIR. Things that you type (passwords, for example) are generally too sensitive to leave in plain text, so they are encrypted with the supplied password. Other database columns, like process names and window titles, are not encrypted. This makes it faster and easier to search for them later.\n\nUnless you use the --no-text flag, selfspy will store everything you type in two \u003ca href=\"http://en.wikipedia.org/wiki/Blowfish_(cipher)\"\u003eBlowfish\u003c/a\u003e encrypted columns in the database.\n\nNormally you would like Selfspy to start automatically when you launch X. How to do this depends on your system, but it will normally mean editing *~/.xinitrc* or *~/.xsession*. If you run KDE, *~/.kde/Autostart*, is a good place to put startup scripts. When run, Selfspy will immediately spawn a daemon and exit.\n\n#### Running on login in OS X\nIf you want selfspy to start automatically on login you need to copy the [com.github.gurgeh.selfspy.plist](https://raw.githubusercontent.com/gurgeh/selfspy/master/com.github.gurgeh.selfspy.plist)\nfile to `~/Library/LaunchAgents/`.\n\n### Example Statistics\n*\"OK, so now all this data will be stored, but what can I use it for?\"*\n\nWhile you can access the Sqlite tables directly or, if you like Python, import `models.py` from the Selfspy directory and use those SqlAlchemy classes, the standard way to query your data is through `selfstats`.\n\nHere are some standard use cases:\n\n*\"Damn! The browser just threw away everything I wrote, because I was not logged in.\"*\n\n`selfstats --back 30 m --showtext`\n\nShow me everything I have written the last 30 minutes. This will ask for my password, in order to decrypt the text.\n\n*\"Hmm.. what is my password for Hoolaboola.com?\"*\n\n`selfstats -T \"Hoolaboola\" -P Google-chrome --showtext`\n\nThis shows everything I have ever written in Chrome, where the window title contained something with \"Hoolaboola\". The regular expressions are case insensitive, so I actually did not need the caps. If I have written a lot on Hoolaboola, perhaps I can be more specific in the title query, to only get the login page.\n\n*\"I need to remember what I worked on a few days ago, for my time report.\"*\n\n`selfstats --date 10 --limit 1 d -P emacs --tkeys`\n\nWhat buffers did I have open in Emacs on the tenth of this month and one day forward? Sort by how many keystrokes I wrote in each. This only works if I have set Emacs to display the current buffer in the window title. In general, try to set your programs (editors, terminals, web apps, ...) to include information on what you are doing in the window title. This will make it easier to search for later. \n\nOn a related but opposite note: if you have the option, remove information like \"mails unread\" or \"unread count\" (for example in Gmail and Google Reader) from the window titles, to make it easier to group them in --tactive and --tkeys.\n\n*\"Also, when and how much have I used my computer this last week?\"*\n\n`selfstats -b 1 w --periods 180`\n\nThis will display my active time periods for the last week. A session is considered inactive when I have not clicked or used the keyboard in 180 seconds. Increase that number to get fewer and larger sessions listed.\n\n*\"How effective have I been this week?\"*\n\n`selfstats -b 1 w --ratios`\n\nThis will show ratios informing me about how much I have written per active second and how much I have clicked vs used the keyboard. For me, a lot of clicking means too much browsing or inefficient use of my tools. Track these ratios over time to get a sense of what is normal for you.\n\n*\"I remember that I wrote something to her about the IP address of our printer a few months ago. I can't quite remember if it was a chat, a tweet, a mail, a facebook post, or what.. Should I search them separately? No.\"*\n\n`selfstats --body printer -s --back 40 w`\n\nShow the texts where I have used the word printer in the last 10 weeks. If it turns out that the actual IP adress is not in the same text chunk as when you wrote \"printer\", you can note the row ID and use --id \n (or --date and --clock) and --limit to show what else you wrote around that time.\n\n*\"What programs do I use the most?\"*\n\n`selfstats --pactive`\n\nList all programs I have ever used in order of time active in them.\n\n*\"Which questions on the website Stack Overflow did I visit yesterday?\"*\n\n`./selfstats -T \"Stack Overflow\" -P Google-chrome --back 32 h --tactive`\n\nList all window titles that contained \"Stack Overflow\" the last 32 hours. Sort by time active. I add the sorting, not only because I want them sorted, but because otherwise the listing would show a row for each time I visited that title, instead of grouping them together.\n\n*\"How much have I browsed today?\"*\n\n`selfstats -P Google-chrome --clock 00:00 --tactive`\n\nThis will show all the different pages I visited in the Chrome browser, ordered by for how long I was active.\n\n*\"Who needs Qwerty? I am going to make an alternative super-programmer-keymap. I wonder what keys I use the most when I code C++?\"*\n\n`selfstats --key-freq -P Emacs -T cpp`\n\nThis will list all keys in order of how much I have pressed them in Emacs, while editing a file where the name contained \"cpp\".\n\n*\"While we are at it, which cpp files have I edited the most this month?\"*\n\n`selfstats -P Emacs -T cpp --tkeys --date 1`\n\nList all buffers in Emacs that contained \"cpp\", from the first this month and forward. Sort by how much I typed in them.\n\nSelfstats is a swiss army knife of self knowledge. Experiment with it when you have acquired a few days of data. Remember that if you know SQL or SqlAlchemy, it is easy to construct your own queries against the database to get exactly the information you want, make pretty graphs, etc. There are a few stored properties, like coordinates of a mouse click and window geometry, that you can currently only reach through the database.\n\n### Selfstats Reference\n\nThe --help is a beast that right now looks something like this:\n\n```\nusage: selfstats [-h] [-c FILE] [-p PASSWORD] [-d DATA_DIR] [-s]\n                    [-D DATE [DATE ...]] [-C CLOCK] [-i ID]\n                    [-b BACK [BACK ...]] [-l LIMIT [LIMIT ...]] [-m nr]\n                    [-T regexp] [-P regexp] [-B regexp] [--ratios] [--clicks]\n                    [--key-freqs] [--human-readable] [--active [seconds]] [--periods [seconds]]\n                    [--pactive [seconds]] [--tactive [seconds]] [--pkeys]\n                    [--tkeys]\n\nCalculate statistics on selfspy data. Per default it will show non-text\ninformation that matches the filter. Adding '-s' means also show text. Adding\nany of the summary options will show those summaries over the given filter\ninstead of the listing. Multiple summary options can be given to print several\nsummaries over the same filter. If you give arguments that need to access text\n/ keystrokes, you will be asked for the decryption password.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -c FILE, --config FILE\n                        Config file with defaults. Command line parameters\n                        will override those given in the config file. Options\n                        to selfspy goes in the \"[Defaults]\" section, followed\n                        by [argument]=[value] on each line. Options specific\n                        to selfstats should be in the \"[Selfstats]\" section,\n                        though \"password\" and \"data-dir\" are still read from\n                        \"[Defaults]\".\n  -p PASSWORD, --password PASSWORD\n                        Decryption password. Only needed if selfstats needs to\n                        access text / keystrokes data. If your database in not\n                        encrypted, specify -p=\"\" here. If you don't specify a\n                        password in the command line arguments or in a config\n                        file, and the statistics you ask for require a\n                        password, a dialog will pop up asking for the\n                        password. If you give your password on the command\n                        line, remember that it will most likely be stored in\n                        plain text in your shell history.\n  -d DATA_DIR, --data-dir DATA_DIR\n                        Data directory for selfspy, where the database is\n                        stored. Remember that Selfspy must have read/write\n                        access. Default is ~/.selfspy\n  -s, --showtext        Also show the text column. This switch is ignored if\n                        at least one of the summary options are used. Requires\n                        password.\n  -D DATE [DATE ...], --date DATE [DATE ...]\n                        Which date to start the listing or summarizing from.\n                        If only one argument is given (--date 13) it is\n                        interpreted as the closest date in the past on that\n                        day. If two arguments are given (--date 03 13) it is\n                        interpreted as the closest date in the past on that\n                        month and that day, in that order. If three arguments\n                        are given (--date 2012 03 13) it is interpreted as\n                        YYYY MM DD\n  -C CLOCK, --clock CLOCK\n                        Time to start the listing or summarizing from. Given\n                        in 24 hour format as --clock 13:25. If no --date is\n                        given, interpret the time as today if that results in\n                        sometimes in the past, otherwise as yesterday.\n  -i ID, --id ID        Which row ID to start the listing or summarizing from.\n                        If --date and/or --clock is given, this option is\n                        ignored.\n  -b BACK [BACK ...], --back BACK [BACK ...]\n                        --back \u003cperiod\u003e [\u003cunit\u003e] Start the listing or summary\n                        this much back in time. Use this as an alternative to\n                        --date, --clock and --id. If any of those are given,\n                        this option is ignored. \u003cunit\u003e is either \"s\"\n                        (seconds), \"m\" (minutes), \"h\" (hours), \"d\" (days) or\n                        \"w\" (weeks). If no unit is given, it is assumed to be\n                        hours.\n  -l LIMIT [LIMIT ...], --limit LIMIT [LIMIT ...]\n                        --limit \u003cperiod\u003e [\u003cunit\u003e]. If the start is given in\n                        --date/--clock, the limit is a time period given by\n                        \u003cunit\u003e. \u003cunit\u003e is either \"s\" (seconds), \"m\" (minutes),\n                        \"h\" (hours), \"d\" (days) or \"w\" (weeks). If no unit is\n                        given, it is assumed to be hours. If the start is\n                        given with --id, limit has no unit and means that the\n                        maximum row ID is --id + --limit.\n  -m nr, --min-keys nr  Only allow entries with at least \u003cnr\u003e keystrokes\n  -T regexp, --title regexp\n                        Only allow entries where a search for this \u003cregexp\u003e in\n                        the window title matches something. All regular expressions\n                        are case insensitive.\n  -P regexp, --process regexp\n                        Only allow entries where a search for this \u003cregexp\u003e in\n                        the process matches something.\n  -B regexp, --body regexp\n                        Only allow entries where a search for this \u003cregexp\u003e in\n                        the body matches something. Do not use this filter\n                        when summarizing ratios or activity, as it has no\n                        effect on mouse clicks. Requires password.\n  --clicks              Summarize number of mouse button clicks for all\n                        buttons.\n  --key-freqs           Summarize a table of absolute and relative number of\n                        keystrokes for each used key during the time period.\n                        Requires password.\n  --human-readable      This modifies the --body entry and honors backspace.\n  --active [seconds]    Summarize total time spent active during the period.\n                        The optional argument gives how many seconds after\n                        each mouse click (including scroll up or down) or\n                        keystroke that you are considered active. Default is\n                        180.\n  --ratios [seconds]    Summarize the ratio between different metrics in the\n                        given period. \"Clicks\" will not include up or down\n                        scrolling. The optional argument is the \"seconds\"\n                        cutoff for calculating active use, like --active.\n  --periods [seconds]   List active time periods. Optional argument works same\n                        as for --active.\n  --pactive [seconds]   List processes, sorted by time spent active in them.\n                        Optional argument works same as for --active.\n  --tactive [seconds]   List window titles, sorted by time spent active in\n                        them. Optional argument works same as for --active.\n  --pkeys               List processes sorted by number of keystrokes.\n  --tkeys               List window titles sorted by number of keystrokes.\n\nSee the README file or http://gurgeh.github.com/selfspy for examples.\n```\n\n### Email\nTo monitor that Selfspy works as it should and to continuously get feedback on yourself, it is good to  regularly mail yourself some statistics. I think the easiest way to automate this is using [sendEmail](http://www.debianadmin.com/how-to-sendemail-from-the-command-line-using-a-gmail-account-and-others.html), which can do neat stuff like send through your Gmail account.\n\nFor example, put something like this in your weekly [cron](http://clickmojo.com/code/cron-tutorial.html) jobs:\n`/(PATH_TO_FILE)/selfstats --back 1 w --ratios 900 --periods 900 | /usr/bin/sendEmail -q -u \"Weekly selfstats\" \u003cetc..\u003e`\nThis will give you some interesting feedback on how much and when you have been active this last week and how much you have written vs moused, etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfspy%2Fselfspy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselfspy%2Fselfspy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfspy%2Fselfspy/lists"}