configs are here
This commit is contained in:
45
quickshell_/Player.qml
Normal file
45
quickshell_/Player.qml
Normal file
@@ -0,0 +1,45 @@
|
||||
pragma Singleton
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import Quickshell.Services.Mpris
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
// property MprisPlayer trackedPlayer: null;
|
||||
readonly property MprisPlayer activePlayer: PlayerController.activePlayer.identity === "Spotify"
|
||||
? PlayerController.activePlayer
|
||||
: null
|
||||
|
||||
readonly property string time: {
|
||||
root.activePlayer.trackTitle
|
||||
}
|
||||
readonly property string artist: {
|
||||
root.activePlayer.trackArtist
|
||||
}
|
||||
readonly property string timetime: {
|
||||
Math.floor(root.activePlayer.position / 60) + ":" +
|
||||
formatTwoDigits(Math.floor(root.activePlayer.position % 60))
|
||||
}
|
||||
|
||||
readonly property string fulltime: {
|
||||
Math.floor(root.activePlayer.length / 60) + ":" +
|
||||
formatTwoDigits(Math.floor(root.activePlayer.length % 60))
|
||||
}
|
||||
|
||||
function formatTwoDigits(num) {
|
||||
return (num < 10 ? "0" : "") + num;
|
||||
}
|
||||
|
||||
|
||||
Timer {
|
||||
// only emit the signal when the position is actually changing.
|
||||
running: root.activePlayer.playbackState == MprisPlaybackState.Playing
|
||||
// Make sure the position updates at least once per second.
|
||||
interval: 1000
|
||||
repeat: true
|
||||
// emit the positionChanged signal every second.
|
||||
onTriggered: root.activePlayer.positionChanged()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user