sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit e927fdc118daf2522527fbdbef4fbaf426e32e26
parent ead8e31902cab38938cc5367ef12c03c52371c11
Author: wifiextender <router@archlinux.info>
Date:   Sun, 21 Aug 2016 09:52:20 +0200

Was accussed that I spam the wiki page, so I withdraw my contributions.

Diffstat:
Mdwm.suckless.org/dwmstatus/index.md | 2--
Ddwm.suckless.org/dwmstatus/volume.c | 100-------------------------------------------------------------------------------
2 files changed, 0 insertions(+), 102 deletions(-)

diff --git a/dwm.suckless.org/dwmstatus/index.md b/dwm.suckless.org/dwmstatus/index.md @@ -21,7 +21,6 @@ Please add your own version of dwmstatus here (keeping the list sorted). * [barM](barM.c) - can display all, time/date, ram usage, output of commands (the New BarMonitor). * [dstat](https://www.umaxx.net/dl) [Screenshot](https://www.umaxx.net/dstat.png) - displays the current network throughput, CPU usage, performance settings, battery status, temperature, volume settings, as well as the current date and time (OpenBSD only, no support for Linux). -* [pinky-bar](https://github.com/wifiextender/pinky-bar) - 50+ different actions, Linux and FreeBSD support. * [dwmsd](https://github.com/johnko/dwmsd) - a daemon that listens on localhost tcp (may be useful as a base for asynchronous updates) * [go-dwmstatus](https://github.com/oniichaNj/go-dwmstatus) - A Go bar that prints current MPD song, load averages, time/date and battery percentage. * [gods](https://github.com/schachmat/gods) - implemented in Go. prints network speed, cpu, ram, date/time @@ -35,7 +34,6 @@ Helper functions If you have simple C functions for gathering system information, please add them here as file or as code example. -* [Basic ALSA Volume API example with error checks and handling](volume.c) * [Support for ACPI battery status Linux](new-acpi-battery.c) * [Reading out a temperature from /sys](dwmstatus-temperature.c) * [Reading up-, and downspeeds of all network interfaces from /proc/net](dwmstatus-netusage.c) diff --git a/dwm.suckless.org/dwmstatus/volume.c b/dwm.suckless.org/dwmstatus/volume.c @@ -1,100 +0,0 @@ -/* - Copyright 07/20/2016 Aaron Caffrey https://github.com/wifiextender - - 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 2 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, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. - - Compile with: - gcc -Wall -Wextra -O2 volume.c -o test -lasound -*/ - -#include <stdio.h> -#include <stdlib.h> - -#include <alsa/asoundlib.h> - -#define ALSA_ERR "Error: alsa failed" - -void exit_with_err(const char *); -void get_sound(void); - -int main(void) { - get_sound(); - return EXIT_SUCCESS; -} - -void -exit_with_err(const char *str1) { - printf("%s\n", str1); - exit(EXIT_FAILURE); -} - -void -get_sound(void) { - snd_mixer_t *handle = NULL; - snd_mixer_elem_t *elem = NULL; - snd_mixer_selem_id_t *s_elem = NULL; - long int vol, max, min; - - if (0 < (snd_mixer_open(&handle, 0))) { - exit_with_err(ALSA_ERR); - } - - if (0 < (snd_mixer_attach(handle, "default"))) { - goto error; - } - - if (0 < (snd_mixer_selem_register(handle, NULL, NULL))) { - goto error; - } - - if (0 < (snd_mixer_load(handle))) { - goto error; - } - - snd_mixer_selem_id_malloc(&s_elem); - if (NULL == s_elem) { - goto error; - } - - snd_mixer_selem_id_set_name(s_elem, "Master"); - if (NULL == (elem = snd_mixer_find_selem(handle, s_elem))) { - goto error; - } - - /* Use `set' to change the current volume value */ - if (0 < (snd_mixer_selem_get_playback_volume(elem, 0, &vol))) { - goto error; - } - snd_mixer_selem_get_playback_volume_range(elem, &min, &max); - - snd_mixer_selem_id_free(s_elem); - snd_mixer_close(handle); - - printf("%s %ld%%\n", "Volume set to", (vol * 100) / max); - return; - -/* stay cheesy no matter what */ -error: - if (NULL != s_elem) { - snd_mixer_selem_id_free(s_elem); - s_elem = NULL; - } - if (NULL != handle) { - snd_mixer_close(handle); - handle = NULL; - } - exit_with_err(ALSA_ERR); -}