Page 8 of 10

Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Mon Oct 16, 2023 4:58 pm
by Sofiya
geo_c wrote: Mon Oct 16, 2023 4:21 pm

I cleaned up this hotkey splash screen quite a bit, corrected some typos, added all the key bindings that are in my 4.4 system, and made a few variations of colors, all with DejaVu Mono bold 9. Attached is an actual .gz with the files, including the keybinding-config

One more note, my keybinding to launch the splash screen ( MOD+MOD1+k) is configured in spectrwm.conf to look for /root/Startup/Spectr-hotkeys.sh

If you don't want the splash in startup but still want to launch it with MOD+MOD1+k, just change the path to your location.

Spectr-hotkeys-colors.tar.gz

@geo_c You are great, the main thing is to push you in the right direction :thumbup2: You measured the dimensions so clearly that the config looks like a glove.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Mon Oct 16, 2023 5:14 pm
by geo_c
Sofiya wrote: Mon Oct 16, 2023 4:58 pm

@geo_c You are great, the main thing is to push you in the right direction :thumbup2: You measured the dimensions so clearly that the config looks like a glove.

I actually have a good eyeball for centered text.

Except why now after I finish it up do I notice that I have MOD1 for Alt in the first section, and every entry after says ALT?

That's the kind of stuff that keeps me from writing actual code.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Mon Oct 16, 2023 5:30 pm
by Sofiya
geo_c wrote: Mon Oct 16, 2023 5:14 pm
Sofiya wrote: Mon Oct 16, 2023 4:58 pm

@geo_c You are great, the main thing is to push you in the right direction :thumbup2: You measured the dimensions so clearly that the config looks like a glove.

I actually have a good eyeball for centered text.

Except why now after I finish it up do I notice that I have MOD1 for Alt in the first section, and every entry after says ALT?

That's the kind of stuff that keeps me from writing actual code.

what you wrote is what is displayed ;)


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Mon Oct 16, 2023 5:44 pm
by geo_c
Sofiya wrote: Mon Oct 16, 2023 5:30 pm

what you wrote is what is displayed ;)

Yes, it works. I like to see consistency though. I think in the list "Alt "is easier to pick out. Whereas using "Super" for MOD just clutters the screen, "Alt" for MOD1 is easier to read.

EDIT: I see I misunderstood you! Now I get, it's a computer, it does what I type into it!

When I get time I'm going to clean that up and make it consistent, maybe even add a background image.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 3:30 am
by geo_c

I think I've got this Hotkey splash screen pretty clear looking now. Changed all the MOD1 references to ALT. Made a few little text adjustments to make it more user friendly, like adding top lines with "Reopen This Window = MOD+ALT+k" and "Drag This Window = MOD+MouseButtonL" to minimize frustration for anyone trying it the first time. I'd like to tweak the colors, but these seem to work for now.

Include in the zip are two folders, one set with fontsize=9, the other fontsize=12 for those with high resolution monitors. 12 works on this machine very well.

hotkeys-colors.tar.gz
(2.95 KiB) Downloaded 49 times

Image

Image


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 12:40 pm
by rockedge

Really nice!

I am trying to keep up putting all of the advancements and new polish into one rootfs! Good is I can make one KLV-spectr_rootfs that can just be swapped into a KLV-Spectr-beta3 (for example) and KLV-Spectr-RT.

the beta3 is uploaded to the usual place and sports a Void Linux kernel 6.5.7_1 and the RT version can fly with full real time kernels 6.1.38-rt13 or 6.5.2-rt8. As usual the kernels can be swapped into any KLV variant.

@Sofiya Now for the part where we stuff all of it into a PLUG and perhaps a script to automate an assembly of KLV-Spectr-xxxx...... :ugeek:

my_photo-5-400px.jpg
my_photo-5-400px.jpg (19.55 KiB) Viewed 5530 times

I will upload a decent KLV-Spectr-RT ISO later today (planned but who really knows?)........


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 1:16 pm
by wiak

Is it cold where you are right now rockedge? Wooly hat.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 1:42 pm
by rockedge

@wiak It's starting to get chilly......and waiting to until at least Oct 31 to turn on the furnace which is fueled with oil. We are awaiting a Nor'Easter storm coming in from the North Atlantic and even though it's sunny right now....(nice in the sun actually) it's a bit chilly on my older bones to sit in front of the machines and in the typical Hamburg harbor style a wool blue hat makes it seem not that bad........and does promote the willingness to make some good hot coffee in the kitchen...........

plus I should be outside raking leaves though I did clear the house roof yesterday......but I gotta combine the new tech into one good PLUG.....


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 2:01 pm
by geo_c
rockedge wrote: Tue Oct 17, 2023 12:40 pm

Really nice!

I am trying to keep up putting all of the advancements and new polish into one rootfs! Good is I can make one KLV-spectr_rootfs that can just be swapped into a KLV-Spectr-beta3 (for example) and KLV-Spectr-RT.

the beta3 is uploaded to the usual place and sports a Void Linux kernel 6.5.7_1 and the RT version can fly with full real time kernels 6.1.38-rt13 or 6.5.2-rt8. As usual the kernels can be swapped into any KLV variant.

@Sofiya Now for the part where we stuff all of it into a PLUG and perhaps a script to automate an assembly of KLV-Spectr-xxxx...... :ugeek:
my_photo-5-400px.jpg

I will upload a decent KLV-Spectr-RT ISO later today (planned but who really knows?)........

Glad I could contribute something! If we'd like to put some information in a welcome splash, I could work on that also. It might be something we could use on other KL variants.

EDIT It occurs to me that I didn't include a typical light foreground, dark gray background colorscheme, I'll add one orr two of those to match most dark gtk themes.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 3:58 pm
by rockedge
geo_c wrote:

dark gray background colorscheme........

Here is me pondering how I'm going to make a selector mechanism for the different looks so it's easy for a user to choose which to use......

my_photo-9-320px.jpg
my_photo-9-320px.jpg (14.16 KiB) Viewed 5480 times

I did a bit of lighting to enhance the effect...

Also working with a script that I hope will help improve the audio volume display when using pipewire. which does not show the volume percentage value, just the percent sign.

missing_vol_pipewire.png
missing_vol_pipewire.png (5.88 KiB) Viewed 5473 times

pulseaudio-control.bash

Code: Select all

#!/usr/bin/env bash

##################################################################
# Polybar Pulseaudio Control                                     #
# https://github.com/marioortizmanero/polybar-pulseaudio-control #
##################################################################

# Deprecated values, to be removed in a next release. This is kept around to
# be displayed for users using it in custom FORMAT
# shellcheck disable=SC2034
ICON_SINK="Replaced by ICON_NODE, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0"
SINK_NICKNAME="Replaced by NODE_NICKNAME, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0"

# Defaults for configurable values, expected to be set by command-line arguments
AUTOSYNC="no"
COLOR_MUTED="%{F#6b6b6b}"
ICON_MUTED=
ICON_NODE=
NODE_TYPE="output"
NOTIFICATIONS="no"
OSD="no"
NODE_NICKNAMES_PROP=
VOLUME_STEP=2
VOLUME_MAX=130
LISTEN_TIMEOUT=0.05
# shellcheck disable=SC2016
FORMAT='$VOL_ICON ${VOL_LEVEL}%  $ICON_NODE $NODE_NICKNAME'
declare -A NODE_NICKNAMES
declare -a ICONS_VOLUME
declare -a NODE_BLACKLIST

# Special variable: within the script, pactl, grep, and awk commands are used
# on sinks or sources, depending on NODE_TYPE.
#
# The commands are almost always the same, except for the sink/source part.
# In order to reduce duplication, this variable is used for commands that behave
# the same, regardless of the NODE_TYPE.
#
# Having only the "radix" (ink/ource) and omitting the first letter enables us
# to use that single variable:
#
#   S-ink  , s-ink  , s-ink  -s, S-ink -s
#   S-ource, s-ource, s-ource-s, S-ource-s
SINK_OR_SOURCE="ink"

# Environment & global constants for the script
export LC_ALL=C  # Some calls depend on English outputs of pactl
END_COLOR="%{F-}"  # For Polybar colors


# Saves the currently default node into a variable named `curNode`. It will
# return an error code when pulseaudio isn't running.
function getCurNode() {
    if ! pactl info &>/dev/null; then return 1; fi
    local curNodeName

    curNodeName=$(pactl info | awk "/Default S${SINK_OR_SOURCE}: / {print \$3}")
    curNode=$(pactl list "s${SINK_OR_SOURCE}s" | grep -B 4 -E "Name: $curNodeName\$" | sed -nE "s/^S${SINK_OR_SOURCE} #([0-9]+)$/\1/p")
}


# Saves the node passed by parameter's volume into a variable named `VOL_LEVEL`.
function getCurVol() {
    VOL_LEVEL=$(pactl list "s${SINK_OR_SOURCE}s" | grep -A 15 -E "^S${SINK_OR_SOURCE} #$1\$" | grep 'Volume:' | grep -E -v 'Base Volume:' | awk -F : '{print $3; exit}' | grep -o -P '.{0,3}%' | sed 's/.$//' | tr -d ' ')
}


# Saves the name of the node passed by parameter into a variable named
# `nodeName`.
function getNodeName() {
    nodeName=$(pactl list "s${SINK_OR_SOURCE}s" short | awk -v sink="$1" "{ if (\$1 == sink) {print \$2} }")
    portName=$(pactl list "s${SINK_OR_SOURCE}s" | grep -e "S${SINK_OR_SOURCE} #" -e 'Active Port: ' | sed -n "/^S${SINK_OR_SOURCE} #$1\$/,+1p" | awk '/Active Port: / {print $3}')
}


# Saves the name to be displayed for the node passed by parameter into a
# variable called `NODE_NICKNAME`.
# If a mapping for the node name exists, that is used. Otherwise, the string
# "Node #<index>" is used.
function getNickname() {
    getNodeName "$1"
    unset NODE_NICKNAME

    if [ -n "$nodeName" ] && [ -n "$portName" ] && [ -n "${NODE_NICKNAMES[$nodeName/$portName]}" ]; then
        NODE_NICKNAME="${NODE_NICKNAMES[$nodeName/$portName]}"
    elif [ -n "$nodeName" ] && [ -n "${NODE_NICKNAMES[$nodeName]}" ]; then
        NODE_NICKNAME="${NODE_NICKNAMES[$nodeName]}"
    elif [ -n "$nodeName" ]; then
        # No exact match could be found, try a Glob Match
        for glob in "${!NODE_NICKNAMES[@]}"; do
            # shellcheck disable=SC2053 # Disable Shellcheck warning for Glob-Matching
            if [[ "$nodeName/$portName" == $glob ]] || [[ "$nodeName" == $glob ]]; then
                NODE_NICKNAME="${NODE_NICKNAMES[$glob]}"
                # Cache that result for next time
                NODE_NICKNAMES["$nodeName"]="$NODE_NICKNAME"
                break
            fi
        done
    fi

    if [ -z "$NODE_NICKNAME" ] && [ -n "$nodeName" ] && [ -n "$NODE_NICKNAMES_PROP" ]; then
        getNicknameFromProp "$NODE_NICKNAMES_PROP" "$nodeName"
        # Cache that result for next time
        NODE_NICKNAMES["$nodeName"]="$NODE_NICKNAME"
    elif [ -z "$NODE_NICKNAME" ]; then
        NODE_NICKNAME="S${SINK_OR_SOURCE} #$1"
    fi
}

# Gets node nickname based on a given property.
function getNicknameFromProp() {
    local nickname_prop="$1"
    local for_name="$2"

    NODE_NICKNAME=
    while read -r property value; do
        case "$property" in
            Name:)
                node_name="$value"
                unset node_desc
                ;;
            "$nickname_prop")
                if [ "$node_name" != "$for_name" ]; then
                    continue
                fi
                NODE_NICKNAME="${value:3:-1}"
                break
                ;;
        esac
    done < <(pactl list "s${SINK_OR_SOURCE}s")
}

# Saves the status of the node passed by parameter into a variable named
# `IS_MUTED`.
function getIsMuted() {
    IS_MUTED=$(pactl list "s${SINK_OR_SOURCE}s" | grep -E "^S${SINK_OR_SOURCE} #$1\$" -A 15 | awk '/Mute: / {print $2}')
}


# Saves all the sink inputs of the sink passed by parameter into a string
# named `sinkInputs`.
function getSinkInputs() {
    sinkInputs=$(pactl list sink-inputs | grep -B 4 "Sink: $1" | sed -nE "s/^Sink Input #([0-9]+)\$/\1/p")
}


# Saves all the source outputs of the source passed by parameter into a string
# named `sourceOutputs`.
function getSourceOutputs() {
    sourceOutputs=$(pactl list source-outputs | grep -B 4 "Source: $1" | sed -nE "s/^Source Output #([0-9]+)\$/\1/p")
}


function volUp() {
    # Obtaining the current volume from pulseaudio into $VOL_LEVEL.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    getCurVol "$curNode"
    local maxLimit=$((VOLUME_MAX - VOLUME_STEP))

    # Checking the volume upper bounds so that if VOLUME_MAX was 100% and the
    # increase percentage was 3%, a 99% volume would top at 100% instead
    # of 102%. If the volume is above the maximum limit, nothing is done.
    if [ "$VOL_LEVEL" -le "$VOLUME_MAX" ] && [ "$VOL_LEVEL" -ge "$maxLimit" ]; then
        pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "$VOLUME_MAX%"
    elif [ "$VOL_LEVEL" -lt "$maxLimit" ]; then
        pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "+$VOLUME_STEP%"
    fi

    if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
    if [ $AUTOSYNC = "yes" ]; then volSync; fi
}


function volDown() {
    # Pactl already handles the volume lower bounds so that negative values
    # are ignored.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "-$VOLUME_STEP%"

    if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
    if [ $AUTOSYNC = "yes" ]; then volSync; fi
}


function volSync() {
    # This will only be called if $AUTOSYNC is `yes`.

    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    
    getCurVol "$curNode"
    
    if [[ "$NODE_TYPE" = "output" ]]; then
        getSinkInputs "$curNode"

        # Every output found in the active sink has their volume set to the
        # current one.
        for each in $sinkInputs; do
            pactl "set-sink-input-volume" "$each" "$VOL_LEVEL%"
        done
    else
        getSourceOutputs "$curNode"

        # Every input found in the active source has their volume set to the
        # current one.
        for each in $sourceOutputs; do
            pactl "set-source-output-volume" "$each" "$VOL_LEVEL%"
        done
    fi
}


function volMute() {
    # Switch to mute/unmute the volume with pactl.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    if [ "$1" = "toggle" ]; then
        getIsMuted "$curNode"
        if [ "$IS_MUTED" = "yes" ]; then
            pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no"
        else
            pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes"
        fi
    elif [ "$1" = "mute" ]; then
        pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes"
    elif [ "$1" = "unmute" ]; then
        pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no"
    fi

    if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
}


function nextNode() {
    # The final nodes list, removing the blacklisted ones from the list of
    # currently available nodes.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi

    # Obtaining a tuple of node indexes after removing the blacklisted devices
    # with their name.
    nodes=()
    local i=0
    while read -r line; do
        index=$(echo "$line" | cut -f1)
        name=$(echo "$line" | cut -f2)

        # If it's in the blacklist, continue the main loop. Otherwise, add
        # it to the list.
        for node in "${NODE_BLACKLIST[@]}"; do
            # shellcheck disable=SC2053 # Disable Shellcheck warning for Glob-Matching
            if [[ "$name" == $node ]]; then
                continue 2
            fi
        done

        nodes[i]="$index"
        i=$((i + 1))
    done < <(pactl list short "s${SINK_OR_SOURCE}s" | sort -n)

    # If the resulting list is empty, nothing is done
    if [ ${#nodes[@]} -eq 0 ]; then return; fi

    # If the current node is greater or equal than last one, pick the first
    # node in the list. Otherwise just pick the next node avaliable.
    local newNode
    if [ "$curNode" -ge "${nodes[-1]}" ]; then
        newNode=${nodes[0]}
    else
        for node in "${nodes[@]}"; do
            if [ "$curNode" -lt "$node" ]; then
                newNode=$node
                break
            fi
        done
    fi

    # The new node is set
    pactl "set-default-s${SINK_OR_SOURCE}" "$newNode"

    # Move all audio threads to new node
    local inputs

    if [[ "$NODE_TYPE" = "output" ]]; then
        inputs="$(pactl list short sink-inputs | cut -f 1)"
        for i in $inputs; do
            pactl move-sink-input "$i" "$newNode"
        done
    else
        outputs="$(pactl list short source-outputs | cut -f 1)"
        for i in $outputs; do
            pactl move-source-output "$i" "$newNode"
        done
    fi

    if [ $NOTIFICATIONS = "yes" ]; then
        getNickname "$newNode"

        if command -v dunstify &>/dev/null; then
            notify="dunstify --replace 201839192"
        else
            notify="notify-send"
        fi
        $notify "PulseAudio" "Changed $NODE_TYPE to $NODE_NICKNAME" --icon=audio-headphones-symbolic &
    fi
}


# This function assumes that PulseAudio is already running. It only supports
# KDE OSDs for now. It will show a system message with the status of the
# node passed by parameter, or the currently active one by default.
function showOSD() {
    if [ -z "$1" ]; then
        curNode="$1"
    else
        getCurNode
    fi
    getCurVol "$curNode"
    getIsMuted "$curNode"
    qdbus org.kde.kded /modules/kosd showVolume "$VOL_LEVEL" "$IS_MUTED"
}


function listen() {
    # If this is the first time start by printing the current state. Otherwise,
    # directly wait for events. This is to prevent the module being empty until
    # an event occurs.
    output

    # Listen for changes and immediately create new output for the bar.
    # This is faster than having the script on an interval.
    pactl subscribe 2>/dev/null | grep --line-buffered -e "on \(card\|s${SINK_OR_SOURCE}\|server\)" | {
        while read -r; do
            # Output the new state
            output

            # Read all stdin to flush unwanted pending events, i.e. if there are
            # 15 events at the same time (100ms window), output is only called
            # twice.
            read -r -d '' -t "$LISTEN_TIMEOUT" -n 10000

            # After the 100ms waiting time, output again the state, as it may
            # have changed if the user did an action during the 100ms window.
            output
        done
    }
}


function output() {
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    getCurVol "$curNode"
    getIsMuted "$curNode"

    # Fixed volume icons over max volume
    local iconsLen=${#ICONS_VOLUME[@]}
    if [ "$iconsLen" -ne 0 ]; then
        local volSplit=$((VOLUME_MAX / iconsLen))
        for i in $(seq 1 "$iconsLen"); do
            if [ $((i * volSplit)) -ge "$VOL_LEVEL" ]; then
                VOL_ICON="${ICONS_VOLUME[$((i-1))]}"
                break
            fi
        done
    else
        VOL_ICON=""
    fi

    getNickname "$curNode"

    # Showing the formatted message
    if [ "$IS_MUTED" = "yes" ]; then
        # shellcheck disable=SC2034
        VOL_ICON=$ICON_MUTED
        content="$(eval echo "$FORMAT")"
        if [ -n "$COLOR_MUTED" ]; then
            echo "${COLOR_MUTED}${content}${END_COLOR}"
        else
            echo "$content"
        fi
    else
        eval echo "$FORMAT"
    fi
}


function usage() {
    echo "\
Usage: $0 [OPTION...] ACTION

Terminology: A node represents either a sink (output) or source (input).

Options:
  --autosync | --no-autosync
        Whether to maintain same volume for all programs.
        Default: \"$AUTOSYNC\"
  --color-muted <rrggbb>
        Color in which to format when muted.
        Pass empty string to disable.
        Default: \"${COLOR_MUTED:4:-1}\"
  --notifications | --no-notifications
        Whether to show notifications when changing nodes.
        Default: \"$NOTIFICATIONS\"
  --osd | --no-osd
        Whether to display KDE's OSD message.
        Default: \"$OSD\"
  --icon-muted <icon>
        Icon to use when muted.
        Default: none
  --icon-node <icon>
        Icon to use for node.
        Default: none
  --format <string>
        Use a format string to control the output.
        Remember to pass this argument wrapped in single quotes (\`'\`) instead
        of double quotes (\`\"\`) to avoid your shell from evaluating the
        variables early.
        Available variables:
        * \$VOL_ICON
        * \$VOL_LEVEL
        * \$ICON_NODE
        * \$NODE_NICKNAME
        * \$IS_MUTED (yes/no)
        Default: '$FORMAT'
  --icons-volume <icon>[,<icon>...]
        Icons for volume, from lower to higher.
        Default: none
  --node-type <node_type>
        Whether to consider PulseAudio sinks (output) or sources (input).
        All the operations of pulseaudio-control will apply to one of the two.
        Pass \`input\` for the sources, e.g. a microphone.
        Pass \`output\` for the sinks, e.g. speakers, headphones.
        Default: \"$NODE_TYPE\"
  --volume-max <int>
        Maximum volume to which to allow increasing.
        Default: \"$VOLUME_MAX\"
  --volume-step <int>
        Step size when inc/decrementing volume.
        Default: \"$VOLUME_STEP\"
  --node-blacklist <name>[,<name>...]
        Nodes to ignore when switching. You can use globs. Don't forget to
        quote the string when using globs, to avoid unwanted shell glob
        extension.
        Default: none
  --node-nicknames-from <prop>
        pactl property to use for node names, unless overridden by
        --node-nickname. Its possible values are listed under the 'Properties'
        key in the output of \`pactl list sinks\` and \`pactl list sources\`.
        Default: none
  --node-nickname <name>:<nick>
        Nickname to assign to given node name, taking priority over
        --node-nicknames-from. May be given multiple times, and 'name' is
        exactly as listed in the output of \`pactl list sinks short | cut -f2\`
        and \`pactl list sources short | cut -f2\`.
        Note that you can also specify a port name for the node with
        \`<name>/<port>\`.
        It is also possible to use glob matching to match node and port names.
        Exact matches are prioritized. Don't forget to quote the string when
        using globs, to avoid unwanted shell glob extension.
        Default: none
  --listen-timeout-secs
        The listen command updates the output as soon as it receives an event
        from PulseAudio. However, events are often accompanied by many other
        useless ones, which may result in unnecessary consecutive output
        updates. This script buffers the following events until a timeout is
        reached to avoid this scenario, which lessens the CPU load on events.
        However, this may result in noticeable latency when performing many
        actions quickly (e.g., updating the volume with the mouse wheel). You
        can specify what timeout to use to control the responsiveness, in
        seconds.
        Default: \"$LISTEN_TIMEOUT\"

Actions:
  help              display this message and exit
  output            print the PulseAudio status once
  listen            listen for changes in PulseAudio to automatically update
                    this script's output
  up, down          increase or decrease the default node's volume
  mute, unmute      mute or unmute the default node's audio
  togmute           switch between muted and unmuted
  next-node         switch to the next available node
  sync              synchronize all the output streams volume to be the same as
                    the current node's volume

Author:
    Mario Ortiz Manero
More info on GitHub:
    https://github.com/marioortizmanero/polybar-pulseaudio-control"
}

# Obtains the value for an option and returns 1 if no shift is needed.
function getOptVal() {
    if [[ "$1" = *=* ]]; then
        val="${1//*=/}"
        return 1
    fi

    val="$2"
}

# Parsing the options from the arguments
while [[ "$1" = --* ]]; do
    unset arg
    unset val

    arg="$1"
    case "$arg" in
        --autosync)
            AUTOSYNC=yes
            ;;
        --no-autosync)
            AUTOSYNC=no
            ;;
        --color-muted|--colour-muted)
            if getOptVal "$@"; then shift; fi
            COLOR_MUTED="%{F#$val}"
            ;;
        --notifications)
            NOTIFICATIONS=yes
            ;;
        --no-notifications)
            NOTIFICATIONS=no
            ;;
        --osd)
            OSD=yes
            ;;
        --no-osd)
            OSD=no
            ;;
        --icon-muted)
            if getOptVal "$@"; then shift; fi
            ICON_MUTED="$val"
            ;;
        --icon-node)
            if getOptVal "$@"; then shift; fi
            # shellcheck disable=SC2034
            ICON_NODE="$val"
            ;;
        --icons-volume)
            if getOptVal "$@"; then shift; fi
            IFS=, read -r -a ICONS_VOLUME <<< "${val//[[:space:]]/}"
            ;;
        --volume-max)
            if getOptVal "$@"; then shift; fi
            VOLUME_MAX="$val"
            ;;
        --volume-step)
            if getOptVal "$@"; then shift; fi
            VOLUME_STEP="$val"
            ;;
        --node-blacklist)
            if getOptVal "$@"; then shift; fi
            IFS=, read -r -a NODE_BLACKLIST <<< "${val//[[:space:]]/}"
            ;;
        --node-nicknames-from)
            if getOptVal "$@"; then shift; fi
            NODE_NICKNAMES_PROP="$val"
            ;;
        --node-nickname)
            if getOptVal "$@"; then shift; fi
            NODE_NICKNAMES["${val//:*/}"]="${val//*:}"
            ;;
        --format)
            if getOptVal "$@"; then shift; fi
            FORMAT="$val"
            ;;
        --node-type)
            if getOptVal "$@"; then shift; fi
            if [[ "$val" != "output" && "$val" != "input" ]]; then
                echo "node-type must be 'output' or 'input', got '$val'" >&2
                exit 1
            fi
            NODE_TYPE="$val"
            SINK_OR_SOURCE=$([ "$NODE_TYPE" == "output" ] && echo "ink" || echo "ource")
            ;;
        --listen-timeout-secs)
            if getOptVal "$@"; then shift; fi
            LISTEN_TIMEOUT="$val"
            ;;
        # Deprecated options, to be removed in a next release
        --icon-sink)
            echo "Replaced by --icon-node, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        --sink-blacklist)
            echo "Replaced by --node-blacklist, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        --sink-nicknames-from)
            echo "Replaced by --node-nicknames-from, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        --sink-nickname)
            echo "Replaced by --node-nickname, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        # Undocumented because the `help` action already exists, but makes the
        # help message more accessible.
        --help)
            usage
            exit 0
            ;;
        *)
            echo "Unrecognised option: $arg" >&2
            exit 1
            ;;
    esac
    shift
done

# Parsing the action from the arguments
case "$1" in
    up)
        volUp
        ;;
    down)
        volDown
        ;;
    togmute)
        volMute toggle
        ;;
    mute)
        volMute mute
        ;;
    unmute)
        volMute unmute
        ;;
    sync)
        volSync
        ;;
    listen)
        listen
        ;;
    next-node)
        nextNode
        ;;
    output)
        output
        ;;
    help)
        usage
        ;;
    # Deprecated action, to be removed in a next release
    next-sink)
        echo "Replaced by next-node, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
        exit 1
        ;;
    "")
        echo "No action specified. Run \`$0 help\` for more information." >&2
        ;;
    *)
        echo "Unrecognised action: $1" >&2
        exit 1
        ;;
esac

Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 4:17 pm
by geo_c
rockedge wrote: Tue Oct 17, 2023 3:58 pm
geo_c wrote:

dark gray background colorscheme........

Here is me pondering how I'm going to make a selector mechanism for the different looks so it's easy for a user to choose which to use......

Well, I don't know. First thought is just to include one of these basic dark splashes which will go with a light or dark theme.

Second thought is I could probably create a gxmessage chooser brought up by MOD+ALT+k, which could be annoying in the long run.

Or grep the gtk colors and automatically choose one of maybe 5 available splashes?

That pipewire display script looks ridiculously complicated.

KEYsplash-basicdark.tar.gz
(1.25 KiB) Downloaded 69 times

Image


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 4:30 pm
by Sofiya
rockedge wrote: Tue Oct 17, 2023 3:58 pm
geo_c wrote:

dark gray background colorscheme........

Here is me pondering how I'm going to make a selector mechanism for the different looks so it's easy for a user to choose which to use......
my_photo-9-320px.jpg

I did a bit of lighting to enhance the effect...

Also working with a script that I hope will help improve the audio volume display when using pipewire. which does not show the volume percentage value, just the percent sign.
missing_vol_pipewire.png

pulseaudio-control.bash

Code: Select all

#!/usr/bin/env bash

##################################################################
# Polybar Pulseaudio Control                                     #
# https://github.com/marioortizmanero/polybar-pulseaudio-control #
##################################################################

# Deprecated values, to be removed in a next release. This is kept around to
# be displayed for users using it in custom FORMAT
# shellcheck disable=SC2034
ICON_SINK="Replaced by ICON_NODE, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0"
SINK_NICKNAME="Replaced by NODE_NICKNAME, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0"

# Defaults for configurable values, expected to be set by command-line arguments
AUTOSYNC="no"
COLOR_MUTED="%{F#6b6b6b}"
ICON_MUTED=
ICON_NODE=
NODE_TYPE="output"
NOTIFICATIONS="no"
OSD="no"
NODE_NICKNAMES_PROP=
VOLUME_STEP=2
VOLUME_MAX=130
LISTEN_TIMEOUT=0.05
# shellcheck disable=SC2016
FORMAT='$VOL_ICON ${VOL_LEVEL}%  $ICON_NODE $NODE_NICKNAME'
declare -A NODE_NICKNAMES
declare -a ICONS_VOLUME
declare -a NODE_BLACKLIST

# Special variable: within the script, pactl, grep, and awk commands are used
# on sinks or sources, depending on NODE_TYPE.
#
# The commands are almost always the same, except for the sink/source part.
# In order to reduce duplication, this variable is used for commands that behave
# the same, regardless of the NODE_TYPE.
#
# Having only the "radix" (ink/ource) and omitting the first letter enables us
# to use that single variable:
#
#   S-ink  , s-ink  , s-ink  -s, S-ink -s
#   S-ource, s-ource, s-ource-s, S-ource-s
SINK_OR_SOURCE="ink"

# Environment & global constants for the script
export LC_ALL=C  # Some calls depend on English outputs of pactl
END_COLOR="%{F-}"  # For Polybar colors


# Saves the currently default node into a variable named `curNode`. It will
# return an error code when pulseaudio isn't running.
function getCurNode() {
    if ! pactl info &>/dev/null; then return 1; fi
    local curNodeName

    curNodeName=$(pactl info | awk "/Default S${SINK_OR_SOURCE}: / {print \$3}")
    curNode=$(pactl list "s${SINK_OR_SOURCE}s" | grep -B 4 -E "Name: $curNodeName\$" | sed -nE "s/^S${SINK_OR_SOURCE} #([0-9]+)$/\1/p")
}


# Saves the node passed by parameter's volume into a variable named `VOL_LEVEL`.
function getCurVol() {
    VOL_LEVEL=$(pactl list "s${SINK_OR_SOURCE}s" | grep -A 15 -E "^S${SINK_OR_SOURCE} #$1\$" | grep 'Volume:' | grep -E -v 'Base Volume:' | awk -F : '{print $3; exit}' | grep -o -P '.{0,3}%' | sed 's/.$//' | tr -d ' ')
}


# Saves the name of the node passed by parameter into a variable named
# `nodeName`.
function getNodeName() {
    nodeName=$(pactl list "s${SINK_OR_SOURCE}s" short | awk -v sink="$1" "{ if (\$1 == sink) {print \$2} }")
    portName=$(pactl list "s${SINK_OR_SOURCE}s" | grep -e "S${SINK_OR_SOURCE} #" -e 'Active Port: ' | sed -n "/^S${SINK_OR_SOURCE} #$1\$/,+1p" | awk '/Active Port: / {print $3}')
}


# Saves the name to be displayed for the node passed by parameter into a
# variable called `NODE_NICKNAME`.
# If a mapping for the node name exists, that is used. Otherwise, the string
# "Node #<index>" is used.
function getNickname() {
    getNodeName "$1"
    unset NODE_NICKNAME

    if [ -n "$nodeName" ] && [ -n "$portName" ] && [ -n "${NODE_NICKNAMES[$nodeName/$portName]}" ]; then
        NODE_NICKNAME="${NODE_NICKNAMES[$nodeName/$portName]}"
    elif [ -n "$nodeName" ] && [ -n "${NODE_NICKNAMES[$nodeName]}" ]; then
        NODE_NICKNAME="${NODE_NICKNAMES[$nodeName]}"
    elif [ -n "$nodeName" ]; then
        # No exact match could be found, try a Glob Match
        for glob in "${!NODE_NICKNAMES[@]}"; do
            # shellcheck disable=SC2053 # Disable Shellcheck warning for Glob-Matching
            if [[ "$nodeName/$portName" == $glob ]] || [[ "$nodeName" == $glob ]]; then
                NODE_NICKNAME="${NODE_NICKNAMES[$glob]}"
                # Cache that result for next time
                NODE_NICKNAMES["$nodeName"]="$NODE_NICKNAME"
                break
            fi
        done
    fi

    if [ -z "$NODE_NICKNAME" ] && [ -n "$nodeName" ] && [ -n "$NODE_NICKNAMES_PROP" ]; then
        getNicknameFromProp "$NODE_NICKNAMES_PROP" "$nodeName"
        # Cache that result for next time
        NODE_NICKNAMES["$nodeName"]="$NODE_NICKNAME"
    elif [ -z "$NODE_NICKNAME" ]; then
        NODE_NICKNAME="S${SINK_OR_SOURCE} #$1"
    fi
}

# Gets node nickname based on a given property.
function getNicknameFromProp() {
    local nickname_prop="$1"
    local for_name="$2"

    NODE_NICKNAME=
    while read -r property value; do
        case "$property" in
            Name:)
                node_name="$value"
                unset node_desc
                ;;
            "$nickname_prop")
                if [ "$node_name" != "$for_name" ]; then
                    continue
                fi
                NODE_NICKNAME="${value:3:-1}"
                break
                ;;
        esac
    done < <(pactl list "s${SINK_OR_SOURCE}s")
}

# Saves the status of the node passed by parameter into a variable named
# `IS_MUTED`.
function getIsMuted() {
    IS_MUTED=$(pactl list "s${SINK_OR_SOURCE}s" | grep -E "^S${SINK_OR_SOURCE} #$1\$" -A 15 | awk '/Mute: / {print $2}')
}


# Saves all the sink inputs of the sink passed by parameter into a string
# named `sinkInputs`.
function getSinkInputs() {
    sinkInputs=$(pactl list sink-inputs | grep -B 4 "Sink: $1" | sed -nE "s/^Sink Input #([0-9]+)\$/\1/p")
}


# Saves all the source outputs of the source passed by parameter into a string
# named `sourceOutputs`.
function getSourceOutputs() {
    sourceOutputs=$(pactl list source-outputs | grep -B 4 "Source: $1" | sed -nE "s/^Source Output #([0-9]+)\$/\1/p")
}


function volUp() {
    # Obtaining the current volume from pulseaudio into $VOL_LEVEL.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    getCurVol "$curNode"
    local maxLimit=$((VOLUME_MAX - VOLUME_STEP))

    # Checking the volume upper bounds so that if VOLUME_MAX was 100% and the
    # increase percentage was 3%, a 99% volume would top at 100% instead
    # of 102%. If the volume is above the maximum limit, nothing is done.
    if [ "$VOL_LEVEL" -le "$VOLUME_MAX" ] && [ "$VOL_LEVEL" -ge "$maxLimit" ]; then
        pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "$VOLUME_MAX%"
    elif [ "$VOL_LEVEL" -lt "$maxLimit" ]; then
        pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "+$VOLUME_STEP%"
    fi

    if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
    if [ $AUTOSYNC = "yes" ]; then volSync; fi
}


function volDown() {
    # Pactl already handles the volume lower bounds so that negative values
    # are ignored.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "-$VOLUME_STEP%"

    if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
    if [ $AUTOSYNC = "yes" ]; then volSync; fi
}


function volSync() {
    # This will only be called if $AUTOSYNC is `yes`.

    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    
    getCurVol "$curNode"
    
    if [[ "$NODE_TYPE" = "output" ]]; then
        getSinkInputs "$curNode"

        # Every output found in the active sink has their volume set to the
        # current one.
        for each in $sinkInputs; do
            pactl "set-sink-input-volume" "$each" "$VOL_LEVEL%"
        done
    else
        getSourceOutputs "$curNode"

        # Every input found in the active source has their volume set to the
        # current one.
        for each in $sourceOutputs; do
            pactl "set-source-output-volume" "$each" "$VOL_LEVEL%"
        done
    fi
}


function volMute() {
    # Switch to mute/unmute the volume with pactl.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    if [ "$1" = "toggle" ]; then
        getIsMuted "$curNode"
        if [ "$IS_MUTED" = "yes" ]; then
            pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no"
        else
            pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes"
        fi
    elif [ "$1" = "mute" ]; then
        pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes"
    elif [ "$1" = "unmute" ]; then
        pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no"
    fi

    if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
}


function nextNode() {
    # The final nodes list, removing the blacklisted ones from the list of
    # currently available nodes.
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi

    # Obtaining a tuple of node indexes after removing the blacklisted devices
    # with their name.
    nodes=()
    local i=0
    while read -r line; do
        index=$(echo "$line" | cut -f1)
        name=$(echo "$line" | cut -f2)

        # If it's in the blacklist, continue the main loop. Otherwise, add
        # it to the list.
        for node in "${NODE_BLACKLIST[@]}"; do
            # shellcheck disable=SC2053 # Disable Shellcheck warning for Glob-Matching
            if [[ "$name" == $node ]]; then
                continue 2
            fi
        done

        nodes[i]="$index"
        i=$((i + 1))
    done < <(pactl list short "s${SINK_OR_SOURCE}s" | sort -n)

    # If the resulting list is empty, nothing is done
    if [ ${#nodes[@]} -eq 0 ]; then return; fi

    # If the current node is greater or equal than last one, pick the first
    # node in the list. Otherwise just pick the next node avaliable.
    local newNode
    if [ "$curNode" -ge "${nodes[-1]}" ]; then
        newNode=${nodes[0]}
    else
        for node in "${nodes[@]}"; do
            if [ "$curNode" -lt "$node" ]; then
                newNode=$node
                break
            fi
        done
    fi

    # The new node is set
    pactl "set-default-s${SINK_OR_SOURCE}" "$newNode"

    # Move all audio threads to new node
    local inputs

    if [[ "$NODE_TYPE" = "output" ]]; then
        inputs="$(pactl list short sink-inputs | cut -f 1)"
        for i in $inputs; do
            pactl move-sink-input "$i" "$newNode"
        done
    else
        outputs="$(pactl list short source-outputs | cut -f 1)"
        for i in $outputs; do
            pactl move-source-output "$i" "$newNode"
        done
    fi

    if [ $NOTIFICATIONS = "yes" ]; then
        getNickname "$newNode"

        if command -v dunstify &>/dev/null; then
            notify="dunstify --replace 201839192"
        else
            notify="notify-send"
        fi
        $notify "PulseAudio" "Changed $NODE_TYPE to $NODE_NICKNAME" --icon=audio-headphones-symbolic &
    fi
}


# This function assumes that PulseAudio is already running. It only supports
# KDE OSDs for now. It will show a system message with the status of the
# node passed by parameter, or the currently active one by default.
function showOSD() {
    if [ -z "$1" ]; then
        curNode="$1"
    else
        getCurNode
    fi
    getCurVol "$curNode"
    getIsMuted "$curNode"
    qdbus org.kde.kded /modules/kosd showVolume "$VOL_LEVEL" "$IS_MUTED"
}


function listen() {
    # If this is the first time start by printing the current state. Otherwise,
    # directly wait for events. This is to prevent the module being empty until
    # an event occurs.
    output

    # Listen for changes and immediately create new output for the bar.
    # This is faster than having the script on an interval.
    pactl subscribe 2>/dev/null | grep --line-buffered -e "on \(card\|s${SINK_OR_SOURCE}\|server\)" | {
        while read -r; do
            # Output the new state
            output

            # Read all stdin to flush unwanted pending events, i.e. if there are
            # 15 events at the same time (100ms window), output is only called
            # twice.
            read -r -d '' -t "$LISTEN_TIMEOUT" -n 10000

            # After the 100ms waiting time, output again the state, as it may
            # have changed if the user did an action during the 100ms window.
            output
        done
    }
}


function output() {
    if ! getCurNode; then
        echo "PulseAudio not running"
        return 1
    fi
    getCurVol "$curNode"
    getIsMuted "$curNode"

    # Fixed volume icons over max volume
    local iconsLen=${#ICONS_VOLUME[@]}
    if [ "$iconsLen" -ne 0 ]; then
        local volSplit=$((VOLUME_MAX / iconsLen))
        for i in $(seq 1 "$iconsLen"); do
            if [ $((i * volSplit)) -ge "$VOL_LEVEL" ]; then
                VOL_ICON="${ICONS_VOLUME[$((i-1))]}"
                break
            fi
        done
    else
        VOL_ICON=""
    fi

    getNickname "$curNode"

    # Showing the formatted message
    if [ "$IS_MUTED" = "yes" ]; then
        # shellcheck disable=SC2034
        VOL_ICON=$ICON_MUTED
        content="$(eval echo "$FORMAT")"
        if [ -n "$COLOR_MUTED" ]; then
            echo "${COLOR_MUTED}${content}${END_COLOR}"
        else
            echo "$content"
        fi
    else
        eval echo "$FORMAT"
    fi
}


function usage() {
    echo "\
Usage: $0 [OPTION...] ACTION

Terminology: A node represents either a sink (output) or source (input).

Options:
  --autosync | --no-autosync
        Whether to maintain same volume for all programs.
        Default: \"$AUTOSYNC\"
  --color-muted <rrggbb>
        Color in which to format when muted.
        Pass empty string to disable.
        Default: \"${COLOR_MUTED:4:-1}\"
  --notifications | --no-notifications
        Whether to show notifications when changing nodes.
        Default: \"$NOTIFICATIONS\"
  --osd | --no-osd
        Whether to display KDE's OSD message.
        Default: \"$OSD\"
  --icon-muted <icon>
        Icon to use when muted.
        Default: none
  --icon-node <icon>
        Icon to use for node.
        Default: none
  --format <string>
        Use a format string to control the output.
        Remember to pass this argument wrapped in single quotes (\`'\`) instead
        of double quotes (\`\"\`) to avoid your shell from evaluating the
        variables early.
        Available variables:
        * \$VOL_ICON
        * \$VOL_LEVEL
        * \$ICON_NODE
        * \$NODE_NICKNAME
        * \$IS_MUTED (yes/no)
        Default: '$FORMAT'
  --icons-volume <icon>[,<icon>...]
        Icons for volume, from lower to higher.
        Default: none
  --node-type <node_type>
        Whether to consider PulseAudio sinks (output) or sources (input).
        All the operations of pulseaudio-control will apply to one of the two.
        Pass \`input\` for the sources, e.g. a microphone.
        Pass \`output\` for the sinks, e.g. speakers, headphones.
        Default: \"$NODE_TYPE\"
  --volume-max <int>
        Maximum volume to which to allow increasing.
        Default: \"$VOLUME_MAX\"
  --volume-step <int>
        Step size when inc/decrementing volume.
        Default: \"$VOLUME_STEP\"
  --node-blacklist <name>[,<name>...]
        Nodes to ignore when switching. You can use globs. Don't forget to
        quote the string when using globs, to avoid unwanted shell glob
        extension.
        Default: none
  --node-nicknames-from <prop>
        pactl property to use for node names, unless overridden by
        --node-nickname. Its possible values are listed under the 'Properties'
        key in the output of \`pactl list sinks\` and \`pactl list sources\`.
        Default: none
  --node-nickname <name>:<nick>
        Nickname to assign to given node name, taking priority over
        --node-nicknames-from. May be given multiple times, and 'name' is
        exactly as listed in the output of \`pactl list sinks short | cut -f2\`
        and \`pactl list sources short | cut -f2\`.
        Note that you can also specify a port name for the node with
        \`<name>/<port>\`.
        It is also possible to use glob matching to match node and port names.
        Exact matches are prioritized. Don't forget to quote the string when
        using globs, to avoid unwanted shell glob extension.
        Default: none
  --listen-timeout-secs
        The listen command updates the output as soon as it receives an event
        from PulseAudio. However, events are often accompanied by many other
        useless ones, which may result in unnecessary consecutive output
        updates. This script buffers the following events until a timeout is
        reached to avoid this scenario, which lessens the CPU load on events.
        However, this may result in noticeable latency when performing many
        actions quickly (e.g., updating the volume with the mouse wheel). You
        can specify what timeout to use to control the responsiveness, in
        seconds.
        Default: \"$LISTEN_TIMEOUT\"

Actions:
  help              display this message and exit
  output            print the PulseAudio status once
  listen            listen for changes in PulseAudio to automatically update
                    this script's output
  up, down          increase or decrease the default node's volume
  mute, unmute      mute or unmute the default node's audio
  togmute           switch between muted and unmuted
  next-node         switch to the next available node
  sync              synchronize all the output streams volume to be the same as
                    the current node's volume

Author:
    Mario Ortiz Manero
More info on GitHub:
    https://github.com/marioortizmanero/polybar-pulseaudio-control"
}

# Obtains the value for an option and returns 1 if no shift is needed.
function getOptVal() {
    if [[ "$1" = *=* ]]; then
        val="${1//*=/}"
        return 1
    fi

    val="$2"
}

# Parsing the options from the arguments
while [[ "$1" = --* ]]; do
    unset arg
    unset val

    arg="$1"
    case "$arg" in
        --autosync)
            AUTOSYNC=yes
            ;;
        --no-autosync)
            AUTOSYNC=no
            ;;
        --color-muted|--colour-muted)
            if getOptVal "$@"; then shift; fi
            COLOR_MUTED="%{F#$val}"
            ;;
        --notifications)
            NOTIFICATIONS=yes
            ;;
        --no-notifications)
            NOTIFICATIONS=no
            ;;
        --osd)
            OSD=yes
            ;;
        --no-osd)
            OSD=no
            ;;
        --icon-muted)
            if getOptVal "$@"; then shift; fi
            ICON_MUTED="$val"
            ;;
        --icon-node)
            if getOptVal "$@"; then shift; fi
            # shellcheck disable=SC2034
            ICON_NODE="$val"
            ;;
        --icons-volume)
            if getOptVal "$@"; then shift; fi
            IFS=, read -r -a ICONS_VOLUME <<< "${val//[[:space:]]/}"
            ;;
        --volume-max)
            if getOptVal "$@"; then shift; fi
            VOLUME_MAX="$val"
            ;;
        --volume-step)
            if getOptVal "$@"; then shift; fi
            VOLUME_STEP="$val"
            ;;
        --node-blacklist)
            if getOptVal "$@"; then shift; fi
            IFS=, read -r -a NODE_BLACKLIST <<< "${val//[[:space:]]/}"
            ;;
        --node-nicknames-from)
            if getOptVal "$@"; then shift; fi
            NODE_NICKNAMES_PROP="$val"
            ;;
        --node-nickname)
            if getOptVal "$@"; then shift; fi
            NODE_NICKNAMES["${val//:*/}"]="${val//*:}"
            ;;
        --format)
            if getOptVal "$@"; then shift; fi
            FORMAT="$val"
            ;;
        --node-type)
            if getOptVal "$@"; then shift; fi
            if [[ "$val" != "output" && "$val" != "input" ]]; then
                echo "node-type must be 'output' or 'input', got '$val'" >&2
                exit 1
            fi
            NODE_TYPE="$val"
            SINK_OR_SOURCE=$([ "$NODE_TYPE" == "output" ] && echo "ink" || echo "ource")
            ;;
        --listen-timeout-secs)
            if getOptVal "$@"; then shift; fi
            LISTEN_TIMEOUT="$val"
            ;;
        # Deprecated options, to be removed in a next release
        --icon-sink)
            echo "Replaced by --icon-node, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        --sink-blacklist)
            echo "Replaced by --node-blacklist, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        --sink-nicknames-from)
            echo "Replaced by --node-nicknames-from, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        --sink-nickname)
            echo "Replaced by --node-nickname, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
            exit 1
            ;;
        # Undocumented because the `help` action already exists, but makes the
        # help message more accessible.
        --help)
            usage
            exit 0
            ;;
        *)
            echo "Unrecognised option: $arg" >&2
            exit 1
            ;;
    esac
    shift
done

# Parsing the action from the arguments
case "$1" in
    up)
        volUp
        ;;
    down)
        volDown
        ;;
    togmute)
        volMute toggle
        ;;
    mute)
        volMute mute
        ;;
    unmute)
        volMute unmute
        ;;
    sync)
        volSync
        ;;
    listen)
        listen
        ;;
    next-node)
        nextNode
        ;;
    output)
        output
        ;;
    help)
        usage
        ;;
    # Deprecated action, to be removed in a next release
    next-sink)
        echo "Replaced by next-node, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2
        exit 1
        ;;
    "")
        echo "No action specified. Run \`$0 help\` for more information." >&2
        ;;
    *)
        echo "Unrecognised action: $1" >&2
        exit 1
        ;;
esac

@rockedge Pipewire sound control is already included in version Spectrwm-bar-polybar-v4.6 .the module is called ( pipewire-control-output ) .you just need to organize everything into folders from Spectrwm-bar-polybar-v4.6
-----------------------------------------

Code: Select all

Management:
left click - mute sound
right click - Paucontrol
mouse wheel - adjusts volume

-----------------------------------------
should also work with Pulseaudio
-----------------------------------------
instead of "pavolume" write "pipewire-control-output" in " /root/.config/polybar/config " line 106


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 4:47 pm
by geo_c
rockedge wrote: Tue Oct 17, 2023 3:58 pm

Here is me pondering how I'm going to make a selector mechanism for the different looks so it's easy for a user to choose which to use......
my_photo-9-320px.jpg

Well I don't normally post photos of myself on the webbernet since the onslaught of AI scraping and all that... but I found it incredibly cool to know who I'm talking to. And who am I fooling anyway, it's all in a file in a black box somewhere...

So here's me contemplating why I'm tweaking OS's instead of practicing all the tunes I have to play Thursday night, which as you can tell I find humorous:


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 4:57 pm
by geo_c
geo_c wrote: Tue Oct 17, 2023 4:17 pm

Well, I don't know. First thought is just to include one of these basic dark splashes which will go with a light or dark theme.

Well actually what I could do is make a separate key binding to bring up a gxmessage chooser that overwrites the Spectr-hotkeys.sh with the new colorscheme. Like:

Code: Select all

program[keysplashcolor]  = /root/keysplash-color-chooser     
bind[keysplashcolor] = MOD+Control+k 

then the gxmessage would run a simple cp command like

Code: Select all

cp /root/my-applications/SpectrKeys/Spectr-hotkeys.sh-basicdark /root/Startup/Spectr-hotkeys.sh

When it comes to IT, I'm like the guy that fixes everything with duct tape and WD-40.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 5:34 pm
by fredx181

Here's photo of me (I may not look as handsome as you guys, but that's of course because of the bad quality of the photo :D );
EDIT: Nice to see btw that the gtk3 splash has it's use :thumbup:

2023-10-17-192732.jpg
2023-10-17-192732.jpg (34.53 KiB) Viewed 5427 times

Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 6:24 pm
by Sofiya

replaced


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Tue Oct 17, 2023 11:10 pm
by rockedge

KLV-Spectr-RT updated/upgraded using the kernel 6.1.38-rt13 is ready for download and further testing.

MOD+z will activate Spectrwm's key bindings and controls listing.

Using pipewire and hopefully all of the polish and improvements by @Sofiya and @geo_c included :thumbup2:

https://rockedge.org/kernels/data/ISO/K ... Spectr/RT/

Download directly -> KLV-Spectr-RT.iso 669 M
Hash Values -> SHA1-MD5.txt

If seems close to complete as the base distro we can base the PLUG file on this build. :ugeek:


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 12:23 am
by Sofiya
rockedge wrote: Tue Oct 17, 2023 11:10 pm

KLV-Spectr-RT updated/upgraded using the kernel 6.1.38-rt13 is ready for download and further testing.

MOD+z will activate Spectrwm's key bindings and controls listing.

Using pipewire and hopefully all of the polish and improvements by @Sofiya and @geo_c included :thumbup2:

https://rockedge.org/kernels/data/ISO/K ... Spectr/RT/

Download directly -> KLV-Spectr-RT.iso 669 M
Hash Values -> SHA1-MD5.txt

If seems close to complete as the base distro we can base the PLUG file on this build. :ugeek:

@ rockedge not all files and programs are installed, spectrwm.config has not been replaced from the latest version. Install all files from "
Spectrwm-bar-polybar-v4.6.tar.gz" with a complete replacement of existing . you not install such a rofi https://gitlab.com/sofija.p2018/kla-ot2 ... line=false menu? in /root/.config/rofi
------------------------------
programs, utilities:

Code: Select all

ffmpeg octoxbps elogind rofi xtools i3lock wmctrl nitrogen 
lxterminal pcmanfm lm_sensors acpi lua yad gpick fox xdotool
xmessage gxmessage hsetroot slop xdo xsel xtitle fzf fd xz
wget gzip xsettingsd python-requests lxappearance viewnior
brightnessctl dunst arandr lxtask xcompmgr polybar gettext scrot

Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 12:26 am
by wiak
geo_c wrote: Tue Oct 17, 2023 2:01 pm

Glad I could contribute something! If we'd like to put some information in a welcome splash, I could work on that also. It might be something we could use on other KL variants

Yes, good thing about such utils are that they use little in the way of resources and, with slight modification sometimes, can easily be used in other KL variants. It has always been a bit like a LEGO build system factory and who doesn't enjoy building with LEGO simplicity?

Endless scope really. Gives users/builders lots of control/individual-power to customise on small or large scale. We end up with better and constantly improved distros therefore.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 1:49 am
by rockedge

@Sofiya I did copy all the latest into the rootfs.......I'll check the packages as well......odd...I copied Spectrwm-bar-polybar-v4.6.tar.gz into the rootfs before I squashed it......

Guess I'll have to try it again..... :shock:


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 1:56 am
by geo_c

Still working in my PFI Install of beta two, with all of @Sofiya's v4.4 additions, I had installed OctoXbps as recommended. I normally use command line xbps, so I finally tried to launch OctoXbps from the menu, and got the message:

"You can not run OctoXbps with administrator's credentials."

Is there an easy solution for this? Should it be run as spot?


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 2:08 am
by geo_c
Sofiya wrote: Thu Oct 12, 2023 11:16 pm

try this Comment out line 761 , in line 769 write hwmon-path = /sys/class/hwmon/hwmon0/temp1_input

You know what? I installed all the 4.4 polybar files on my Dell Inspiron, much older than the Dell Precision that you helped troubleshoot the temperature tray config, and the Inspiron had the same issue. Temp reporting steady 25 degrees.

So I applied the same fix, only it didn't initially work and I changed "temp1_input" to "temp2_input" and the tray worked! I needed to be able to see the temp on that particular machine because I used to run jackalpup on it, which is a RT kernel and the thing would shutdown at the failsafe temp.

I have that one on a cooling pad now, and it does much better, hangs around 50-65 degrees.

So I think these older Dells do have a slightly different temperature monitor.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 2:48 am
by Sofiya
geo_c wrote: Wed Oct 18, 2023 1:56 am

Still working in my PFI Install of beta two, with all of @Sofiya's v4.4 additions, I had installed OctoXbps as recommended. I normally use command line xbps, so I finally tried to launch OctoXbps from the menu, and got the message:

"You can not run OctoXbps with administrator's credentials."

Is there an easy solution for this? Should it be run as spot?

Code: Select all

run-as-spot octoxbps

Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 11:33 am
by Sofiya
rockedge wrote: Wed Oct 18, 2023 1:49 am

@Sofiya I did copy all the latest into the rootfs.......I'll check the packages as well......odd...I copied Spectrwm-bar-polybar-v4.6.tar.gz into the rootfs before I squashed it......

Guess I'll have to try it again..... :shock:

@rockedge I'm sorry . I looked again at all the files correctly, I probably opened something wrong in a hurry


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 11:36 am
by Sofiya

KLV-Spectrwm Dracula


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 12:50 pm
by wiak

I tried Spectr for the first time.

Problem with my machine - wouldn't boot with that kernel, but booted fine once I swapped in kernel/modules/vmlinuz from KLV-Swayland.

Looks good. A bit like Sway, though many of the chosen key combinations are different; trying to use same ones would be nice but problem then is that would be far from the upstream defaults, which I want to keep.

I had trouble with keybinds in Spectr though - some didn't seem to work the ways Mod+z said they would; for example 'minimize' and 'restore' (not in Spectr right now and can't remember the keys used but I think it was Mod+Alt+i which didn't seem to do anything. Probably I'm just not understanding correctly what it means and how to use it though.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 1:06 pm
by Sofiya
wiak wrote: Wed Oct 18, 2023 12:50 pm

I tried Spectr for the first time.

Problem with my machine - wouldn't boot with that kernel, but booted fine once I swapped in kernel/modules/vmlinuz from KLV-Swayland.

Looks good. A bit like Sway, though many of the chosen key combinations are different; trying to use same ones would be nice but problem then is that would be far from the upstream defaults, which I want to keep.

I had trouble with keybinds in Spectr though - some didn't seem to work the ways Mod+z said they would; for example 'minimize' and 'restore' (not in Spectr right now and can't remember the keys used but I think it was Mod+Alt+i which didn't seem to do anything. Probably I'm just not understanding correctly what it means and how to use it though.

yes @wiak , you are right about these keys, I also researched this and these combinations behave incorrectly.It’s not clear what is causing this behavior.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 2:14 pm
by rockedge

@wiak thanks for testing out KLV-Spectr ! I am surprised the kernel 6.1.38-rt13 didn't start in your machine. The beta3 model has a Void Linux kernel that should be good but of course most any of the KLV kernels would work as well. Good to know though. Sway is also pretty good. Each tiling WM has it's strengths but I feel KLV-Spectr in RT mode or using another kernel, is going to be a good choice for speed, responsiveness and it's lightness in resource usage.

We'll need to hammer out the few bugs. I'm still not that familiar with any of the tiling WM's navigation completely yet.

@Sofiya, @geo_c perhaps we should have a spectrwm.conf that uses the default MOD1 and see if the commands work in the default configuration. Also I will again go over the rootfs to check for missing packages.

It's close to a solid release...........so the work on the launchpad continues. :thumbup:

Probably I'm just not understanding correctly what it means and how to use it though.

I fall into this category as well :thumbup2:


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 2:41 pm
by geo_c
rockedge wrote: Wed Oct 18, 2023 2:14 pm

@Sofiya, @geo_c perhaps we should have a spectrwm.conf that uses the default MOD1 and see if the commands work in the default configuration. Also I will again go over the rootfs to check for missing packages.

Probably I'm just not understanding correctly what it means and how to use it though.

I fall into this category as well :thumbup2:

What you have to watch with Spectr is window focus. MOD+ALT+i works for me. What it does is minimizes the focused window, so it should disappear from view. To restore, pressing MOD+Shift+i then brings up the stock dmenu on the bar and displays minimized windows for that workspace. Arrow keys page through them, then pressing ENTER will restore the window to it's previous state, so if it was floated and sized, it should come back the same.

So far all of my keybindings work well. But we should make sure that all our keybinding in spectrwm are consistent with each other. I'm working off a PFI install, which is why I included my keybinding config file with the splash scripts. Those need to be pasted carefully into spectrwm.conf for all of them to work. Of course I suppose different keyboard and hardware could be an issue.

EDIT and as I said, the bindings have all worked for me, there is one small annoyance though. When the splash screen is active, and I move it to a different workspace using MOD+Shift+[1=10], and then subsequently want to switch to workspaces using keys like MOD+right, MOD+[1-10], or MOD+up, nothing happens for a good 5-10 seconds. Then at some point the keys become available again. It's like spectr has a lag moving a splash to a new workspace. Clicking with the mouse will immediately cause the keys to be responsive again. So, that's the only mysterious bug I've noticed so far with the keys.

EDIT2 and it may be possible if using @Sofiya's modifications to the bar to allow for full screen video viewing (which I have not incorporated due to time issues and not really needing it) might have something to do with keybinds, as I believe some were changed, like restarting Spectrwm, etc... EDIT3 Also I believe the way the polybar and built in spectr bar interact was changed, and that seems like a likely culprit, in that when using the minimize/restore function, you might not be seeing the stock dmenu.


Re: KLV-Spectr-RT with real full time kernel 6.1.38-rt13c

Posted: Wed Oct 18, 2023 3:18 pm
by Sofiya
geo_c wrote: Wed Oct 18, 2023 2:41 pm
rockedge wrote: Wed Oct 18, 2023 2:14 pm

@Sofiya, @geo_c perhaps we should have a spectrwm.conf that uses the default MOD1 and see if the commands work in the default configuration. Also I will again go over the rootfs to check for missing packages.

Probably I'm just not understanding correctly what it means and how to use it though.

I fall into this category as well :thumbup2:

What you have to watch with Spectr is window focus. MOD+ALT+i works for me. What it does is minimizes the focused window, so it should disappear from view. To restore, pressing MOD+Shift+i then brings up the stock dmenu on the bar and displays minimized windows for that workspace. Arrow keys page through them, then pressing ENTER will restore the window to it's previous state, so if it was floated and sized, it should come back the same.

now that you explained how it works, the test showed that it really works :thumbup:

amendment:
and yes, some of the keyboard shortcuts that @geo_c added are not in my configuration.for the reason that I am satisfied with the way I have

EDIT2 and it may be possible if using @Sofiya's modifications to the bar to allow for full screen video viewing (which I have not incorporated due to time issues and not really needing it) might have something to do with keybinds, as I believe some were changed, like restarting Spectrwm, etc... EDIT3 Also I believe the way the polybar and built in spectr bar interact was changed, and that seems like a likely culprit, in that when using the minimize/restore function, you might not be seeing the stock dmenu.

This function does not affect anything