From e9b4b6323f975a12aa41a4a0d4e3c93c423ab0d5 Mon Sep 17 00:00:00 2001 From: blix4 Date: Tue, 27 Aug 2019 00:20:08 -0700 Subject: volume widget support amixer with no device specified This works on my setup without having pulseaudio installed. --- volume-widget/README.md | 25 +++++++++++++++++++++++++ volume-widget/volume.lua | 19 ++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) (limited to 'volume-widget') diff --git a/volume-widget/README.md b/volume-widget/README.md index 118abc6..494be24 100644 --- a/volume-widget/README.md +++ b/volume-widget/README.md @@ -31,6 +31,31 @@ s.mytasklist, -- Middle widget sudo sed -i 's/bebebe/ed4737/g' ./audio-volume-muted-symbolic_red.svg ``` +### Pulse or ALSA only + +Try running this command: + +```amixer -D pulse sget Master``` + +If that prints something like this, then the default setting of 'pulse' is probably fine: +``` +Simple mixer control 'Master',0 + Capabilities: pvolume pvolume-joined pswitch pswitch-joined + Playback channels: Mono + Limits: Playback 0 - 64 + Mono: Playback 64 [100%] [0.00dB] [on] + +``` + +If it prints something like this: +``` +$ amixer -D pulse sget Master +ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused + +amixer: Mixer attach pulse error: Connection refused +``` +then try setting the environment variable `AWW_VOLUME_CONTROLLER` to `alsa_only`. + ## Control volume To mute/unmute click on the widget. To increase/decrease volume scroll up or down when mouse cursor is over the widget. diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 8124bcf..04f1c26 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -13,12 +13,21 @@ local wibox = require("wibox") local watch = require("awful.widget.watch") local spawn = require("awful.spawn") +local secrets = require("awesome-wm-widgets.secrets") + local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" -local GET_VOLUME_CMD = 'amixer -D pulse sget Master' -local INC_VOLUME_CMD = 'amixer -D pulse sset Master 5%+' -local DEC_VOLUME_CMD = 'amixer -D pulse sset Master 5%-' -local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' +if secrets.volume_audio_controller == 'pulse' then + device_arg = '-D pulse' +else + device_arg = '' +end + +local GET_VOLUME_CMD = 'amixer ' .. device_arg .. ' sget Master' +local INC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%+' +local DEC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%-' +local TOG_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master toggle' + local volume_widget = wibox.widget { { @@ -64,4 +73,4 @@ end) watch(GET_VOLUME_CMD, 1, update_graphic, volume_widget) -return volume_widget \ No newline at end of file +return volume_widget -- cgit v1.2.3 From 05e9a909bd29bc7e9a50ba6e5ff6fdecd4503f2a Mon Sep 17 00:00:00 2001 From: blix4 Date: Tue, 27 Aug 2019 00:30:32 -0700 Subject: clean up a global variable --- volume-widget/volume.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'volume-widget') diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 04f1c26..fe7ff2c 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -17,6 +17,7 @@ local secrets = require("awesome-wm-widgets.secrets") local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" +local device_arg if secrets.volume_audio_controller == 'pulse' then device_arg = '-D pulse' else -- cgit v1.2.3