Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
eee8ac7f
Commit
eee8ac7f
authored
Oct 26, 2016
by
Dylan Araps
Committed by
GitHub
Oct 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #396 from dylanaraps/song
Song: Rewrite song function
parents
314c2547
6f41167e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
64 deletions
+78
-64
neofetch
neofetch
+78
-64
No files found.
neofetch
View file @
eee8ac7f
...
@@ -1120,79 +1120,93 @@ getmemory() {
...
@@ -1120,79 +1120,93 @@ getmemory() {
# Song {{{
# Song {{{
getsong
()
{
getsong
()
{
if
mpc version
>
/dev/null 2>&1
;
then
# This is absurdly long.
song
=
"
$(
mpc current 2>/dev/null
)
"
player
=
"
$(
ps x |
awk
'!(/awk|Helper|Cache/) && /mpd|cmus|mocp|spotify|Google Play|iTunes.app|rhythmbox|banshee|amarok|deadbeef|audacious/ {printf $5 " " $6; exit}'
)
"
state
=
"
$(
mpc |
awk
-F
'\\[|\\]'
'/\[/ {printf $2}'
2>/dev/null
)
"
case
"
${
player
/*\/
}
"
in
elif
[
-n
"
$(
ps x |
awk
'!(/awk/) && /cmus/'
)
"
]
;
then
"mpd"
*
)
IFS
=
$'
\n
'
song
=
"
$(
mpc current 2>/dev/null
)
"
song
=(
$(
cmus-remote
-Q
|
grep
"tag artist
\|
tag title
\|
status"
2>/dev/null |
sort
)
)
state
=
"
$(
mpc |
awk
-F
'\\[|\\]'
'/\[/ {printf $2}'
2>/dev/null
)
"
state
=
"
${
song
[0]/status
}
"
;;
artist
=
"
${
song
[1]/tag artist
}
"
title
=
"
${
song
[2]/tag title
}
"
"cmus"
*
)
song
=
"
${
artist
/tag title
}
-
${
title
/tag artist
}
"
IFS
=
$'
\n
'
song
=(
$(
cmus-remote
-Q
|
grep
"tag artist
\|
tag title
\|
status"
2>/dev/null |
sort
)
)
elif
pgrep
"mocp"
>
/dev/null 2>&1
;
then
state
=
"
${
song
[0]/status
}
"
song
=
"
$(
mocp
-Q
"%artist - %song"
2>/dev/null
)
"
artist
=
"
${
song
[1]/tag artist
}
"
state
=
"
$(
mocp
-Q
"%state"
2>/dev/null
)
"
title
=
"
${
song
[2]/tag title
}
"
song
=
"
${
artist
/tag title
}
-
${
title
/tag artist
}
"
elif
[
-n
"
$(
ps x |
awk
'!(/awk/) && /spotify/'
)
"
]
;
then
;;
case
"
$os
"
in
"Linux"
)
"mocp"
*
)
# This command is way too long
song
=
"
$(
mocp
-Q
"%artist - %song"
2>/dev/null
)
"
song
=
"
$(
\
state
=
"
$(
mocp
-Q
"%state"
2>/dev/null
)
"
dbus-send
--print-reply
--dest
=
org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2
\
;;
org.freedesktop.DBus.Properties.Get string:
'org.mpris.MediaPlayer2.Player'
string:
'Metadata'
|
\
awk
-F
'string "'
'/string|array/ {printf "%s",$2; next}{print ""}'
|
\
"spotify"
*
)
awk
-F
'"'
'/artist|title/ {printf $2 " - "}'
case
"
$os
"
in
)
"
"Linux"
)
song
=
"
${
song
% -
}
"
# Thanks dbus
song
=
"
${
song
/
'('
*
}
"
song
=
"
$(
\
song
=
"
${
song
//
'['
*
}
"
dbus-send
--print-reply
--dest
=
org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2
\
;;
org.freedesktop.DBus.Properties.Get string:
'org.mpris.MediaPlayer2.Player'
string:
'Metadata'
|
\
awk
-F
'string "'
'/string|array/ {printf "%s",$2; next}{print ""}'
|
\
awk
-F
'"'
'/artist|title/ {printf $2 " - "}'
)
"
song
=
"
${
song
% -
}
"
song
=
"
${
song
/
'('
*
}
"
song
=
"
${
song
//
'['
*
}
"
;;
"Mac OS X"
)
"Mac OS X"
)
song
=
"
$(
osascript
-e
'tell application "Spotify" to artist of current track as string & " - " & name of current track as string'
)
"
song
=
"
$(
osascript
-e
'tell application "Spotify" to artist of current track as string & " - " & name of current track as string'
)
"
state
=
"
$(
osascript
-e
'tell application "Spotify" to player state as string'
)
"
state
=
"
$(
osascript
-e
'tell application "Spotify" to player state as string'
)
"
;;
;;
esac
esac
;;
elif
[
-n
"
$(
ps x |
awk
'!(/awk/ || /Helper/) && /Google Play Music Desktop Player/'
)
"
]
&&
type
-p
gpmdp-remote
>
/dev/null 2>&1
;
then
"google play"
*
)
song
=
"
$(
gpmdp-remote current
)
"
song
=
"
$(
gpmdp-remote current 2>/dev/null
)
"
state
=
"
$(
gpmdp-remote status
)
"
state
=
"
$(
gpmdp-remote status 2>/dev/null
)
"
;;
elif
[
-n
"
$(
ps x |
awk
'!(/awk/ || /Helper/ || /Cache/) && /iTunes.app/'
)
"
]
;
then
"itunes"
*
)
song
=
"
$(
osascript
-e
'tell application "iTunes" to artist of current track as string & " - " & name of current track as string'
)
"
song
=
"
$(
osascript
-e
'tell application "iTunes" to artist of current track as string & " - " & name of current track as string'
)
"
state
=
"
$(
osascript
-e
'tell application "iTunes" to player state as string'
)
"
state
=
"
$(
osascript
-e
'tell application "iTunes" to player state as string'
)
"
;;
elif
[
-n
"
$(
ps x |
awk
'!(/awk/) && /rhythmbox/'
)
"
]
;
then
"rhythmbox"
*
)
song
=
"
$(
rhythmbox-client
--print-playing
)
"
song
=
"
$(
rhythmbox-client
--print-playing
)
"
# Well, what can you expect? It's dbus after all.
# Thanks dbus
state
=
"
$(
dbus-send
--print-reply
--dest
=
org.mpris.MediaPlayer2.rhythmbox /org/mpris/MediaPlayer2
\
state
=
"
$(
dbus-send
--print-reply
--dest
=
org.mpris.MediaPlayer2.rhythmbox /org/mpris/MediaPlayer2
\
org.freedesktop.DBus.Properties.Get string:
'org.mpris.MediaPlayer2.Player'
string:
'PlayBackStatus'
|
\
org.freedesktop.DBus.Properties.Get string:
'org.mpris.MediaPlayer2.Player'
string:
'PlayBackStatus'
|
\
awk
-F
'string "'
'{printf $2}'
)
"
awk
-F
'string "'
'{printf $2}'
)
"
state
=
"
${
state
//\
"}"
state
=
"
${
state
//\
"}"
;;
elif [ -n
"
$(
ps x |
awk
'!(/awk/) && /banshee/'
)
"
]; then
"banshee"
*)
artist=
"
$(
banshee
--query-artist
|
awk
-F
':'
'{print $2}'
)
"
artist=
"
$(
banshee
--query-artist
|
awk
-F
':'
'{print $2}'
)
"
title=
"
$(
banshee
--query-title
|
awk
-F
':'
'{print $2}'
)
"
title=
"
$(
banshee
--query-title
|
awk
-F
':'
'{print $2}'
)
"
song=
"
$artist
-
$title
"
song=
"
$artist
-
$title
"
state=
"
$(
banshee
--query-current-state
|
awk
-F
':'
'{print $2}'
)
"
state=
"
$(
banshee
--query-current-state
|
awk
-F
':'
'{print $2}'
)
"
;;
elif [ -n
"
$(
ps x |
awk
'!(/awk/) && /amarok/'
)
"
]; then
"amarok"
*)
artist=
"
$(
qdbus org.kde.amarok /Player GetMetadata |
awk
-F
':'
'/^artist/ {print $2}'
)
"
artist=
"
$(
qdbus org.kde.amarok /Player GetMetadata |
awk
-F
':'
'/^artist/ {print $2}'
)
"
title=
"
$(
qdbus org.kde.amarok /Player GetMetadata |
awk
-F
':'
'/title/ {print $2}'
)
"
title=
"
$(
qdbus org.kde.amarok /Player GetMetadata |
awk
-F
':'
'/title/ {print $2}'
)
"
song=
"
$artist
-
$title
"
song=
"
$artist
-
$title
"
;;
elif [ -n
"
$(
ps x |
awk
'!(/awk/) && /deadbeef/'
)
"
]; then
"deadbeef"
*)
song=
"
$(
deadbeef
--nowplaying
'%a - %t'
)
"
song=
"
$(
deadbeef
--nowplaying
'%a - %t'
)
"
;;
elif [ -n
"
$(
ps x |
awk
'!(/awk/) && /audacious/'
)
"
]; then
"audacious"
*)
song=
"
$(
audtool current-song
)
"
song=
"
$(
audtool current-song
)
"
;;
else
*) song=
"Not Playing"
;;
song=
"Not Playing"
esac
fi
case
"
$state
"
in
case
"
$state
"
in
"paused"
|
"PAUSE"
|
"Paused"
)
"paused"
|
"PAUSE"
|
"Paused"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment