4 ms·
Only slightly OT; does anyone have a solution for playing audio from ssh? The best I have so far is to pick a program that I know is under X (here xterm) and r
by aidenn0 4y ago
Only slightly OT; does anyone have a solution for playing audio from ssh? The best I have so far is to pick a program that I know is under X (here xterm) and run something like:
eval "env $(cat /proc/"$(pgrep -n xterm)"/environ |xargs -0 -n1 printf '%q ') bash"
To get the environment setup right.
- jraph 4y ago(edit: I might have misunderstood your comment, but see my edit at the end) If you use PulseAudio or pipewire-pulse on your local computer and that both computers are on the same network (or at least the machine you ssh into can access your local machine, possibly through a tunnel - PulseAudio listen to port 4713 by default), you can set the PULSE_SERVER environment variable. PULSE_SERVER=X.X.X.X whatever_should_play_a_sound Where X.X.X.X is the domain or IP of your local machine. Your local machine needs to be configured to allow remote computers to play sound locally (by loading module module-native-protocol-tcp as far as I know - a papref setting is available for PulseAudio). If the computer you ssh into has Pulseaudio or pipewire-pulse, on your local machine you can run: PULSE_SERVER=Y.Y.Y.Y pavucontrol Where Y.Y.Y.Y is your ssh server, and set the default output sink to your local computer's. Then it will play things through your local computer. You need to setup your local computer so it advertises its PulseAudio service, and your server needs to have the module-zeroconf-discover module loaded. You can load a module with pactl (for both PulseAudio or pipewire-pulse): pactl load-module module-zeroconf-discover pactl load-module module-native-protocol-tcp listen=0.0.0.0 edit: and if you just want to play something on your remote machine, then `PULSE_SERVER=localhost` can work. export $(dbus-launch) instead of your command possibly works too. With Pipewire on Debian I noticed it works out of the box though.
- aidenn0 4y agoYou are misunderstanding; I want to play audio on the remote machine, not on the local machine. The remote machine is running pipewire-pulse.
- deleted 4y ago[deleted]
- jraph 4y agoYes sorry, I figured it out before seeing your comment and edited my reply. PULSE_SERVER=localhost or export $(dbus-launch) could work.
- aidenn0 4y agoAha, I found more details, and also think I've solved it: 1. I misremembered it was an alsa-client that couldn't use the pipewire virtual device. 2. your mention of dbus did help though; setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus seems to do the trick.
- hecanjog 4y agoI usually just mount the remote drive with sshfs and play the audio locally. This pulseaudio approach might work with pipewire too -- I haven't tested it but I love this text-mode audio player... https://mathr.co.uk/harry/#sound https://mathr.co.uk/harry/#sound
- deleted 4y ago[deleted]
- wereallterrrist 4y agoMan, how much are distros + bad user config hurting user "Linux" reports. Thank god for NixOS where (1) we do a decent job of base config and (2) user config errors are basically trivially identifiable. 1. Open `pulsemixer` to monitor pulse clients 2. `ssh localhost "pacat < /dev/urandom"` Observe that pacat is showing as a pulse client. This stuff is really easy and should absolutely just work.
- yjftsjthsd-h 4y agoDid you reply to the wrong comment? This doesn't seem relevant to remote audio
- wereallterrrist 4y agoUm, it's just an example? Does this somehow help? 1. (term1) `ssh remote pulsemixer` 2. (term2) `ssh remote "pacat </dev/urandom"` Observe that (1) you can see a new client appear on the remote, and (2) audio will play from the default playback device on the remote (and you can trivially change that device with `pulsemixer`) EDIT: for your speakers/ears-sake, I recommend turning down the default playback device before doing this.
- aidenn0 4y agoI'm running nixos (22.05), and I can't run alsa clients to the pipewire alsa device on the remote machine over ssh without setting the "correct" environment variables (I have yet to identify them, so I use what I posted to clone the environment of an X program).
- Arnavion 4y agohttps://news.ycombinator.com/item?id=30621077 https://news.ycombinator.com/item?id=30621077 (And yes, I use pipewire. The socket is pipewire-pulse's.)