Script for polybar to display and control media(not only Spotify) using DBus.

Overview

polybar-now-playing

Script for polybar to display and control media(not only Spotify) using DBus

Python script to display and control current playing media. Includes a way to switch between players. Scrolling text used for metadata(title, artist, album, etc.) and playback button based on spotify-polybar and zscroll.

Demo:

demo

demo

screenshot

Dependencies

Setup & Configuration

  • This script requires a monospace font to work as expected, so adding a monospace font to your polybar config is adviced. After adding the font, update the index in polybar-now-playing file where indicated. Font indices are 1-based so be careful, refer polybar:Fonts.
  • Format of playing track/media details by default is "title - artist". It can be changed by specifying respective field names in metadata_fields list. For more details/ field names, refer mpris sepecification.
# Config options

# (int) : Length of media info string. If length of string exceedes this value,
# the text will scroll. Default value is 20.
message_display_len = 20

# (int) : Font index of polybar. this value should be 1 more than the font
# value specified in polybar config.
font_index = <font index defined in polybar config> + 1


# (float) : Update speed of the text in seconds. Default value 0.3.
update_delay = 0.3

# (list) : list of chars containing previous, play, pause, next glyphs
# for media controls in respective order.
# example:
control_chars = ['','','','']

# (dict) : dict of char icons to display as prefix.
# If player name is available as key, then use the corressponding icon,
# else default.
# example:
display_player_prefix = {
    "spotify":  '',
    "firefox":  '',
    "default":  ''
}

# (list) : list of metadata fields based on mpris sepecification.
metadata_fields = ["xesam:title", "xesam:artist"]

# (char) : separator for metadata fields
metadata_separator = "-"
  • After setting the options, add the following to your polybar config.
[module/now-playing]
type = custom/script
tail = true
;format-prefix = ""
format = <label>
exec = <path/to/script>
click-right = "kill -USR1 $(pgrep --oldest --parent %pid%)"
Comments
  • Unable to switch players

    Unable to switch players

    Thanks for the script, was exactly what I was looking for! Only issue I have with it is I can't figure out how to switch the players. I assume that it's done through the click-right = "kill -USR1 $(pgrep --oldest --parent %pid%)" part in the polybar module config, but it doesn't do anything when I right-click (or left-click and middle-click, for that matter) the module. And when I run kill -USR1 $(pgrep --oldest --parent %pid%) separately in a terminal, I get this error:

    pgrep: not a number: %pid% kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

    opened by vanir-04 6
  • buttons unresponsive

    buttons unresponsive

    glad I found this project because I was looking for this exact thing, but now after setting it up, the buttons don't respond to clicks. any ideas here? I've tried running the script non-daemonized to see if theres any error messages but there don't seem to be.

    opened by CodingArctic 6
  • "error: Failed to parse contents."

    Hi, thanks a lot for the script, I've been getting this error when I launch polybar from the terminal with the script enabled Screenshot_2021-07-20-10_602x795 the bar still launches properly but it's annoying because when modifying the bar manually I reload it from terminal to look for errors and this spams away any other error from other modules. The bar still works though.

    opened by Light034 5
  • How to change the size of the buttons?

    How to change the size of the buttons?

    Hi, I changed the font size on the polybar config.ini "font-0 =" but this change doesn't seem to affect the size of the icons for prev, play/pause, next buttons, I was looking into the code and the config but I couldn't find any variable that could be changed to make them bigger or smaller. I also tried adding a label-font = 2 to the polybar module but it didn't change anything.

    Screenshot_2021-08-31-10_326x51

    Is there a way to change the size of this icons? if not, would it be possible to get it implemented?

    invalid 
    opened by Light034 3
  • Multiple browser tabs at the same time

    Multiple browser tabs at the same time

    Hi! Thanks for the script, it is pretty nice!

    Would like to ask if is there a way to control multiple tabs from Chrome playing at the same time. For example, I have 2 tabs, each one playing different videos from Youtube. I would like to control each tab... Thanks!

    EDIT: Changed the question

    opened by andregalastri 2
  • Broken on Arch update

    Broken on Arch update

    I have Arch Linux on the zen kernel 5.15.7 and after a full system upgrade the script broke and gives this error every time.

    Traceback (most recent call last):
      File "/home/gianmarco/.config/polybar/gmg/scripts/polybar-now-playing", line 52, in <module>
        session_bus = dbus.SessionBus()
    AttributeError: module 'dbus' has no attribute 'SessionBus'
    
    opened by gianmarcogg03 1
Owner
Dope Wizard
Dope Wizard
A really easy way to display your spotify listening status on spotify.

Spotify playing README A really easy way to display your spotify listening status on READMEs and Websites too! Demo Here's the embed from the site. Cu

Sunrit Jana 21 Nov 6, 2022
A Python script to create customised Spotify playlists using the JSON, Spotipy Library and Spotify Web API, based on seed tracks in your history.

A Python script to create customised Spotify playlists using the JSON, Spotipy Library and Spotify Web API, based on seed tracks in your history.

Youngseo Park 1 Feb 1, 2022
google-resumable-media Apache-2google-resumable-media (🥉28 · ⭐ 27) - Utilities for Google Media Downloads and Resumable.. Apache-2

google-resumable-media Utilities for Google Media Downloads and Resumable Uploads See the docs for examples and usage. Experimental asyncio Support Wh

Google APIs 36 Nov 22, 2022
An interactive App to play with Spotify data, both from the Spotify Web API and from CSV datasets.

An interactive App to play with Spotify data, both from the Spotify Web API and from CSV datasets.

Caio Lang 3 Jan 24, 2022
A simple program to display current playing from Spotify app on your desktop

WallSpot A simple program to display current playing from Spotify app on your desktop How to Use: Linux: Currently Supports GNOME and KDE. If you want

Nannan 4 Feb 19, 2022
A wrapper for The Movie Database API v3 and v4 that only uses the read access token (not api key).

fulltmdb A wrapper for The Movie Database API v3 and v4 that only uses the read access token (not api key). Installation Use the package manager pip t

Jacob Hale 2 Sep 26, 2021
A collection of scripts to steal BTC from Lightning Network enabled custodial services. Only for educational purpose! Share your findings only when design flaws are fixed.

Lightning Network Fee Siphoning Attack LN-fee-siphoning is a collection of scripts to subtract BTC from Lightning Network enabled custodial services b

Reckless_Satoshi 14 Oct 15, 2022
A collection of scripts to steal BTC from Lightning Network enabled custodial services. Only for educational purpose! Share your findings only when design flaws are fixed.

Lightning Network Fee Siphoning Attack LN-fee-siphoning is a collection of scripts to subtract BTC from Lightning Network enabled custodial services b

Reckless_Satoshi 14 Oct 15, 2022
A script that takes what you're listening too on Spotify and sets it as your Nertivia custom status.

nertivia-spotify-listening-status A script that takes what you're listening too on Spotify and sets it as your Nertivia custom status. setup Install r

Ben Tettmar 2 Feb 3, 2022
A Python script to update Spotify Playlist data every 5 minutes.

Spotify Playlist Updater A Python script to update Spotify Playlist data every 5 minutes. Description An automatic playlist updater using Spotify API

null 6 Nov 24, 2022
Python script to backup/convert your Spotify playlists into the XSPF format.

Python script to backup/convert your Spotify playlists into the XSPF format.

Chris Ovenden 4 Jun 9, 2022
Requests based multi-threaded script for increasing followers on Spotify

Proxyless Spotify Follow Bot Requests based multi-threaded script for increasing followers on Spotify. Click here to report bugs. Usage Download ZIP h

null 397 Jan 3, 2023
Automatically compile an AWS Service Control Policy that ONLY allows AWS services that are compliant with your preferred compliance frameworks.

aws-allowlister Automatically compile an AWS Service Control Policy that ONLY allows AWS services that are compliant with your preferred compliance fr

Salesforce 189 Dec 8, 2022
Python3 program to control Elgato Ring Light on your local network without Elgato's Control Center software

Elgato Light Controller I'm really happy with my Elgato Key Light from an illumination perspective. However, their control software has been glitchy f

Jeff Tarr 14 Nov 16, 2022
A script to forward mass number of media to another group/channel. Heroku deploy

Telegram Forward Script ?? This is a Script to Forward Large Number of Files to Another Telegram Channel. Star එකක් දාල fork එකක් ගහපියව් ?? If You Tr

Anjana Madu 17 Oct 21, 2022
Simple PoC script that allows you to exploit telegram's "send with timer" feature by saving any media sent with this functionality.

Simple PoC script that allows you to exploit telegram's "send with timer" feature by saving any media sent with this functionality.

Matteo 52 Nov 29, 2022
Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

Nikola Arbov 1 Jan 13, 2022
Dante, my discord bot. Open source project in development and not optimized for other filesystems, install and setup script in development

DanteMode (In private development for ~6 months) Dante, my discord bot. Open source project in development and not optimized for other filesystems, in

null 2 Nov 5, 2021
Telegram Group Calls Streaming bot with some useful features, written in Python with Pyrogram and Py-Tgcalls. Supporting platforms like Youtube, Spotify, Resso, AppleMusic, Soundcloud and M3u8 Links.

Yukki Music Bot Yukki Music Bot is a Powerful Telegram Music+Video Bot written in Python using Pyrogram and Py-Tgcalls by which you can stream songs,

Team Yukki 996 Dec 28, 2022