mirror of https://github.com/artizirk/dotfiles
Arti Zirk
8 months ago
7 changed files with 50 additions and 457 deletions
@ -1,19 +0,0 @@ |
|||||||
#!/bin/sh |
|
||||||
# src: https://codeberg.org/trill/dotfiles/src/branch/master/.local/bin/i3blocks/pipewire-sink.sh |
|
||||||
|
|
||||||
# `pactl list sinks` shows sink properties with a mix of english language and local language |
|
||||||
# defined by LANG env var, so we unset the var to guarantee only the fallback language is used |
|
||||||
unset LANG; |
|
||||||
sink_list="$(wpctl status | sed -n '/^Audio/,/Sink endpoints:/p' | sed -n '/Sinks:/,/|\s*$/p' | head -n -2 | tail -n +2 | tr -d '│')" |
|
||||||
|
|
||||||
|
|
||||||
CONTENT="$sink_list" |
|
||||||
OPTION_SELECTED=$(echo "$CONTENT" \ |
|
||||||
| rofi -dmenu -location 2 \ |
|
||||||
| sed -e 's/[^0-9]*\([0-9]*\).*/\1/g') |
|
||||||
|
|
||||||
echo "" |
|
||||||
if ! [[ -z "$OPTION_SELECTED" ]]; then |
|
||||||
wpctl set-default "$OPTION_SELECTED" |
|
||||||
fi |
|
||||||
|
|
@ -1,11 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
|
|
||||||
SELECTED=$(pactl list short sinks |\ |
|
||||||
awk '{print $1 " " $2 " " $7}' |\ |
|
||||||
column -t |\ |
|
||||||
sort -k3 -r |\ |
|
||||||
rofi -dmenu -i |\ |
|
||||||
awk '{print $2}' |
|
||||||
) |
|
||||||
echo $SELECTED |
|
||||||
pactl set-default-sink $SELECTED |
|
@ -0,0 +1,49 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
# Borrowed from |
||||||
|
# https://github.com/LukeSmithxyz/voidrice/blob/7a96fb100cf385e05c211937b509d2bf166299e6/.local/bin/statusbar/sb-volume |
||||||
|
|
||||||
|
# Prints the current volume or 🔇 if muted. |
||||||
|
|
||||||
|
function select_output { |
||||||
|
local NEW_OUTPUT SINKS |
||||||
|
NEW_OUTPUT=$(pw-dump | jq -r '.[] | select(.info.props."media.class"=="Audio/Sink") | "\(.id)\t\(.info.props."node.description")"' | rofi -dmenu -display-columns 2 -p "Select Audio Output" -location 2 | sed -e 's/[^0-9]*\([0-9]*\).*/\1/g') |
||||||
|
if ! [[ -z "$NEW_OUTPUT" ]]; then |
||||||
|
wpctl set-default "$NEW_OUTPUT" |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
case $BLOCK_BUTTON in |
||||||
|
1) select_output ;; |
||||||
|
2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; |
||||||
|
4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;; |
||||||
|
5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;; |
||||||
|
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. |
||||||
|
- Middle click to mute. |
||||||
|
- Scroll to change." ;; |
||||||
|
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; |
||||||
|
esac |
||||||
|
|
||||||
|
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" |
||||||
|
|
||||||
|
# If muted, print 🔇 and exit. |
||||||
|
[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit |
||||||
|
|
||||||
|
vol="${vol#Volume: }" |
||||||
|
|
||||||
|
split() { |
||||||
|
# For ommiting the . without calling and external program. |
||||||
|
IFS=$2 |
||||||
|
set -- $1 |
||||||
|
printf '%s' "$@" |
||||||
|
} |
||||||
|
|
||||||
|
vol="$(printf "%.0f" "$(split "$vol" ".")")" |
||||||
|
|
||||||
|
case 1 in |
||||||
|
$((vol >= 70)) ) icon="🔊" ;; |
||||||
|
$((vol >= 30)) ) icon="🔉" ;; |
||||||
|
$((vol >= 1)) ) icon="🔈" ;; |
||||||
|
* ) echo 🔇 && exit ;; |
||||||
|
esac |
||||||
|
|
||||||
|
echo "$icon$vol%" |
@ -1,71 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info> |
|
||||||
# Copyright (C) 2014 Alexander Keller <github@nycroth.com> |
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify |
|
||||||
# it under the terms of the GNU General Public License as published by |
|
||||||
# the Free Software Foundation, either version 3 of the License, or |
|
||||||
# (at your option) any later version. |
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful, |
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
# GNU General Public License for more details. |
|
||||||
|
|
||||||
# You should have received a copy of the GNU General Public License |
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||||
|
|
||||||
#------------------------------------------------------------------------ |
|
||||||
|
|
||||||
# The second parameter overrides the mixer selection |
|
||||||
# For PulseAudio users, use "pulse" |
|
||||||
# For Jack/Jack2 users, use "jackplug" |
|
||||||
# For ALSA users, you may use "default" for your primary card |
|
||||||
# or you may use hw:# where # is the number of the card desired |
|
||||||
MIXER="default" |
|
||||||
[ -n "$(lsmod | grep pulse)" ] && MIXER="pulse" |
|
||||||
[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" |
|
||||||
MIXER="${2:-$MIXER}" |
|
||||||
|
|
||||||
# The instance option sets the control to report and configure |
|
||||||
# This defaults to the first control of your selected mixer |
|
||||||
# For a list of the available, use `amixer -D $Your_Mixer scontrols` |
|
||||||
SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | |
|
||||||
sed -n "s/Simple mixer control '\([A-Za-z ]*\)',0/\1/p" | |
|
||||||
head -n1 |
|
||||||
)}" |
|
||||||
|
|
||||||
# The first parameter sets the step to change the volume by (and units to display) |
|
||||||
# This may be in in % or dB (eg. 5% or 3dB) |
|
||||||
STEP="${1:-5%}" |
|
||||||
|
|
||||||
#------------------------------------------------------------------------ |
|
||||||
|
|
||||||
capability() { # Return "Capture" if the device is a capture device |
|
||||||
amixer -D $MIXER get $SCONTROL | |
|
||||||
sed -n "s/ Capabilities:.*cvolume.*/Capture/p" |
|
||||||
} |
|
||||||
|
|
||||||
volume() { |
|
||||||
amixer -D $MIXER get $SCONTROL $(capability) |
|
||||||
} |
|
||||||
|
|
||||||
format() { |
|
||||||
perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' |
|
||||||
perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "' |
|
||||||
# If dB was selected, print that instead |
|
||||||
perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1') |
|
||||||
perl_filter+='"; exit}' |
|
||||||
perl -ne "$perl_filter" |
|
||||||
} |
|
||||||
|
|
||||||
#------------------------------------------------------------------------ |
|
||||||
|
|
||||||
case $BLOCK_BUTTON in |
|
||||||
1) ~/.bin/rofi_set_default_sink.sh ;; |
|
||||||
3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute |
|
||||||
4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase |
|
||||||
5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease |
|
||||||
esac |
|
||||||
|
|
||||||
volume | format |
|
Loading…
Reference in new issue