From 30520ee636799e05bb3eacc4b448d07c42f1d84c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Mar 2021 11:44:03 +0000 Subject: [PATCH 1/5] Update documentation for password option --- README_commandline.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README_commandline.md b/README_commandline.md index a7d3a6c1b..dbcaad945 100644 --- a/README_commandline.md +++ b/README_commandline.md @@ -398,25 +398,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 From 3b04ce6645ca3da5eb5934c160d9fde7a24890a0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Mar 2021 11:49:05 +0000 Subject: [PATCH 2/5] Allow manual password entry --- epicyon.py | 121 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 86 insertions(+), 35 deletions(-) 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] From 2e8f48021ba2cd323533183b22c6ceb57768bbfc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Mar 2021 11:53:41 +0000 Subject: [PATCH 3/5] Note about leaving out password option --- README_commandline.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README_commandline.md b/README_commandline.md index dbcaad945..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 From 1f6a0dd85c69649ec0d1cd176adec6103563d1b0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Mar 2021 15:15:32 +0000 Subject: [PATCH 4/5] Script for installing notification daemon --- install-desktop-notifications | 88 +++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 install-desktop-notifications diff --git a/install-desktop-notifications b/install-desktop-notifications new file mode 100755 index 000000000..d1666d2c3 --- /dev/null +++ b/install-desktop-notifications @@ -0,0 +1,88 @@ +#!/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 + exit 1 +fi +if [[ "$HANDLE" != *'@'* ]]; then + exit 2 +fi +PASSWORD=$(zenity --width=400 --password --title "Epicyon Desktop Notifications") +if [ ! "$PASSWORD" ]; then + 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 + echo '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 + echo 'No desktop notification command was found. Try installing zenity.' + 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" From 09c2dbddafe76c690f902feca5308cad7d6d692d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Mar 2021 15:19:54 +0000 Subject: [PATCH 5/5] Warning dialogs --- install-desktop-notifications | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install-desktop-notifications b/install-desktop-notifications index d1666d2c3..460efdd1c 100755 --- a/install-desktop-notifications +++ b/install-desktop-notifications @@ -17,13 +17,16 @@ 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 @@ -52,7 +55,7 @@ else git pull fi if [ ! -d ${HOME}/.epicyon ]; then - echo 'Unable to clone epicyon repo' + zenity --warning --width=400 --text "Unable to clone Epicyon repo" exit 4 fi chown -R "${currUser}":"${currUser}" ${HOME}/.epicyon @@ -66,7 +69,7 @@ else fi fi if [[ ! "$notificationType" ]]; then - echo 'No desktop notification command was found. Try installing zenity.' + zenity --warning --width=400 --text "No desktop notification command was found." exit 5 fi