GiacomoLaw / Keylogger

A simple keylogger for Windows, Linux and Mac
https://simple-keylogger.github.io/
MIT License
2.09k stars 616 forks source link

Python3 compatibility, Pep8 formatting, Environment variable options. #20

Closed cjwelborn closed 7 years ago

cjwelborn commented 7 years ago

This PR allows the linux version of KeyLogger to run on Python 2 or 3. The code was reformatted in Pep8 style to help with readability. Three environment variables are checked so options can be set:

Example usage of environment variables:

# Tells the keylogger to clear the log file, by simply setting pylogger_clean to anything.
# Tells the keylogger to use ! as the cancel key, by setting pylogger_cancel to "!"
# Tells the keylogger to use /home/cj/myfile.txt as the log file by setting pylogger_file.
pylogger_clean=1 pylogger_cancel='!' pylogger_file="/home/cj/myfile.txt" python3 ./keylogger.py

If keylogger.py is made executable (chmod +x keylogger.py), you can drop the python3 part:

pylogger_file="/home/cj/myfile.txt" ./keylogger.py

By prepending the environment variables to the command, it sets the variable for that command's subshell only. They can be set permanently by putting them in .bashrc.

These options could just as well be implemented using command-line options, but I thought the argument parsing might add too much code (even though docopt only takes one line after you define the usage string).

cjwelborn commented 7 years ago

The owner of pyxhook accepted my changes for pyxhook.py, so if you don't like the keylogger.py changes you could just update from there.

GiacomoLaw commented 7 years ago

Also, please squash your commits into one. 😉

Thanks!

cjwelborn commented 7 years ago

@GiacomoLaw, readme updated, commits squashed. :smile: