{"id":13575169,"url":"https://github.com/mihirlad55/polybar-spotify-module","last_synced_at":"2025-04-04T19:31:15.209Z","repository":{"id":38040057,"uuid":"254769715","full_name":"mihirlad55/polybar-spotify-module","owner":"mihirlad55","description":"A collection of lightweight programs for use with a Polybar Spotify Module","archived":false,"fork":false,"pushed_at":"2024-02-09T17:26:46.000Z","size":101,"stargazers_count":144,"open_issues_count":19,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-05T10:45:56.207Z","etag":null,"topics":["c","lightweight","module","polybar","spotify"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mihirlad55.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-11T01:26:18.000Z","updated_at":"2024-10-07T23:32:33.000Z","dependencies_parsed_at":"2024-03-17T04:42:50.525Z","dependency_job_id":null,"html_url":"https://github.com/mihirlad55/polybar-spotify-module","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihirlad55%2Fpolybar-spotify-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihirlad55%2Fpolybar-spotify-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihirlad55%2Fpolybar-spotify-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihirlad55%2Fpolybar-spotify-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mihirlad55","download_url":"https://codeload.github.com/mihirlad55/polybar-spotify-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247237678,"owners_count":20906329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","lightweight","module","polybar","spotify"],"created_at":"2024-08-01T15:00:58.735Z","updated_at":"2025-04-04T19:31:10.200Z","avatar_url":"https://github.com/mihirlad55.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# Polybar Spotify Module\n\n![polybar-spotify-module](https://github.com/mihirlad55/polybar-spotify-module/raw/master/screenshots/capture2.png)\n\nThis is a pure C implementation of an external polybar module that signals\npolybar when a track is playing/paused and when the track changes. There is\nalso a program that retreives the title and artist of the currently playing\nsong on spotify.\n\n\n## Requirements\nDBus is used for listening to spotify track changes. Obviously you need spotify\nand polybar as well:\n`dbus polybar spotify`\n\nTo compile the program, you will need `make`.\n\nYou most likely already have the above packages installed. Systemd depends on\nDBus, and you wouldn't be looking at this, if you didn't have polybar and\nspotify installed.\n\n\n## How to Setup\n\n### Installing the Program\nRun the following code to clone the repo and install the programs.\n```\ngit clone https://github.com/mihirlad55/polybar-spotify-module\ncd polybar-spotify-module/src/\nsudo make install\n```\n\n#### Arch Linux Users\n`polybar-spotify-module` exists as a package on the AUR! Use your favourite\nAUR helper to install the package.\n```\nyay -S polybar-spotify-module\n```\nThe package can be found here\n\u003chttps://aur.archlinux.org/packages/polybar-spotify-module/\u003e.\n\n### Running spotify-listener in the Background\n`spotify-listener` must run in the background for it to be able to listen for\ntrack changes and communicate with polybar. There are two ways to keep it\nrunning in the background. If you are using systemd, you can have it start at\nsystem startup by running:\n\n```\nsystemctl --user enable spotify-listener\n```\n\nThen, you can start the service now by running:\n\n```\nsystemctl --user start spotify-listener\n```\n\nIf you are not using systemd, make sure the `spotify-listener` program is\nexecuted at startup. Something like\n```\nspotify-listener \u0026\ndisown\n```\nin a startup script should accomplish that.\n\n\n### Configuring Polybar\nYour polybar configuration file should be located at `.config/polybar/config`\n\nFirst make sure IPC is enabled. The following should be in your configuration\nfile under the `[bar/\u003cyour bar name\u003e]` section:\n```\n[bar/main]\nenable-ipc = true\n```\n\nIf you plan to use icons for next/play/previous/pause buttons, make sure you\nadd (and have installed) an icon font accordingly such as NerdFonts or\nFontAwesome under the `[bar/\u003cyour bar name\u003e]` section:\n```\n[bar/main]\nfont-1 = Font Awesome 5 Free:size=10;1\n```\nNote that the font is specified in modules as a 1-based index, so `font-1` is\nspecified by `format-font = 2`.\n\nNext, add the following spotify modules:\n```\n[module/previous]\ntype = custom/ipc\nformat-font = 2\n; Default\nhook-0 = echo \"\"\n; When spotify active\nhook-1 = echo \"Previous\"\nclick-left = \"spotifyctl -q previous\"\n\n\n[module/next]\ntype = custom/ipc\nformat-font = 2\n; Default\nhook-0 = echo \"\"\n; When spotify active\nhook-1 = echo \"Next\"\nclick-left = \"spotifyctl -q next\"\n\n\n[module/playpause]\ntype = custom/ipc\nformat-font = 2\n; Default\nhook-0 = echo \"\"\n; Playing\nhook-1 = echo \"Pause\"\n; Paused\nhook-2 = echo \"Play\"\nclick-left = \"spotifyctl -q playpause\"\n\n\n[module/spotify]\ntype = custom/ipc\n; Default\nhook-0 = echo \"\"\n; Playing/paused show song name and artist\nhook-1 = spotifyctl -q status --format '%artist%: %title%'\n```\nYou can replace the text for Pause/Play/Next/Previous with icons for each of\nthe hooks.\n\nLastly, make sure the new spotify modules are part of your bar. Make sure one of\nthe following lines is part of your modules.\n```\nmodules-center = spotify previous playpause next\nmodules-left = spotify previous playpause next\nmodules-right = spotify previous playpause next\n```\n\n## Status Formatting\nThe `spotifyctl status` command has multiple formatting options. You can\nspecify the:\n- Maximum output length\n- Maximum artist length\n- Maxiumum track title length\n- Output Format\n- Truncation string\n\nBy default, the above lengths are `INT_MAX` (no limit). Additionally, if max\nlength is specified, the artist and track title will not be truncated if\nthe untruncated output satisfies the output max length constraint.\n\nThe tokens `%artist%` and `%title%` can be used to specify the output format.\n\nFor example for the artist `Eminem` and track title `Sing For The Moment`\n```\nspotifyctl status --format '%artist%: %title%' --max-length 20 \\\n    --max-title-length 10 --max-artist-length 10 --trunc '...'\n```\nwould result in the following output\n```\nEminem: Sing Fo...\n```\n\nFor more information and examples, you can run the command `spotifyctl help`.\n\n\n## How it Works\nThe spotify-listener program connects to the DBus Session Bus and listens for\ntwo particular signals:\n\n- `org.freedesktop.DBus.ProprtyChanged` for track changes\n- `org.freedesktop.DBus.NameOwnerChanged` for spotify disconnections\n\nUsing this information, it sends messages to spotify polybar custom/IPC modules\nto show/hide spotify controls and display the play/pause icon based on whether\na song is playing/paused.\n\nThe spotifyctl program calls `org.mpris.MediaPlayer2.Properties.Get` method to\nretreive status information and calls methods in the\n`org.mpris.MediaPlayer2.Player` interface to pause/play and go to the\nprevious/next track.\n\n\n## Why Did I Make this in C\n- Practice/learn low-level C\n- Reduce number of dependencies\n- Make something as lightweight as possible by directly interfacing with DBus\n- For fun 😜\n\n\n## Resources\nThe following are very useful resources for DBus API and specs:\n\n- \u003chttps://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html\u003e\n- \u003chttps://dbus.freedesktop.org/doc/api/html/group__DBusBus.html\u003e\n- \u003chttps://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html\u003e\n- \u003chttps://dbus.freedesktop.org/doc/dbus-specification.html\u003e\n- \u003chttps://dbus.freedesktop.org/doc/dbus-tutorial.html\u003e\n\n\n## Credits\nInspired by the python implementation by\n[dietervanhoof](https://github.com/dietervanhoof): \u003chttps://github.com/dietervanhoof/polybar-spotify-controls\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihirlad55%2Fpolybar-spotify-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmihirlad55%2Fpolybar-spotify-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihirlad55%2Fpolybar-spotify-module/lists"}