song: Added song_format.

This commit is contained in:
Dylan Araps 2018-05-10 08:49:05 +10:00
parent e8ac76dc57
commit b5a2323144
2 changed files with 27 additions and 10 deletions

View File

@ -437,6 +437,16 @@ disk_subtitle="mount"
# yarock # yarock
music_player="auto" music_player="auto"
# Format to display song information.
#
# Default: '%artist% - %album% - %title%'
# Values: '%artist%', '%album%', '%title%'
# Flag: --song_format
#
# Example:
# on: 'Song: Jet - Get Born - Sgt Major'
song_format="%artist% - %album% - %title%"
# Print the Artist and Title on separate lines # Print the Artist and Title on separate lines
# #
# Default: 'off' # Default: 'off'
@ -2486,18 +2496,20 @@ get_song() {
*) mpc >/dev/null 2>&1 && song="$(mpc -f '%artist% ‡ %album% ‡ %title%' current)" ;; *) mpc >/dev/null 2>&1 && song="$(mpc -f '%artist% ‡ %album% ‡ %title%' current)" ;;
esac esac
[[ "$song" != *[a-z]* ]] && unset -v song [[ "$song" != *[a-z]* ]] && { unset -v song; return; }
LC_ALL="$sys_locale" IFS="‡" read -r artist album title <<< "$song"
# Display Artist, Album and Title on separate lines. # Display Artist, Album and Title on separate lines.
if [[ "$song_shorthand" == "on" && "$song" ]]; then if [[ "$song_shorthand" == "on" ]]; then
LC_ALL="$sys_locale" IFS="‡" read -r artist album song <<< "$song"
[[ "$(trim "$artist")" ]] && prin "Artist" "$artist" [[ "$(trim "$artist")" ]] && prin "Artist" "$artist"
[[ "$(trim "$album")" ]] && prin "Album" "$album" [[ "$(trim "$album")" ]] && prin "Album" "$album"
[[ "$(trim "$song")" ]] && prin "Song" "$song" [[ "$(trim "$song")" ]] && prin "Song" "$title"
else
song="${song_format/\%artist\%/${artist}}"
song="${song/\%album\%/${album}}"
song="${song/\%title\%/${title}}"
fi fi
song="${song//‡/-}"
} }
get_resolution() { get_resolution() {
@ -4678,7 +4690,8 @@ INFO:
'dir' shows the basename of the disks's path. (/, Local Disk, etc) 'dir' shows the basename of the disks's path. (/, Local Disk, etc)
--ip_host url URL to query for public IP --ip_host url URL to query for public IP
--song_shorthand on/off Print the Artist/Title on separate lines --song_format format Print the song data in a specific format (see config file).
--song_shorthand on/off Print the Artist/Album/Title on separate lines.
--music_player player-name Manually specify a player to use. --music_player player-name Manually specify a player to use.
Available values are listed in the config file Available values are listed in the config file
--install_time on/off Enable/Disable showing the time in Install Date output. --install_time on/off Enable/Disable showing the time in Install Date output.
@ -4835,6 +4848,7 @@ get_args() {
"--shell_path") shell_path="$2" ;; "--shell_path") shell_path="$2" ;;
"--shell_version") shell_version="$2" ;; "--shell_version") shell_version="$2" ;;
"--ip_host") public_ip_host="$2" ;; "--ip_host") public_ip_host="$2" ;;
"--song_format") song_format="$2" ;;
"--song_shorthand") song_shorthand="$2" ;; "--song_shorthand") song_shorthand="$2" ;;
"--music_player") music_player="$2" ;; "--music_player") music_player="$2" ;;
"--install_time") install_time="$2" ;; "--install_time") install_time="$2" ;;

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6.
.TH NEOFETCH "1" "May 2018" "Neofetch 3.4.1-git" "User Commands" .TH NEOFETCH "1" "May 2018" "Neofetch 4.0.0-git" "User Commands"
.SH NAME .SH NAME
Neofetch \- A fast, highly customizable system info script Neofetch \- A fast, highly customizable system info script
.SH SYNOPSIS .SH SYNOPSIS
@ -115,8 +115,11 @@ Takes: name, mount, dir
\fB\-\-ip_host\fR url \fB\-\-ip_host\fR url
URL to query for public IP URL to query for public IP
.TP .TP
\fB\-\-song_format\fR format
Print the song data in a specific format (see config file).
.TP
\fB\-\-song_shorthand\fR on/off \fB\-\-song_shorthand\fR on/off
Print the Artist/Title on separate lines Print the Artist/Album/Title on separate lines.
.TP .TP
\fB\-\-music_player\fR player\-name \fB\-\-music_player\fR player\-name
Manually specify a player to use. Manually specify a player to use.