Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main

main
Bob Mottram 2021-03-13 15:24:07 +00:00
commit 5546a70c38
3 changed files with 185 additions and 39 deletions

View File

@ -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] 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!): To remove an account (be careful!):
``` bash ``` 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. On Debian based systems you will need to have the **python3-espeak** package installed.
``` bash ``` 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: Or if you have [picospeaker](https://gitlab.com/ky1e/picospeaker) installed:
``` bash ``` 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 ## 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: 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 ``` 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: The notifications client also provides a number of basic commands, which may be more convenient than the web interface for some purposes:
``` bash ``` bash

View File

@ -1001,8 +1001,11 @@ if args.message:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
session = createSession(proxyType) session = createSession(proxyType)
if not args.sendto: if not args.sendto:
@ -1073,8 +1076,11 @@ if args.announce:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
session = createSession(proxyType) session = createSession(proxyType)
personCache = {} personCache = {}
@ -1093,8 +1099,11 @@ if args.announce:
if args.itemName: if args.itemName:
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if not args.nickname: if not args.nickname:
print('Specify a nickname with the --nickname option') print('Specify a nickname with the --nickname option')
@ -1149,8 +1158,11 @@ if args.itemName:
if args.undoItemName: if args.undoItemName:
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if not args.nickname: if not args.nickname:
print('Specify a nickname with the --nickname option') print('Specify a nickname with the --nickname option')
@ -1179,8 +1191,11 @@ if args.like:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
session = createSession(proxyType) session = createSession(proxyType)
personCache = {} personCache = {}
@ -1204,8 +1219,11 @@ if args.undolike:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
session = createSession(proxyType) session = createSession(proxyType)
personCache = {} personCache = {}
@ -1229,8 +1247,11 @@ if args.delete:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
session = createSession(proxyType) session = createSession(proxyType)
personCache = {} personCache = {}
@ -1257,9 +1278,11 @@ if args.follow:
print('Please specify the nickname for the account with --nickname') print('Please specify the nickname for the account with --nickname')
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Please specify the password for ' + args.nickname + args.password = getpass.getpass('Password: ')
' on ' + domain) if not args.password:
sys.exit() print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
followNickname = getNicknameFromActor(args.follow) followNickname = getNicknameFromActor(args.follow)
if not followNickname: if not followNickname:
@ -1296,8 +1319,11 @@ if args.unfollow:
print('Please specify the nickname for the account with --nickname') print('Please specify the nickname for the account with --nickname')
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Please specify the password for '+args.nickname+' on '+domain) args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
followNickname = getNicknameFromActor(args.unfollow) followNickname = getNicknameFromActor(args.unfollow)
if not followNickname: if not followNickname:
@ -1515,9 +1541,13 @@ if args.addaccount:
if not validNickname(domain, nickname): if not validNickname(domain, nickname):
print(nickname + ' is a reserved name. Use something different.') print(nickname + ' is a reserved name. Use something different.')
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Use the --password option to set the password for ' + nickname) args.password = getpass.getpass('Password: ')
sys.exit() 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: if len(args.password.strip()) < 8:
print('Password should be at least 8 characters') print('Password should be at least 8 characters')
sys.exit() sys.exit()
@ -1552,8 +1582,11 @@ if args.addgroup:
print(nickname + ' is a reserved name. Use something different.') print(nickname + ' is a reserved name. Use something different.')
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Use the --password option to set the password for ' + nickname) args.password = getpass.getpass('Password: ')
sys.exit() 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: if len(args.password.strip()) < 8:
print('Password should be at least 8 characters') print('Password should be at least 8 characters')
sys.exit() sys.exit()
@ -1723,8 +1756,11 @@ if args.skill:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if not args.skillLevelPercent: if not args.skillLevelPercent:
print('Specify a skill level in the range 0-100') print('Specify a skill level in the range 0-100')
@ -1759,8 +1795,11 @@ if args.availability:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
session = createSession(proxyType) session = createSession(proxyType)
personCache = {} personCache = {}
@ -1830,8 +1869,11 @@ if args.block:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if '@' in args.block: if '@' in args.block:
blockedDomain = args.block.split('@')[1] blockedDomain = args.block.split('@')[1]
@ -1866,8 +1908,11 @@ if args.delegate:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if not args.project: if not args.project:
print('Specify a project with the --project option') print('Specify a project with the --project option')
@ -1905,8 +1950,11 @@ if args.undelegate:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if not args.project: if not args.project:
print('Specify a project with the --project option') print('Specify a project with the --project option')
@ -1940,8 +1988,11 @@ if args.unblock:
sys.exit() sys.exit()
if not args.password: if not args.password:
print('Specify a password with the --password option') args.password = getpass.getpass('Password: ')
sys.exit() if not args.password:
print('Specify a password with the --password option')
sys.exit()
args.password = args.password.replace('\n', '')
if '@' in args.unblock: if '@' in args.unblock:
blockedDomain = args.unblock.split('@')[1] blockedDomain = args.unblock.split('@')[1]

View File

@ -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"