Compare commits
No commits in common. "a6849cceea845b72d5e7613843e60312353b2d73" and "220d5c3d30ac4f78cb9fc7df2ba244de59d586eb" have entirely different histories.
a6849cceea
...
220d5c3d30
43
ratatoskr.sh
43
ratatoskr.sh
@ -63,7 +63,7 @@ play_sound() {
|
|||||||
declare -A sounds=(
|
declare -A sounds=(
|
||||||
[error]="|sox -n -p synth saw E2 fade 0 0.25 0.05 repeat norm -7"
|
[error]="|sox -n -p synth saw E2 fade 0 0.25 0.05 repeat norm -7"
|
||||||
[music]="|sox -np synth pl E2 pl B2 overdrive 100 remix - overdrive 100 fade h .25 1 .25 norm -11"
|
[music]="|sox -np synth pl E2 pl B2 overdrive 100 remix - overdrive 100 fade h .25 1 .25 norm -11"
|
||||||
[status]='|sox -np synth .05 tri C2:C7'
|
[post]='|sox -np synth .05 tri C2:C7'
|
||||||
)
|
)
|
||||||
if [[ -n "${sounds[${soundName}]}" ]]; then
|
if [[ -n "${sounds[${soundName}]}" ]]; then
|
||||||
sox -qV0 "${sounds[${soundName}]}" -d gain -9 &> /dev/null &
|
sox -qV0 "${sounds[${soundName}]}" -d gain -9 &> /dev/null &
|
||||||
@ -113,9 +113,25 @@ post_music() {
|
|||||||
if [[ "${link}" =~ ^file:// ]]; then
|
if [[ "${link}" =~ ^file:// ]]; then
|
||||||
link="https://www.youtube.com/results?search_query=$(playerctl metadata -f '{{artist}} {{title}}' | urlencode -b)"
|
link="https://www.youtube.com/results?search_query=$(playerctl metadata -f '{{artist}} {{title}}' | urlencode -b)"
|
||||||
fi
|
fi
|
||||||
statusSpoiler_text="Music"
|
local json=$(jq -n --arg status "[${text}](${link})" --arg spoiler_text "Music" --arg content_type "text/markdown" '{status: $status, spoiler_text: $spoiler_text, content_type: $content_type}')
|
||||||
postType="music"
|
local result
|
||||||
post_status "[${text}](${link})"
|
result="$(curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \
|
||||||
|
-d "$json" \
|
||||||
|
"${instanceURL}/api/v1/statuses")"
|
||||||
|
# Check for errors
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "there was a problem contacting the server"
|
||||||
|
play_sound error
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local error="$(echo "$result" | jq -r '.error')"
|
||||||
|
if [[ "$error" != "null" ]]; then
|
||||||
|
echo "Error: $error"
|
||||||
|
play_sound error
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Music posted!"
|
||||||
|
play_sound music
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,10 +140,10 @@ post_status() {
|
|||||||
if [[ "${*}" == "" ]]; then
|
if [[ "${*}" == "" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
postType="${postType:-status}"
|
|
||||||
local statusText="$*"
|
local statusText="$*"
|
||||||
statusVisibility="${statusVisibility:-public}"
|
local statusVisibility="${statusVisibility:-public}"
|
||||||
statusContent_type="${statusContent_type:-text/markdown}"
|
local statusContent_type="${statusContent_type:-text/markdown}"
|
||||||
|
local statusSpoiler_text=""
|
||||||
local statusJson="$(jq -n --arg status "$statusText" \
|
local statusJson="$(jq -n --arg status "$statusText" \
|
||||||
--arg spoiler_text "$statusSpoiler_text" \
|
--arg spoiler_text "$statusSpoiler_text" \
|
||||||
--arg visibility "$statusVisibility" \
|
--arg visibility "$statusVisibility" \
|
||||||
@ -148,8 +164,8 @@ post_status() {
|
|||||||
play_sound error
|
play_sound error
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "${postType^} posted!"
|
echo "Status posted!"
|
||||||
play_sound "${postType}"
|
play_sound post
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -194,7 +210,6 @@ declare -A command=(
|
|||||||
[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\" or echo \"Hello world\" | ${0}"
|
[p::]="Post from the command line, e.g. ${0##*/} -p \"hello world\" or echo \"Hello world\" | ${0}"
|
||||||
[t:]="Title of your post."
|
|
||||||
[v:]="Post visibility, [direct | followers | public | unlisted], default is public."
|
[v:]="Post visibility, [direct | followers | public | unlisted], default is public."
|
||||||
[S]="Scrobble the currently playing music track, requires playerctl."
|
[S]="Scrobble the currently playing music track, requires playerctl."
|
||||||
)
|
)
|
||||||
@ -209,12 +224,12 @@ eval set -- "$options"
|
|||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break;;
|
||||||
-C)
|
-C)
|
||||||
get_oauth_token
|
get_oauth_token
|
||||||
shift;;
|
shift;;
|
||||||
-t)
|
|
||||||
statusSpoiler_text="${2}"
|
|
||||||
shift 2;;
|
|
||||||
-v)
|
-v)
|
||||||
statusVisibility="${2}"
|
statusVisibility="${2}"
|
||||||
shift 2;;
|
shift 2;;
|
||||||
@ -229,7 +244,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
post_status "$(cat)"
|
post_status "$(cat)"
|
||||||
else
|
else
|
||||||
shift 3
|
shift 3
|
||||||
post_status "$@"
|
#post_status "$@"
|
||||||
fi
|
fi
|
||||||
exit 0;;
|
exit 0;;
|
||||||
-S)
|
-S)
|
||||||
|
Loading…
Reference in New Issue
Block a user