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
8aef69b7
Commit
8aef69b7
authored
Dec 15, 2016
by
Dylan Araps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Song: Move dbus commands to a function
parent
ca8c45b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
28 deletions
+16
-28
neofetch
neofetch
+16
-28
No files found.
neofetch
View file @
8aef69b7
...
...
@@ -1139,6 +1139,18 @@ get_song() {
# This is absurdly long.
player
=
"
$(
ps x |
awk
'!(/awk|Helper|Cache/) && /mpd|cmus|mocp|spotify|Google Play|iTunes.app|rhythmbox|banshee|amarok|deadbeef|audacious|gnome-music|lollypop|clementine|pragha/ {printf $5 " " $6; exit}'
)
"
get_song_dbus
()
{
# Multiple players use an almost identical dbus command to get the information.
# This function saves us including the same command throughtout the function.
song
=
"
$(
\
dbus-send
--print-reply
--dest
=
org.mpris.MediaPlayer2.
"
${
1
}
"
/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
% -
}
"
}
case
"
${
player
/*\/
}
"
in
"mpd"
*
)
song
=
"
$(
mpc current
)
"
...
...
@@ -1159,18 +1171,7 @@ get_song() {
"spotify"
*
)
case
"
$os
"
in
"Linux"
)
# Thanks dbus
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
//
'['
*
}
"
;;
"Linux"
)
get_song_dbus
"spotify"
;;
"Mac OS X"
)
song
=
"
$(
osascript
-e
'tell application "Spotify" to artist of current track as string & " - " & name of current track as string'
)
"
...
...
@@ -1219,22 +1220,9 @@ get_song() {
song
=
"
$(
audtool current-song
)
"
;;
"gnome-music"
*
|
"lollypop"
*
|
"clementine"
*
)
case
"
$player
"
in
"gnome-music"
*
)
player
=
"GnomeMusic"
;;
"lollypop"
*
)
player
=
"Lollypop"
;;
"clementine"
*
)
player
=
"clementine"
;;
esac
# Hello dbus my old friend.
song
=
"
$(
\
dbus-send
--print-reply
--dest
=
org.mpris.MediaPlayer2.
"
${
player
}
"
/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
% -
}
"
;;
"gnome-music"
*
)
get_song_dbus
"GnomeMusic"
;;
"lollypop"
*
)
get_song_dbus
"Lollypop"
;;
"clementine"
*
)
get_song_dbus
"clementine"
;;
"pragha"
*
)
artist
=
"
$(
pragha
-c
|
awk
-F
':'
'/artist/ {print $2}'
)
"
...
...
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