[GH-ISSUE #100] Add sharing functionality #974

Closed
opened 2026-03-14 12:46:14 +03:00 by kerem · 14 comments
Owner

Originally created by @noelpilled on GitHub (Jan 6, 2023).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/100

A way to copy a link to both currently playing & currently selected track/album/artist/etc(podcast support?) would be nice. Maybe keybinds or adding the option to the action menu

Originally created by @noelpilled on GitHub (Jan 6, 2023). Original GitHub issue: https://github.com/aome510/spotify-player/issues/100 A way to copy a link to both currently playing & currently selected track/album/artist/etc(podcast support?) would be nice. Maybe keybinds or adding the option to the action menu
kerem 2026-03-14 12:46:14 +03:00
Author
Owner

@sewnie commented on GitHub (Jan 7, 2023):

i suggest only displaying the link as copying it would require support for Wayland, X11, etc.

<!-- gh-comment-id:1374519148 --> @sewnie commented on GitHub (Jan 7, 2023): i suggest only displaying the link as copying it would require support for Wayland, X11, etc.
Author
Owner

@aome510 commented on GitHub (Jan 18, 2023):

@apprehensions, @noelpilled can you guys test the changes in https://github.com/aome510/spotify-player/pull/110? The copy-link action should be available for all Spotify items. I only tested on macos. The default copy_command on Linux is xsel -ib but feel free to change it by setting copy_command option in app.toml file. For example,

copy_command = { command = "...", args = ["...", "..."] }
<!-- gh-comment-id:1396160870 --> @aome510 commented on GitHub (Jan 18, 2023): @apprehensions, @noelpilled can you guys test the changes in https://github.com/aome510/spotify-player/pull/110? The copy-link action should be available for all Spotify items. I only tested on macos. The default `copy_command` on Linux is `xsel -ib` but feel free to change it by setting `copy_command` option in `app.toml` file. For example, ```toml copy_command = { command = "...", args = ["...", "..."] } ```
Author
Owner

@noelpilled commented on GitHub (Jan 19, 2023):

recently made the switch to nixos & not really in a comfortable place to figure out how to package this myself at the moment so I won’t be able to help :(

<!-- gh-comment-id:1396715720 --> @noelpilled commented on GitHub (Jan 19, 2023): recently made the switch to nixos & not really in a comfortable place to figure out how to package this myself at the moment so I won’t be able to help :(
Author
Owner

@sewnie commented on GitHub (Jan 19, 2023):

@aome510, why did you device to do a copy method via a copy command? why don't you just display the track link and have the terminal handle the copying? anyhoo, xsel should not be used; xclip should, as its the most used and well-known C xclipboard program. you should also provide an example for wayland via wl-copy.

however, since you said i can test:

copy_command = { command = "xclip", args = ["-sel", "c"] }
2023-01-19T11:24:27.311804Z  INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 621ms
2023-01-19T11:24:29.580103Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-01-19T11:24:30.650885Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-01-19T11:24:30.696877Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-01-19T11:24:30.804890Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)

tl;dr, it doesn't work for me. xclip is similar to xsel as it takes in stdin as input by default.

<!-- gh-comment-id:1396828184 --> @sewnie commented on GitHub (Jan 19, 2023): @aome510, why did you device to do a copy method via a copy command? why don't you just display the track link and have the terminal handle the copying? anyhoo, `xsel` should not be used; `xclip` should, as its the most used and well-known C xclipboard program. you should also provide an example for wayland via `wl-copy`. however, since you said i can test: ```toml copy_command = { command = "xclip", args = ["-sel", "c"] } ``` ``` 2023-01-19T11:24:27.311804Z INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 621ms 2023-01-19T11:24:29.580103Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-01-19T11:24:30.650885Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-01-19T11:24:30.696877Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-01-19T11:24:30.804890Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) ``` tl;dr, it doesn't work for me. `xclip` is similar to `xsel` as it takes in stdin as input by default.
Author
Owner

@aome510 commented on GitHub (Jan 19, 2023):

why did you device to do a copy method via a copy command? why don't you just display the track link and have the terminal handle the copying?

I found it not trivial in my case to copy display text from the terminal. Not sure if it was because the text is rendered by TUI library but I couldn't just select it like I do normally with terminal text. That said, imo, most people would prefer to have one-step action to achieve the goal instead of displaying the link, trying to copy it with terminal.

tl;dr, it doesn't work for me. xclip is similar to xsel as it takes in stdin as input by default.

Judging from the log, it seems the app couldn't find xclip from your path. Can you specify the full path in the app.toml config file then try again?

<!-- gh-comment-id:1397185021 --> @aome510 commented on GitHub (Jan 19, 2023): > why did you device to do a copy method via a copy command? why don't you just display the track link and have the terminal handle the copying? I found it not trivial in my case to copy display text from the terminal. Not sure if it was because the text is rendered by TUI library but I couldn't just select it like I do normally with terminal text. That said, imo, most people would prefer to have one-step action to achieve the goal instead of displaying the link, trying to copy it with terminal. > tl;dr, it doesn't work for me. xclip is similar to xsel as it takes in stdin as input by default. Judging from the log, it seems the app couldn't find `xclip` from your path. Can you specify the full path in the `app.toml` config file then try again?
Author
Owner

@aome510 commented on GitHub (Jan 19, 2023):

xsel should not be used; xclip should, as its the most used and well-known C xclipboard program. you should also provide an example for wayland via wl-copy.

I could change it to xclip for linux. I'm not too familiar with wayland though

<!-- gh-comment-id:1397187006 --> @aome510 commented on GitHub (Jan 19, 2023): > xsel should not be used; xclip should, as its the most used and well-known C xclipboard program. you should also provide an example for wayland via wl-copy. I could change it to `xclip` for linux. I'm not too familiar with wayland though
Author
Owner

@sewnie commented on GitHub (Jan 26, 2023):

It supports simply displaying the link.. Right?

<!-- gh-comment-id:1404657958 --> @sewnie commented on GitHub (Jan 26, 2023): It supports simply displaying the link.. Right?
Author
Owner

@noelpilled commented on GitHub (Jan 26, 2023):

Curious what the use case for simply displaying the link is? Aren't the strings pretty long?

<!-- gh-comment-id:1404928869 --> @noelpilled commented on GitHub (Jan 26, 2023): Curious what the use case for simply displaying the link is? Aren't the strings pretty long?
Author
Owner

@aome510 commented on GitHub (Jan 28, 2023):

It supports simply displaying the link.. Right?

No, it uses a default command to copy the link to clipboard. Like I mentioned before, I found it nontrivial to display the link and copy to clipboard using my terminal.

<!-- gh-comment-id:1407264767 --> @aome510 commented on GitHub (Jan 28, 2023): > It supports simply displaying the link.. Right? No, it uses a default command to copy the link to clipboard. Like I mentioned before, I found it nontrivial to display the link and copy to clipboard using my terminal.
Author
Owner

@treeshateorcs commented on GitHub (Sep 7, 2023):

i added

copy_command = { command = "wl-copy", args = [] } # linux

to my config, but i still can't copyTrackLink. when i press 5 nothing happens (not even the menu closes)

<!-- gh-comment-id:1710803684 --> @treeshateorcs commented on GitHub (Sep 7, 2023): i added ``` copy_command = { command = "wl-copy", args = [] } # linux ``` to my config, but i still can't copyTrackLink. when i press 5 nothing happens (not even the menu closes)
Author
Owner

@aome510 commented on GitHub (Sep 9, 2023):

i added

copy_command = { command = "wl-copy", args = [] } # linux

to my config, but i still can't copyTrackLink. when i press 5 nothing happens (not even the menu closes)

Can you check if there is any errors in the application's log (in ~/.cache/spotify_player/)?

<!-- gh-comment-id:1712375354 --> @aome510 commented on GitHub (Sep 9, 2023): > i added > > ``` > copy_command = { command = "wl-copy", args = [] } # linux > ``` > > to my config, but i still can't copyTrackLink. when i press 5 nothing happens (not even the menu closes) Can you check if there is any errors in the application's log (in `~/.cache/spotify_player/`)?
Author
Owner

@treeshateorcs commented on GitHub (Sep 9, 2023):

it says

2023-09-09T11:25:05.900974Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:06.141760Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:06.340173Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:06.496259Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:07.604987Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:07.801972Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:07.996163Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:08.150035Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:27:01.026774Z  INFO spotify_player::streaming: Got an event from the integrated player: TimeToPreloadNextTrack { play_request_id: 0, track_id: SpotifyId { id: 254099813482921766222209309487781320590, audio_type: Track } }
2023-09-09T11:27:02.022980Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 996ms

even though wl-copy is in path

edit 1: even if i write the full path to wl-copy (/usr/bin/wl-copy) it says no such file or directory

edit 2: with the same config on macos everything works fine (except s/wl-copy/pbcopy)

<!-- gh-comment-id:1712489154 --> @treeshateorcs commented on GitHub (Sep 9, 2023): it says ``` 2023-09-09T11:25:05.900974Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:25:06.141760Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:25:06.340173Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:25:06.496259Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:25:07.604987Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:25:07.801972Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:25:07.996163Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:25:08.150035Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) 2023-09-09T11:27:01.026774Z INFO spotify_player::streaming: Got an event from the integrated player: TimeToPreloadNextTrack { play_request_id: 0, track_id: SpotifyId { id: 254099813482921766222209309487781320590, audio_type: Track } } 2023-09-09T11:27:02.022980Z INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 996ms ``` even though wl-copy is in path edit 1: even if i write the full path to wl-copy (/usr/bin/wl-copy) it says no such file or directory edit 2: with the same config on macos everything works fine (except s/wl-copy/pbcopy)
Author
Owner

@aome510 commented on GitHub (Sep 9, 2023):

it says

2023-09-09T11:25:05.900974Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:06.141760Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:06.340173Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:06.496259Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:07.604987Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:07.801972Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:07.996163Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:25:08.150035Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2)
2023-09-09T11:27:01.026774Z  INFO spotify_player::streaming: Got an event from the integrated player: TimeToPreloadNextTrack { play_request_id: 0, track_id: SpotifyId { id: 254099813482921766222209309487781320590, audio_type: Track } }
2023-09-09T11:27:02.022980Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 996ms

even though wl-copy is in path

edit 1: even if i write the full path to wl-copy (/usr/bin/wl-copy) it says no such file or directory

edit 2: with the same config on macos everything works fine (except s/wl-copy/pbcopy)

interesting, can you provide a complete log as well? I want to make sure that the copy_command is correctly configured.

<!-- gh-comment-id:1712563498 --> @aome510 commented on GitHub (Sep 9, 2023): > > it says > > ``` > 2023-09-09T11:25:05.900974Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:25:06.141760Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:25:06.340173Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:25:06.496259Z ERROR terminal_event{event=Key(KeyEvent { code: Char('5'), modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:25:07.604987Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:25:07.801972Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:25:07.996163Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:25:08.150035Z ERROR terminal_event{event=Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE })}: spotify_player::event: Failed to handle event: No such file or directory (os error 2) > 2023-09-09T11:27:01.026774Z INFO spotify_player::streaming: Got an event from the integrated player: TimeToPreloadNextTrack { play_request_id: 0, track_id: SpotifyId { id: 254099813482921766222209309487781320590, audio_type: Track } } > 2023-09-09T11:27:02.022980Z INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 996ms > ``` > > even though wl-copy is in path > > edit 1: even if i write the full path to wl-copy (/usr/bin/wl-copy) it says no such file or directory > > edit 2: with the same config on macos everything works fine (except s/wl-copy/pbcopy) interesting, can you provide a complete log as well? I want to make sure that the `copy_command` is correctly configured.
Author
Owner

@treeshateorcs commented on GitHub (Sep 9, 2023):

@aome510 hmmm, it isn't!

2023-09-09T17:44:41.506603Z INFO spotify_player: General configurations: AppConfig { theme: "dracula", client_id: "######", client_port: 8080, copy_command: Command { command: "xclip", args: ["-sel", "c"] }, playback_format: "{track} • {artists}\n{album}\n{metadata}", notify_format: NotifyFormat { summary: "{track} • {artists}", body: "{album}" }, tracks_playback_limit: 50, proxy: None, ap_port: None, app_refresh_duration_in_ms: 32, playback_refresh_duration_in_ms: 0, page_size_in_rows: 20, track_table_item_max_len: 32, play_icon: "▶", pause_icon: "▌▌", liked_icon: "♥", border_type: Plain, progress_bar_type: Rectangle, playback_window_position: Top, playback_window_width: 6, enable_media_control: true, enable_streaming: true, enable_cover_image_cache: true, default_device: "spotify-player", device: DeviceConfig { name: "fedora", device_type: "speaker", volume: 100, bitrate: 320, audio_cache: true } }

and here's my config

client_id = "#####"

[device]
name = "fedora"
volume = 100
bitrate = 320
audio_cache = true
copy_command = { command = "/usr/bin/wl-copy", args = [] } # linux

just to make sure it's in the correct place - /home/tho/.config/spotify-player/app.toml

edit 1: okay i've found the culprit copy_command should be at the top level, not at device

<!-- gh-comment-id:1712564816 --> @treeshateorcs commented on GitHub (Sep 9, 2023): @aome510 hmmm, it isn't! > 2023-09-09T17:44:41.506603Z INFO spotify_player: General configurations: AppConfig { theme: "dracula", client_id: "######", client_port: 8080, copy_command: Command { command: "xclip", args: ["-sel", "c"] }, playback_format: "{track} • {artists}\n{album}\n{metadata}", notify_format: NotifyFormat { summary: "{track} • {artists}", body: "{album}" }, tracks_playback_limit: 50, proxy: None, ap_port: None, app_refresh_duration_in_ms: 32, playback_refresh_duration_in_ms: 0, page_size_in_rows: 20, track_table_item_max_len: 32, play_icon: "▶", pause_icon: "▌▌", liked_icon: "♥", border_type: Plain, progress_bar_type: Rectangle, playback_window_position: Top, playback_window_width: 6, enable_media_control: true, enable_streaming: true, enable_cover_image_cache: true, default_device: "spotify-player", device: DeviceConfig { name: "fedora", device_type: "speaker", volume: 100, bitrate: 320, audio_cache: true } } and here's my config ``` client_id = "#####" [device] name = "fedora" volume = 100 bitrate = 320 audio_cache = true copy_command = { command = "/usr/bin/wl-copy", args = [] } # linux ``` just to make sure it's in the correct place - /home/tho/.config/spotify-player/app.toml edit 1: okay i've found the culprit `copy_command` should be at the top level, not at `device`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#974
No description provided.