diff --git a/README_commandline.md b/README_commandline.md index a7d3a6c1b..94e848f00 100644 --- a/README_commandline.md +++ b/README_commandline.md @@ -10,6 +10,8 @@ The first thing you will need to do is to create an account. You can do this wit python3 epicyon.py --addaccount nickname@domain --password [yourpassword] ``` +You can also leave out the **--password** option and then enter it manually, which has the advantage of passwords not being logged within command history. + To remove an account (be careful!): ``` bash @@ -398,25 +400,27 @@ It is possible to use text-to-speech to read your inbox as posts arrive. This ca On Debian based systems you will need to have the **python3-espeak** package installed. ``` bash -python3 epicyon.py --speaker yournickname@yourdomain --password [yourpassword] +python3 epicyon.py --speaker yournickname@yourdomain ``` Or if you have [picospeaker](https://gitlab.com/ky1e/picospeaker) installed: ``` bash -python3 epicyon.py --screenreader picospeaker --notify yournickname@yourdomain --password [yourpassword] +python3 epicyon.py --screenreader picospeaker --notify yournickname@yourdomain ``` -This will then stay running and incoming posts will be announced as they arrive. +You can also use the **--password** option to provide the password. This will then stay running and incoming posts will be announced as they arrive. ## Desktop notifications You can get desktop notifications either by running the screen reader as shown above, or if you only want notifications and not spoken messages then you can run the client as follows, without the *screenreader* option: ``` bash -python3 epicyon.py --notify yournickname@yourdomain --password [yourpassword] +python3 epicyon.py --notify yournickname@yourdomain ``` +You can also use the **--password** option if needed. + The notifications client also provides a number of basic commands, which may be more convenient than the web interface for some purposes: ``` bash diff --git a/epicyon.py b/epicyon.py index be2f854f6..cde1c49e8 100644 --- a/epicyon.py +++ b/epicyon.py @@ -1001,8 +1001,11 @@ if args.message: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') session = createSession(proxyType) if not args.sendto: @@ -1073,8 +1076,11 @@ if args.announce: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') session = createSession(proxyType) personCache = {} @@ -1093,8 +1099,11 @@ if args.announce: if args.itemName: if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if not args.nickname: print('Specify a nickname with the --nickname option') @@ -1149,8 +1158,11 @@ if args.itemName: if args.undoItemName: if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if not args.nickname: print('Specify a nickname with the --nickname option') @@ -1179,8 +1191,11 @@ if args.like: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') session = createSession(proxyType) personCache = {} @@ -1204,8 +1219,11 @@ if args.undolike: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') session = createSession(proxyType) personCache = {} @@ -1229,8 +1247,11 @@ if args.delete: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') session = createSession(proxyType) personCache = {} @@ -1257,9 +1278,11 @@ if args.follow: print('Please specify the nickname for the account with --nickname') sys.exit() if not args.password: - print('Please specify the password for ' + args.nickname + - ' on ' + domain) - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') followNickname = getNicknameFromActor(args.follow) if not followNickname: @@ -1296,8 +1319,11 @@ if args.unfollow: print('Please specify the nickname for the account with --nickname') sys.exit() if not args.password: - print('Please specify the password for '+args.nickname+' on '+domain) - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') followNickname = getNicknameFromActor(args.unfollow) if not followNickname: @@ -1515,9 +1541,13 @@ if args.addaccount: if not validNickname(domain, nickname): print(nickname + ' is a reserved name. Use something different.') sys.exit() + if not args.password: - print('Use the --password option to set the password for ' + nickname) - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if len(args.password.strip()) < 8: print('Password should be at least 8 characters') sys.exit() @@ -1552,8 +1582,11 @@ if args.addgroup: print(nickname + ' is a reserved name. Use something different.') sys.exit() if not args.password: - print('Use the --password option to set the password for ' + nickname) - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if len(args.password.strip()) < 8: print('Password should be at least 8 characters') sys.exit() @@ -1723,8 +1756,11 @@ if args.skill: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if not args.skillLevelPercent: print('Specify a skill level in the range 0-100') @@ -1759,8 +1795,11 @@ if args.availability: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') session = createSession(proxyType) personCache = {} @@ -1830,8 +1869,11 @@ if args.block: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if '@' in args.block: blockedDomain = args.block.split('@')[1] @@ -1866,8 +1908,11 @@ if args.delegate: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if not args.project: print('Specify a project with the --project option') @@ -1905,8 +1950,11 @@ if args.undelegate: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if not args.project: print('Specify a project with the --project option') @@ -1940,8 +1988,11 @@ if args.unblock: sys.exit() if not args.password: - print('Specify a password with the --password option') - sys.exit() + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') if '@' in args.unblock: blockedDomain = args.unblock.split('@')[1] diff --git a/install-desktop-notifications b/install-desktop-notifications new file mode 100755 index 000000000..460efdd1c --- /dev/null +++ b/install-desktop-notifications @@ -0,0 +1,91 @@ +#!/bin/bash + +currUser="$USER" + +if [ ! -d "${HOME}/.config/systemd/user" ]; then + mkdir -p "${HOME}/.config/systemd/user" +fi + +if [ ! -f /usr/bin/zenity ]; then + if [ -f /usr/bin/apt ]; then + sudo apt install zenity + fi + if [ -f /usr/bin/pacman ]; then + sudo pacman -S zenity + fi +fi + +HANDLE=$(zenity --entry --width=400 --title "Epicyon Desktop Notifications" --text "Fediverse handle (name@domain): ") +if [ ! "$HANDLE" ]; then + zenity --warning --width=400 --text "No fediverse handle was given" + exit 1 +fi +if [[ "$HANDLE" != *'@'* ]]; then + zenity --warning --width=400 --text "Fediverse handle must be in the form username@domain" + exit 2 +fi +PASSWORD=$(zenity --width=400 --password --title "Epicyon Desktop Notifications") +if [ ! "$PASSWORD" ]; then + zenity --warning --width=400 --text "No password was given" + exit 3 +fi + +if [ ! -f /usr/bin/git ]; then + if [ -f /usr/bin/apt ]; then + sudo apt install git + fi + if [ -f /usr/bin/pacman ]; then + sudo pacman -S git + fi +fi + +if [ ! -f /usr/bin/python3 ]; then + if [ -f /usr/bin/apt ]; then + sudo apt install python3 + fi + if [ -f /usr/bin/pacman ]; then + sudo pacman -S python + fi +fi + +if [ ! -d ${HOME}/.epicyon ]; then + git clone https://gitlab.com/bashrc2/epicyon ${HOME}/.epicyon +else + cd ${HOME}/.epicyon || exit 1 + git pull +fi +if [ ! -d ${HOME}/.epicyon ]; then + zenity --warning --width=400 --text "Unable to clone Epicyon repo" + exit 4 +fi +chown -R "${currUser}":"${currUser}" ${HOME}/.epicyon + +notificationType= +if [ -f /usr/bin/notify-send ]; then + notificationType='notify-send' +else + if [ -f /usr/bin/zenity ]; then + notificationType='zenity' + fi +fi +if [[ ! "$notificationType" ]]; then + zenity --warning --width=400 --text "No desktop notification command was found." + exit 5 +fi + +{ echo '[Unit]'; + echo 'Description=Epicyon Desktop Notifications'; + echo ''; + echo '[Service]'; + echo "WorkingDirectory=${HOME}/.epicyon"; + echo "ExecStart=/usr/bin/python3 epicyon.py --notifyType $notificationType --notify $HANDLE --password \"$PASSWORD\""; + echo 'Type=oneshot'; + echo 'RemainAfterExit=yes'; + echo ''; + echo '[Install]'; + echo 'WantedBy=multi-user.target'; } > "${HOME}/.config/systemd/user/epicyon-notifications.service" +systemctl --user enable epicyon-notifications.service +systemctl --user daemon-reload +systemctl --user restart epicyon-notifications.service & + +zenity --info --width=400 --text "Epicyon notifications are now enabled"