mirror of
https://github.com/bvanroll/_dotfiles.git
synced 2025-08-29 20:12:42 +00:00
init
This commit is contained in:
22
.config/i3blocks/spotifyd_dbus/LICENSE.md
Normal file
22
.config/i3blocks/spotifyd_dbus/LICENSE.md
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 GrislyMe
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
20
.config/i3blocks/spotifyd_dbus/README.md
Normal file
20
.config/i3blocks/spotifyd_dbus/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Spotifyd dbus status
|
||||
Show song currently played on Spotifyd
|
||||
|
||||
And provide simple control(Click to pause/start).
|
||||

|
||||
|
||||
## requirement
|
||||
require dbus-python package.
|
||||
|
||||
require spotifyd with dbus support. (For Arch user is "spotifyd-full-git" in AUR)
|
||||
|
||||
## example config
|
||||
```
|
||||
[spotify]
|
||||
min_width=Buttom=?
|
||||
command=$SCRIPT_DIR/spotifyd_dbus $buttom
|
||||
color=#00FFB3
|
||||
interval=10
|
||||
```
|
||||
|
BIN
.config/i3blocks/spotifyd_dbus/example.png
Normal file
BIN
.config/i3blocks/spotifyd_dbus/example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
44
.config/i3blocks/spotifyd_dbus/spotifyd_dbus
Executable file
44
.config/i3blocks/spotifyd_dbus/spotifyd_dbus
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import dbus
|
||||
import sys
|
||||
|
||||
def progressBar(perc : float):
|
||||
char = ["░", "▒", "█"]
|
||||
bar = char[2] * int(perc / 0.2)
|
||||
if perc >= 0.99:
|
||||
return bar + char[2]
|
||||
bar += char[1]
|
||||
while len(bar) != 5:
|
||||
bar += char[0]
|
||||
return bar
|
||||
|
||||
def main():
|
||||
bus = dbus.SessionBus()
|
||||
proxy = bus.get_object('org.mpris.MediaPlayer2.spotifyd','/org/mpris/MediaPlayer2')
|
||||
|
||||
properties_manager = dbus.Interface(proxy, 'org.freedesktop.DBus.Properties')
|
||||
|
||||
if properties_manager:
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] == "1":
|
||||
dbus.Interface(proxy, 'org.mpris.MediaPlayer2.Player').PlayPause()
|
||||
|
||||
status = properties_manager.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')
|
||||
if status == "Playing" : status = " "
|
||||
else : status = " "
|
||||
|
||||
current = properties_manager.Get('org.mpris.MediaPlayer2.Player', 'Position')
|
||||
|
||||
data = properties_manager.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
|
||||
length = data["mpris:length"]
|
||||
title = data["xesam:title"]
|
||||
|
||||
perc = current / length
|
||||
progress = progressBar(perc)
|
||||
bar = f" [ {title} ] {status} {progress}"
|
||||
print(bar)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user