Try   HackMD

Alterando sinks do PulseAudio por linha de comando e através do painel do XFCE4

tags: linux pulseaudio shell script xfce

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Instalação

Se estiver no Arch Linux, instale os pacotes xfce4-genmon-plugin e newaita-icons-git:

sudo pikaur -Syu newaita-icons-git xfce4-genmon-plugin

Scripts

Crie as pastas necessárias:

mkdir -p ~/bin/ ~/.config/xfce4/scripts/

Crie o script em ~/bin/select-sinks.sh:

#!/usr/bin/env bash

sink=$(pactl list short sinks | awk 'NR==1{print $2}')
active=$(LANG=C pactl list sinks | awk '{if ($1 == "Active" && $2 == "Port:") {gsub(/[ \t]+$/, "", $2);print $3; exit;}}')

port_one=$(LANG=C pactl list sinks | awk '/Ports/{getline;gsub(":","");gsub(/[ \t]+$/, "", $2);print $1;}')
port_two=$(LANG=C pactl list sinks | awk '/Ports/{getline;getline;gsub(":","");gsub(/[ \t]+$/, "", $2);print $1;}')

if [[ $port_one == *"$active"* ]]; then
    pacmd set-sink-port $sink $port_two
    exit 0
fi

if [[ $port_two == *"$active"* ]]; then
    pacmd set-sink-port $sink $port_one
    exit 0
fi

Em seguida outro em ~/.config/xfce4/scripts/sinks.sh:

#!/usr/bin/env bash

sink=$(pactl list short sinks | awk 'NR==1{print $2}')
active=$(LANG=C pactl list sinks | awk '{if ($1 == "Active" && $2 == "Port:") {print $3; exit;}}')
icon="/usr/share/icons/Newaita-dark/devices/22/audio-headset.svg"

if [[ $active != *"headphones"* ]]; then
	icon="/usr/share/icons/Newaita-dark/.DP/22/speaker.svg"
fi

echo "<img>${icon}</img>"
echo "<click>bash -c $HOME/bin/select-sink.sh</click>"

Configuração

Clique com o direito na barra de tarefas do XFCE e vá em Painel > Adicionar novos itens...:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Selecione Monitor genérico e clique em Adicionar:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

No novo item que será criado, clique com o botão direito e vá em Propriedades:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Em Comando adicione o seguinte comando:

bash -c "$HOME/.config/xfce4/scripts/sinks.sh"

Desmarque Rótulo e Período(s) deixe em 10,00 depois clique em Salvar:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Resultado

Altofalante Headset
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Ajude

Se esse artigo foi útil pra você de alguma maneira(eu espero que sim

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
) considere doar um valor simbólico ou me patrocinar para que eu possa ajudar sempre mais.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →