using media keys in ip netns

0

So im running Debian 9 with KDE, and since Spotify doesn't support offline mode, I just made a new namespace (ip netns add jail), and just run Spotify in this ns (ip netns exec jail su user -c spotify), but when I do this the media keys wont work (play, next, etc).
Any ideas are appreciated

ImGunther

Posted 2017-11-06T14:11:43.570

Reputation: 1

1You added a veth pair to communicate with the main namespace? Your main namespace does routing/NAT, whatever is required? – dirkt – 2017-11-06T15:22:37.307

I now tried doing that for multiple days but couldn't get it to work, could you help me out? I tried searching but sadly I think I'm too low level.. – ImGunther – 2017-11-10T18:41:36.223

Answers

0

Here is a small bash script to create a new namespace, setup an veth-pair, and launch an xterm in that namespace:

#!/bin/bash

# Setup network namespace with veth pair, start xterm in it

# nsterm ns0 veth0 10.0.0 yellow 24

if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

NS=${1:-ns0}
DEV=${2:-veth0}
DEV_A=${DEV}a
DEV_B=${DEV}b
ADDR=${3-:10.0.0}
ADDR_A=${ADDR}.254
ADDR_B=${ADDR}.1
MASK=${5:-24}
COL=${4:-yellow}

# echo ns=$NS dev=$DEV col=$COL mask=$MASK

ip netns add $NS
ip link add $DEV_A type veth peer name $DEV_B netns $NS
ip addr add $ADDR_A/$MASK dev $DEV_A
ip link set ${DEV}a up
ip netns exec $NS ip addr add $ADDR_B/$MASK dev $DEV_B
ip netns exec $NS ip link set ${DEV}b up
ip netns exec $NS ip route add default via $ADDR_A dev $DEV_B
ip netns exec $NS su -c "xterm -bg $COL &" your_userid

Replace your_userid in last line with your user id, so su can change to that. Use ip addr and ip route both in that xterm and in some other terminal to understand the network configuration.

Now run xev from the new xterm, and verify that the media keys work (there's really no reason they shouldn't, the keys themselves are totally unrelated to network namespaces).

The network namespace acts like a separate little computer inside your computer, so you still have to make your "real" computer (main namespace) connect it to your router somehow, e.g. by using NAT on veth0a (google for tutorials: you need to enable forwarding, and masquerade iptables rules).

Test that the new namespace is successfully connected to your router with ping google.com (or whatever).

Finally, try to launch spotify from the new xterm. If the above tests are all successful, it should work.

dirkt

Posted 2017-11-06T14:11:43.570

Reputation: 11 627

Thanks for such well done instruction! Sadly it still wont quite work..
ip addr shows the script worked, ip route in xterm doesnt output anything though.
Xev shows that the keystrokes are registered, but it has no effect on spotify..
I really appreciate your help though, if I manage to somehow get it to work I'll post it here
– ImGunther – 2017-11-15T21:00:50.217