Rhythmbox рушится на старте

12.04 (и, возможно, 11.10)

Если вы хотите напрямую управлять томом pulseaudio, а не идти по маршруту ALSA, вы можете использовать следующий скрипт. Хотя также можно контролировать громкость через DBUS, как описано в этом ответе Stackoverflow, однако я не смог найти способ сделать эту работу в Ubuntu 12.04.

Как сказано в самом скрипте, это использует этот ответ Stackoverflow и расширяет идею в сценарий, который принимает изменение объема в качестве аргумента командной строки, а также показывает уведомление OSD. Я попытался как можно более точно его моделировать по умолчанию Ubuntu (12.04).

Сценарий принимает изменения объема как абсолютное, или относительное число или процентное значение. Так, например:

pavol.sh 2000 устанавливает громкость в 2000, pavol.sh 30% устанавливает громкость на 30 процентов, pavol.sh +1000 увеличивает громкость на 1000, а pavol.sh -5% уменьшает громкость на 5 процентов.

Это также довольно либерально комментируется в надежде на то, что оно полезно для дальнейшей настройки.

HowTo

Используйте свой любимый текстовый редактор для создания файла в своем (или где-нибудь еще - просто запомните путь) под названием pavol.sh и скопируйте и вставьте содержимое ниже в этот файл, т. е.

gedit ~/pavol.sh

Запустите chmod a+x ~/pavol.sh, чтобы сделать его исполняемым.

Затем откройте Sytem Settings, перейдите к настройкам Keyboard и перейдите на вкладку Shortcuts. Нажмите Custom Shortcuts и создайте два новых сочетания клавиш с помощью кнопки плюс.

Дайте каждому имя и как команду введите что-то вроде этого: /home/username/pavol.sh "+3%" Важно ввести полный путь к pavol.sh (если скрипт не находится в папке, включенной в переменную среды PATH). Также используйте знаки котировки "" вокруг значения тома или сочетание клавиш не будет работать.

После этого щелкните по правой стороне каждой записи, чтобы установить комбинацию клавиш или мультимедийный ключ. Если желаемая комбинация или клавиша уже назначена другому ярлыку, программа спросит, хотите ли вы переназначить ее.

pavol.sh

#!/bin/bash --

## This script expands upon this answer on stackoverflow:
## https://stackoverflow.com/a/10739764
##



## GLOBAL VARIABLES

# restrict usable commands
PATH="/bin:/usr/bin"

# this script changes the volume of the default sink (as set, for instance, via the Ubuntu sound menu);
# use "pactl info" to display these settings neatly in a terminal
DEFAULT_SINK=$(pacmd dump | grep 'set-default-sink' | cut -d ' ' -f 2)

# get max. volume from the DEFAULT_SINK
MAX_VOL=$(pacmd list-sinks | grep -A 20 "name: <${DEFAULT_SINK}>" | grep "volume steps:" | tr -d '[:space:]' | cut -d ':' -f 2)

# show debug messages?
# 0 means no debug messages; 1 prints the current volume to the console at the end of the script; 2 switches on bash debugging via "set -x"
DEBUG=0



## FUNCTIONS

# generate trace output if DEBUG is 2 or higher
if [ ${DEBUG} -gt 1 ]; then set -x; fi

# use poor man's return buffer via this variable (This is not stackable!)
RETVAL=""


# print simple usage text to console
show_usage() {
    echo "Usage: $(basename ${0}) [+|-][number|percentage]"
}


# return (via RETVAL) the current pulseaudio volume as hexadecimal value
get_cur_vol() {
    RETVAL=$(pacmd dump | grep "set-sink-volume ${DEFAULT_SINK}" | cut -d ' ' -f 3)
}


# change the pulseaudio volume as set in the first parameter variable, i.e. ${1};
# this can either be an absolute percentage or normal value, for instance 20% or 2000,
# or a relative percentage or normal value, for instance +3% or -5% or +200 or -1000
change_vol() {
    step=${1}

    relative=${step:0:1} # extract first character
    percent=${step: -1}  # extract last character

    # cut off first character for easier calculations, if it is either a "+" or "-"
    if [ "${relative}" = "+" -o "${relative}" = "-" ]; then step=${step:1}; fi

    # if the last character of ${step} was, in fact, a percent sign...
    if [ "${percent}" = "%" ]; then
        step=${step:0:-1}        # cut off last character for easier calculations
        step=$[step*MAX_VOL/100] # change percentage into fixed value via MAX_VOL
    fi

    # save current volume in ${old_vol}
    get_cur_vol
    old_vol=$[RETVAL+0] # the dummy calculation turns the hexadecimal number to a decimal one

    # calculate the new volume value ${new_vol} with the operand that was extracted earlier
    if [ "${relative}" = "+" ]; then
        new_vol=$[old_vol+step]
    else
        if [ "${relative}" = "-" ]; then
            new_vol=$[old_vol-step]
        else
            # no operand found, so ${step} must be an absolute value
            new_vol=${step}
        fi
    fi

    # check boundaries - don't go below 0 and above MAX_VOL
    if [ ${new_vol} -lt 0 ]; then new_vol=0; fi
    if [ ${new_vol} -gt ${MAX_VOL} ]; then new_vol=${MAX_VOL}; fi

    # set the new volume
    pactl -- set-sink-volume "${DEFAULT_SINK}" "${new_vol}"

    # mute the sink if the new volume drops to 0 ...
    if [ ${new_vol} -le 0 ]; then
        pactl -- set-sink-mute "${DEFAULT_SINK}" yes
    else
        # ... or unmute the sink if the new volume is greater than the old
        if [ ${new_vol} -gt ${old_vol} ]; then
            pactl -- set-sink-mute "${DEFAULT_SINK}" no
        fi
    fi
}


# show an OSD notification
notify_osd() {
    # get current volume
    get_cur_vol
    cur_vol_percent=$[RETVAL*100/MAX_VOL]

    # get mute state (gives "yes" or "no")
    muted=$(pacmd dump | grep "set-sink-mute ${DEFAULT_SINK}" | cut -d ' ' -f 3)

    # choose suitable icon (modeled after the default Ubuntu 12.04 behavior):
    # muted-icon if volume is muted
    if [ "${muted}" = "yes" ]; then
        icon="notification-audio-volume-muted"
    else
        # icon with loudspeaker and 1 of the 3 circle segments filled if volume is less than 34%
        if [ ${cur_vol_percent} -lt 34 ]; then
            icon="notification-audio-volume-low"
        else
            # icon with loudspeaker and 2 of the 3 circle segments filled if volume is between 34% and 66%
            if [ ${cur_vol_percent} -lt 67 ]; then
                icon="notification-audio-volume-medium"
            else
                # icon with loudspeaker and all 3 of the 3 circle segments filled if volume is higher than 66%
                icon="notification-audio-volume-high"
            fi
        fi
    fi

    # show notification
    notify-send "Volume" -i ${icon} -h int:value:${cur_vol_percent} -h string:synchronous:volume
}


# fake main function, that gets called first and kicks off all the other functions
main() {
    # only change volume if input is a number with either a +/- prefix and/or a % suffix
    if [[ "${1}" =~ ^[+-]?[0-9]+[%]?$ ]]; then
        change_vol ${1}
    else
        show_usage
    fi

    # show volume osd
    notify_osd

    # show the new - now current - volume in hexadecimal, decimal and percentage if DEBUG is greater than 0
    if [ ${DEBUG} -gt 0 ]; then
        get_cur_vol
        echo "${RETVAL} - $[RETVAL+0] - $[RETVAL*100/MAX_VOL]%"
    fi
}



## REAL MAIN

# run the fake main function and pass on all command line arguments; then exit the script
main ${@}
exit 0
1
задан 2 March 2013 в 01:40

2 ответа

Первое, что я бы рекомендовал, - это, по крайней мере, обновление до Ubuntu 11.04. Ubuntu 10.10 достигнет End Of Life через несколько недель, когда выпущено 12.04 (что я действительно рекомендую обновить до).

Крушение, вероятно, не имеет ничего общего с Ubuntu One, но невозможно знать что, как вы задали здесь вопрос, вместо сообщения об ошибке. Если ситуация рушится, сообщите об ошибках, а не задавайте вопросы по askUbuntu (который не является форумом для сообщений об ошибках).

0
ответ дан 25 May 2018 в 13:03

Ну, в моем случае у меня есть музыка, хранящаяся на сетевом ресурсе. Я удалил некоторые файлы из библиотеки на другом компьютере. Когда я запустил Rhythmbox, он все еще показывал эти песни на пару секунд и затем исчезал. И Rhythmbox.

Итак, я удалил ~/.local/share/rhythmbox, и он запущен без заминки. Просто нужно было переиндексировать местоположение, где хранится музыка.

0
ответ дан 25 May 2018 в 13:03

Другие вопросы по тегам:

Похожие вопросы: