It's alive! Well, sort of, added a -p flag to post, be warned, thar be spam in them thar outputs.

This commit is contained in:
stormdragon2976 2023-01-29 19:45:43 -05:00
parent 82ee21407d
commit 9578307c7a

View File

@ -62,7 +62,7 @@ get_oauth_token() {
# Post music with -M flag # Post music with -M flag
post_music() { post_music() {
curl -vS --oauth2-bearer "${oauth_token}" \ curl -sS --oauth2-bearer "${oauth_token}" \
-d "$(playerctl metadata -f 'album={{album}}')" \ -d "$(playerctl metadata -f 'album={{album}}')" \
-d "$(playerctl metadata -f 'artist={{artist}}')" \ -d "$(playerctl metadata -f 'artist={{artist}}')" \
-d "$(playerctl metadata -f 'title={{title}}')" \ -d "$(playerctl metadata -f 'title={{title}}')" \
@ -71,6 +71,16 @@ post_music() {
} }
# Post status with -p flag, command line.
post_status() {
curl -sS --oauth2-bearer "${oauth_token}" \
-d "content=${content_type:-text/markdown}" \
-d "status=${@}" \
"${instanceURL}/api/v1/statuses"
exit 0
}
# Variable initialization # Variable initialization
configPath="${XDG_CONFIG_HOME:-$HOME/.config}/ratatoskr" # Path for settings, usually ~/.config/ratatoskr configPath="${XDG_CONFIG_HOME:-$HOME/.config}/ratatoskr" # Path for settings, usually ~/.config/ratatoskr
configFile="default.conf" # The default config file, eventually will support multiple accounts. configFile="default.conf" # The default config file, eventually will support multiple accounts.
@ -87,6 +97,7 @@ declare -A command=(
[C]="Recreate default configuration file. Acquire new oauth token." [C]="Recreate default configuration file. Acquire new oauth token."
[h]="Help, show usage information for ${0##*/}." [h]="Help, show usage information for ${0##*/}."
[M]="Post the currently playing music track, requires playerctl." [M]="Post the currently playing music track, requires playerctl."
[p:]="Post from the command line, e.g. ${0##*/} -p \"hello world\""
) )
# if the default file doesn't exist, create it # if the default file doesn't exist, create it
@ -106,6 +117,7 @@ while getopts "${args}" i ; do
C) get_oauth_token;; C) get_oauth_token;;
h) help;; h) help;;
M) post_music;; M) post_music;;
p) post_status "${OPTARG}";;
esac esac
done done