Skip to main content

pipewire switch headphone/speaker (port)

switch with pactl

pactl set-sink-port 0 analog-output-headphones

pactl set-sink-port 0 analog-output-speaker


pactl list | grep "Active Port"
 Active Port: analog-output-speaker
 Active Port: analog-input-headset-mic


 find ports name

pactl list sinks

Sink #52
    State: SUSPENDED
    Name: alsa_output.pci-0000_00_1f.3.analog-stereo

 Ports:
        analog-output-speaker: Speakers (type: Speaker, priority: 10000, availability group: Legacy 3, availability unknown)
        analog-output-headphones: Headphones (type: Headphones, priority: 9900, availability group: Legacy 2, availability unknown)
    Active Port: analog-output-headphones

 

see in ports:


pactl list sinks short
52    alsa_output.pci-0000_00_1f.3.analog-stereo    PipeWire    s32le 2ch 48000Hz    SUSPENDED


man pactl

 set-sink-port SINK PORT
              Set the specified sink (identified by its symbolic name or
              numerical index) to the specified port (identified by its
              symbolic name).




oldconfig

 bindsym $mod1+slash exec  pactl set-sink-port 0 analog-output-headphones


bindsym $mod1+shift+slash exec  pactl set-sink-port 0 analog-output-speaker

 

sink new name is  SINK=alsa_output.pci-0000_00_1f.3.analog-stereo 

 

using proaudio sink 

 pactl set-sink-port alsa_output.pci-0000_00_1f.3.pro-output-0  analog-output-headphones

pactl set-sink-port alsa_output.pci-0000_00_1f.3.pro-output-0  analog-output-speaker 

 

pactl set-sink-port alsa_output.pci-0000_00_1f.3.analog-stereo analog-output-headphones

pactl set-sink-port alsa_output.pci-0000_00_1f.3.analog-stereo analog-output-speaker

 

instead of alsa_output.pci-0000_00_1f.3.analog-stereo u can use  0 

 

nano ~/.local/bin/switch_output

--------------------------------------------------

 if [[ $(pactl list | grep "Active Port: analog-output") == *"headphones"* ]]; then
    pactl set-sink-port 0 analog-output-speaker
else
    pactl set-sink-port 0 analog-output-headphones
fi

------------------------------------------------------
set $r_vol exec  pkill -RTMIN+1 i3blocks

bindsym F9 exec switch_output  ; $r_vol

## my dell has free f9 without need to press fn key


##get active port

 pactl list | grep "Active Port: analog-output" | cut -d':' -f 2

 pactl list | grep "Active Port: analog-input" | cut -d':' -f 2

 


i3blocks volume 

--------------------------------------------

#!/bin/sh

# Prints the current volume or 🔇 if muted.
case $BLOCK_BUTTON in
         2) pamixer -t  >>/dev/null ;;
         4)  pamixer -i 5 >>/dev/null ;;
         5)  pamixer -d 5 >>/dev/null ;;
         6) foot -e "$EDITOR" "$0" ;;
 esac


vol=$(pamixer  --get-volume-human)
[ "$vol" = "muted" ] && echo 🔇 && exit


hed=$(pactl list | grep "Active Port: analog-output" | cut -d':' -f 2)
if [[ "$hed" == *"headphones"* ]]; then
 icon="🎧"
fi

if [[ "$hed" == *"speaker"* ]]; then
icon="🔉"
fi


echo "$icon $vol"

------------------------------------------------------------------------------------------------------------


pw-cli list-objects Node

pw-cli list-objects Device 

pw-cli list-objects Port

pw-cli list-objects  

 

pw Ports

id 32, type PipeWire:Interface:Port/3

object.path = "alsa:pcm:0:front:0:playback:playback_0"

port.alias = "ALC3204 Analog:playback_FL"

 

id 42, type PipeWire:Interface:Port/3

object.path = "alsa:pcm:0:front:0:playback:playback_1"

port.alias = "ALC3204 Analog:playback_FR"

 

id 41, type PipeWire:Interface:Port/3

object.path = "alsa:pcm:0:front:0:capture:capture_0"

port.alias = "ALC3204 Analog:capture_FL"

 

id 47, type PipeWire:Interface:Port/3

object.path = "alsa:pcm:0:front:0:capture:capture_1"

port.alias = "ALC3204 Analog:capture_FR"

 

id 43, type PipeWire:Interface:Port/3

object.path = "alsa:pcm:0:front:0:playback:monitor_1"

port.alias = "ALC3204 Analog:monitor_FR"

 

id 44, type PipeWire:Interface:Port/3

object.path = "alsa:pcm:0:front:0:playback:monitor_0"

port.alias = "ALC3204 Analog:monitor_FL"

 


pw Nodes

id 45, type PipeWire:Interface:Node/3

object.path = "alsa:pcm:0:front:0:playback"

node.name = "alsa_output.pci-0000_00_1f.3.analog-stereo"

 

id 46, type PipeWire:Interface:Node/3

object.path = "alsa:pcm:0:front:0:capture"

node.name = "alsa_input.pci-0000_00_1f.3.analog-stereo"

 


pactl get-default-sink

alsa_output.pci-0000_00_1f.3.analog-stereo

 

pactl list sinks
Sink #45

Name: alsa_output.pci-0000_00_1f.3.analog-stereo

Description: Built-in Audio Analog Stereo

Monitor Source: alsa_output.pci-0000_00_1f.3.analog-stereo.monitor

object.path = "alsa:pcm:0:front:0:playback"

 

device.vendor.id = "0x8086"

device.product.id = "0x34c8"

device.product.name = "Ice Lake-LP Smart Sound Technology Audio Controller"


 

Ports:

analog-output-speaker: Speakers (type: Speaker, priority: 10000, availability group: Legacy 2, availability unknown)

analog-output-headphones: Headphones (type: Headphones, priority: 9900, availability group: Legacy 1, not available)    

Active Port: analog-output-speaker

 

pactl set-sink-volume @DEFAULT_SINK@ +5%

pactl set-sink-volume @DEFAULT_SINK@ -5%

pactl set-sink-mute @DEFAULT_SINK@ toggle

 

pactl set-source-mute @DEFAULT_SOURCE@ toggle 

pactl set-source-volume @DEFAULT_SOURCE@ +5%

pactl set-source-volume @DEFAULT_SOURCE@ -5%

 

 

path=/org/mpris/MediaPlayer2;

org.mpris.MediaPlayer2.Player

 

playerctl alternative with dbus for mpv with mpv-mpris plugin

 dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mpv  /org/mpris/MediaPlayer2  org.mpris.MediaPlayer2.Player.PlayPause

 

org.mpris.MediaPlayer2.Player.PlayPause

org.mpris.MediaPlayer2.Player.Next
org.mpris.MediaPlayer2.Player.Previous
org.mpris.MediaPlayer2.Player.Stop
 

 


src:

https://unix.stackexchange.com/questions/726288/having-trouble-using-cli-to-switch-between-playback-devices-with-pipewire

https://www.kailashkatheth.com.np/2021/06/headphoneearphone-switch-script.html

https://gist.github.com/miyl/40cdf1a66b360ad8ec0b19e2ffa56194 


Comments

Popular posts from this blog

sxhkd volume andbrightness config for dwm on void

xbps-install  sxhkd ------------ mkdir .config/sxhkd cd .config/sxhkd nano/vim sxhkdrc -------------------------------- XF86AudioRaiseVolume         amixer -c 1 -- sset Master 2db+ XF86AudioLowerVolume         amixer -c 1 -- sset Master 2db- XF86AudioMute         amixer -c 1 -- sset Master toggle alt + shift + Escape         pkill -USR1 -x sxhkd XF86MonBrightnessUp          xbacklight -inc 20 XF86MonBrightnessDown          xbacklight -dec 20 ------------------------------------------------------------- amixer -c card_no -- sset Interface volume run alsamixer to find card no and interface names xbps-install -S git git clone https://git.suckless.org/dwm xbps-install -S base-devel libX11-devel libXft-devel libXinerama-devel  vim config.mk # FREETYPEINC = ${X11INC}/freetype2 #comment for non-bsd make clean install   cp config.def.h config.h vim config.h xbps-install -S font-symbola #for emoji on statusbar support     void audio config xbps-i

Hidden Wiki

Welcome to The Hidden Wiki New hidden wiki url 2015 http://zqktlwi4fecvo6ri.onion Add it to bookmarks and spread it!!! Editor's picks Bored? Pick a random page from the article index and replace one of these slots with it. The Matrix - Very nice to read. How to Exit the Matrix - Learn how to Protect yourself and your rights, online and off. Verifying PGP signatures - A short and simple how-to guide. In Praise Of Hawala - Anonymous informal value transfer system. Volunteer Here are five different things that you can help us out with. Plunder other hidden service lists for links and place them here! File the SnapBBSIndex links wherever they go. Set external links to HTTPS where available, good certificate, and same content. Care to start recording onionland's history? Check out Onionland's Museum Perform Dead Services Duties. Introduction Points Ahmia.fi - Clearnet search engine for Tor Hidden Services (allows you

download office 2021 and activate

get office from here  https://tb.rg-adguard.net/public.php open powershell as admin (win+x and a ) type cmd  goto insall dir 1.         cd /d %ProgramFiles(x86)%\Microsoft Office\Office16 2.           cd /d %ProgramFiles%\Microsoft Office\Office16 try 1 or 2 depending on installation  install volume license  for /f %x in ('dir /b ..\root\Licenses16\ProPlus2021VL_KMS*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%x" activate using kms cscript ospp.vbs /setprt:1688 cscript ospp.vbs /unpkey:6F7TH >nul cscript ospp.vbs /inpkey:FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH cscript ospp.vbs /sethst:s8.uk.to cscript ospp.vbs /act Automatic script (windefender may block it) ------------------------------------------------------------------------------------------------------------------- @echo off title Activate Microsoft Office 2021 (ALL versions) for FREE - MSGuides.com&cls&echo =====================================================================================&