jan146 / playerctl-scroller

Scroll the currently playing song via playerctl. It can also be used with polybar.
2 stars 1 forks source link

Getting a "Segmentation fault (core dumped)" error #2

Open bowen-song opened 2 years ago

bowen-song commented 2 years ago

Hi, I've come here from the original playerctl scroller in hopes of finding a more lightweight option and your version in C seems to check the boxes.

I'm unable to get the program to run correctly; every time I run playerctl-scroller, I get a "Segmentation fault (core dumped)" error. I did a quick search around to learn about segmentation errors, but I don't really know enough about C to help fix this issue. Hope you can help!

jan146 commented 2 years ago

The program is not meant to be run by itself, but with a wrapper script, namely scroller.sh. It should be located in ~/.config/polybar/scripts/ after issuing make config.

bowen-song commented 2 years ago

Sorry, I should have been more clear in my original description of the problem. Part of the reason I tried to run the program separately was due to the fact that after sudo make and make config, I'm able to get a "No player is running" label in polybar, but it won't actually report my music player. For some more description on my setup, I've gone through and updated the scroller.sh as required (for player, I've left it as playerctl) and the music player I'm using is called sublime-music which advertises itself as an mpris player. I'm led to believe the problem is not with the player, but probably some issue with my configuration because even when playing videos from Firefox, I don't get an update on polybar.

Here are the relevant configurations: ~/.config/polybar/config

[bar/mainbar]
enable-ipc = true

[module/spotify]
type = custom/script
tail = true
format = <label>
exec = ~/.config/polybar/scripts/scroller.sh

[module/music-pp]
type = custom/ipc
hook-0 = echo ""
hook-1 = echo ""
initial = 1
click-left = playerctl play-pause

~/.config/polybar/scripts/scroller.sh

#!/bin/bash

BAR="mainbar"

MODULE="music-pp"

PLAYER="playerctl"
###rest of configuration is the default, auto-generated config###
jan146 commented 2 years ago

If you're getting a "No player is running" message, then the destination of the dbus query is undefined. To help with narrowing down the problem, try running scroller.sh --status while an mpris player is running (paused or playing). The output should be [Paused|Playing] [dbus destination], in which case, the problem is likely somewhere within playerctl-scroller. If the output is "OFFLINE" however, then please provide me with the output of this command (while an mpris player is running of course):

dbus-send --print-reply \
--dest=org.freedesktop.DBus \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames \
| grep mpris

This should print out all the available playerctl destinations, which should include playerctld and sublime-music.

bowen-song commented 2 years ago

Results from ./scroller.sh --status OFFLINE

Results from command:

dbus-send --print-reply \
--dest=org.freedesktop.DBus \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames \
| grep mpris
      string "org.mpris.MediaPlayer2.sublimemusic"
      string "org.mpris.MediaPlayer2.firefox.instance179977"

Seems like the issue is that playerctld does not show up in the destination, but I'm not sure what this would indicate.

jan146 commented 2 years ago

From my testing, this is how the playerctld instance works: Playerctl-scroller uses the following command to initialize the default player:

dbus-send --print-reply \
--dest=org.mpris.MediaPlayer2.playerctld \
/org/mpris/MediaPlayer2 \
org.freedesktop.DBus.Properties.GetAll

When I execute it, I get an error:

Error org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.DBus.Properties” on
object at path /org/mpris/MediaPlayer2

As such, this command is executed only at the start. However, the default playerctld mpris player instance is available after executing it. Try executing the command above manually and check whether the command output of:

dbus-send --print-reply \
--dest=org.freedesktop.DBus \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames \
| grep mpris

is still the same (missing string "org.mpris.MediaPlayer2.playerctld") or if it now includes the default instance. You can also check whether playerctld is running with ps -aux | grep playerctld.

Best regards, Jan

bowen-song commented 2 years ago

Hi Jan, thanks for the quick response.

Upon executing the initializing command, I receive a different error from you:

Error org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/mpris/MediaPlayer2”

Executing the command:

dbus-send --print-reply \
--dest=org.freedesktop.DBus \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames \
| grep mpris

however, gives the correct results including the string "org.mpris.MediaPlayer2.playerctld" as expected.

New questions/problems:

  1. Will this initialization command need to be run manually every time? I've rebooted my computer and it seems like playerctld does not initialize automatically.

  2. My music player sublime-music is undetectable by the script:

    • when playing music with my player, the output is still "No player is running"
    • when playing music with firefox, the script works as expected after manual initialization of playerctld
    • some troubleshooting I had with the original script from PrayagS (and what I think may be causing this issue too) was as follows:

These commands from terminal produce different results for the different music players:

While spotify stopped, playerctl --player=spotify status -> Stopped
While spotify stopped, playerctl status -> Stopped
While sublime-music is stopped, playerctl --player=sublime-music status -> **No players found (unexpected)**
While sublime-music is stopped, playerctl status -> Stopped (as expected)

For some reason, playerctl cannot detect sublime-music when the --player option is specified, and works only when there is no --player