Skip to content

Commit

Permalink
feat(lib): add functionality to save/get volume to/from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Hibbins committed Oct 26, 2024
1 parent 27974ff commit 16583df
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,24 @@ _station_list() {
jq -r '.[] | .name' <"$FAVORITE_PATH/$1.json"
}

# Function to get the saved volume or set it to default
get_saved_volume() {
if [ ! -f "$CONFIG_FILE" ]; then
echo "volume=100" > "$CONFIG_FILE"
fi
grep "volume" "$CONFIG_FILE" | cut -d '=' -f2
}

_play() {
echo
yellowprint "Press q to quit."
echo
mpv "$1" || {

# Get the saved volume from the config file
volume=$(get_saved_volume)

# Start mpv with saved volume level and the Lua script from the lib directory
mpv --volume="$volume" --script="./lib/save_volume.lua" "$1" || {
echo "Not able to play your station."
return 1
}
Expand Down

0 comments on commit 16583df

Please sign in to comment.