summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Dobosz <gryf73@gmail.com>2015-01-29 21:53:41 +0100
committerRoman Dobosz <gryf73@gmail.com>2015-01-29 21:53:41 +0100
commit4f3c64607e3035e66bfe873705b6e22a8af9af57 (patch)
treebc8f797ab07595a2505d0300402fa198677b4245
parent623b3209a72ab6913e613ee93a979191cb19aba3 (diff)
downloadwmamixer-4f3c64607e3035e66bfe873705b6e22a8af9af57.tar.gz
wmamixer-4f3c64607e3035e66bfe873705b6e22a8af9af57.tar.bz2
wmamixer-4f3c64607e3035e66bfe873705b6e22a8af9af57.zip
Cleanup the code, added some info to readme, realigned the master volume icon
-rw-r--r--Makefile4
-rw-r--r--README51
-rw-r--r--XPM/icons.xcfbin5129 -> 4904 bytes
-rw-r--r--XPM/icons.xpm22
-rw-r--r--XPM/wmamixer.xpm (renamed from XPM/wmsmixer.xpm)2
-rw-r--r--wmamixer.c42
-rw-r--r--wmamixer.h43
7 files changed, 98 insertions, 66 deletions
diff --git a/Makefile b/Makefile
index 86119e4..042df18 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,5 @@
all:
- gcc -Wall -Wextra -lm -lXpm -lXext -lX11 -lasound wmamixer.c -o wmamixer
+ gcc wmamixer.c -Wall -Wextra -lm -lXpm -lXext -lX11 -lasound -o wmamixer
strip wmamixer
-dev:
- gcc -ggdb -Wall -Wextra -lm -lXpm -lXext -lX11 -lasound wmamixer.c -o wmamixer
clean:
rm wmamixer
diff --git a/README b/README
index 73a4ae6..b0d7a41 100644
--- a/README
+++ b/README
@@ -1,4 +1,51 @@
wmamixer
---------
+========
-wmamixer is an alsa mixer for windowmaker based on wmsmixer.
+Wmamixer is a fork of wmsmixer and is an ALSA mixer dockapp for Window Maker.
+
+The code for the ALSA part was taken and adapted from amixer and alsamixer
+programs from alsa-utils package.
+
+Bugs
+----
+
+If spotted any bug, please report it using bug tracker on bitbucket.
+
+Changes
+-------
+
+Changes with comparison with wmsmixer:
+
+- ALSA instead of OSS. This is real thing, using alsa-lib, not just emulation
+ of OSS.
+- Placement of configuration file changed to "$XDG_CONFIG_HOME/wmamixer.conf",
+ which usually translate to "$HOME/.config/wmamixer.conf"
+
+Limitations
+-----------
+
+1. Currently, wmamixer does not support switches and enum type of controls.
+Only volume is supported. Enum and switch based ALSA controls are simply
+ignored.
+
+2. There are controls with really small limit range, for example here is
+control Beep (pc speaker in other words) which is represented by amixer like
+this:
+
+ Simple mixer control 'Beep',0
+ Capabilities: pvolume pvolume-joined pswitch pswitch-joined
+ Playback channels: Mono
+ Limits: Playback 0 - 3
+ Mono: Playback 1 [33%] [-12.00dB] [on]
+
+Under "Limits" section, there is a Playback capability with range 0 - 3. Using
+scrollwheel on such low ranges is somehow awkward. For that controls it's
+better to use clicking instead of scrolling.
+
+
+Links
+-----
+wmsmixer homepage:
+http://web.archive.org/web/20081024034859/http://www.hibernaculum.net/wmsmixer/index.php
+ALSA homepage:
+http://www.alsa-project.org
diff --git a/XPM/icons.xcf b/XPM/icons.xcf
index 92e3396..1f68099 100644
--- a/XPM/icons.xcf
+++ b/XPM/icons.xcf
Binary files differ
diff --git a/XPM/icons.xpm b/XPM/icons.xpm
index 6734cca..434e143 100644
--- a/XPM/icons.xpm
+++ b/XPM/icons.xpm
@@ -15,17 +15,17 @@ static char *icons_xpm[] = {
"....................................+...............................................#..........................#++..............................................#++#.............................##@@..##................#@++++@#.........",
"....................................+........................++...................#+++#.......................#++#+......................#++++++#...............+.#+............................#+@##@@@................#+@#..#@+#........",
".................................+.++....+..+.+.............++#+..................+++++.......................++#+#+....................#++++++++++++#+............+...........................#+......................#+#......#+#.......",
-"...................#+............+.++....+..+.+............+#+.+.......+.........#+++++#......................+#+#++...................#+++++++....+.+.+.........#+#...........................#+......................+#........#+.......",
-".................#+++.......+.+.++.++...++..+.++..........+#+.###......#+.........+++++........................+#++.+..................+#++++++++++++#+..........+#.............................#+....................#+..........+#......",
-"...............#+++++.......+.+.+++++.+.++.++.++.........+##+#.#+..+....+.........#+++#..........#+.............++##.+.................+.#++++++#................#.............#+................#+...................@+..........+@......",
-".............#+++++++.......+++.+++++++.+++++++++........###++#.+..#+.#.#+..........#..........#+++...............+##.+................+.........................+#..........#+++..........#++++++++++++++#..........@++#........#++@.....",
-"...........#+++++++++.......+++++++++++++++++++++........###+#+.#.+.+.+..+...................#+++++................+##.+...............#+..................................#+++++..........+##..#..#..#.@#+.........@++++........++++@....",
-".........#+++++++++++.......@@@@@@@@@@@@@@@@@@@@@........#.#+#+.+.#.+.#..+.................#+++++++.................+##.+...............#+...............................#+++++++.........#+#@.#@.#@.#@.#.+#........+@+++........+++@+....",
-".......#+++++++++++++.......+++++++++++++++++++++.........#.++..+..#+....+...............#+++++++++..................+##.+...............+.............................#+++++++++.........+#..#..#..#..#.##+........+#+++........+++#+....",
-".....#+++++++++++++++.......+.+++++++++++++++++++........+.#+...+..+....+..............#+++++++++++...................+##+...............+...........................#+++++++++++........#+@.#@.#@.#@.#@.@#+#.......+#+++........+++#+....",
-"....+++++++++++++++++.......+.++++.++++.++++++++..........+#+..##......#+............#+++++++++++++....................+++...............+.........................#+++++++++++++........+#.#..#..#..#..#..#+.......+@+++........+++@+....",
-"..............................++.+.++++..+.+++.+...........+.+.+.......+...........#+++++++++++++++.......................+.............++.......................#+++++++++++++++........++++++++++++++++++++.......@++++........++++@....",
-"...............................+.+.++.+..+.++..+............++#+..................+++++++++++++++++................#+++...+#...........++.......................+++++++++++++++++........++++++++++++++++++++........@++#........#++@.....",
+".................................+.++....+..+.+............+#+.+.......+.........#+++++#......................+#+#++...................#+++++++....+.+.+.........#+#...........................#+......................+#........#+.......",
+"............................+.+.++.++...++..+.++..........+#+.###......#+.........+++++........................+#++.+..................+#++++++++++++#+..........+#.............................#+....................#+..........+#......",
+"...................#+.......+.+.+++++.+.++.++.++.........+##+#.#+..+....+.........#+++#..........#+.............++##.+.................+.#++++++#................#.............#+................#+...................@+..........+@......",
+".................#+++.......+++.+++++++.+++++++++........###++#.+..#+.#.#+..........#..........#+++...............+##.+................+.........................+#..........#+++..........#++++++++++++++#..........@++#........#++@.....",
+"...............#+++++.......+++++++++++++++++++++........###+#+.#.+.+.+..+...................#+++++................+##.+...............#+..................................#+++++..........+##..#..#..#.@#+.........@++++........++++@....",
+".............#+++++++.......@@@@@@@@@@@@@@@@@@@@@........#.#+#+.+.#.+.#..+.................#+++++++.................+##.+...............#+...............................#+++++++.........#+#@.#@.#@.#@.#.+#........+@+++........+++@+....",
+"...........#+++++++++.......+++++++++++++++++++++.........#.++..+..#+....+...............#+++++++++..................+##.+...............+.............................#+++++++++.........+#..#..#..#..#.##+........+#+++........+++#+....",
+".........#+++++++++++.......+.+++++++++++++++++++........+.#+...+..+....+..............#+++++++++++...................+##+...............+...........................#+++++++++++........#+@.#@.#@.#@.#@.@#+#.......+#+++........+++#+....",
+".......#+++++++++++++.......+.++++.++++.++++++++..........+#+..##......#+............#+++++++++++++....................+++...............+.........................#+++++++++++++........+#.#..#..#..#..#..#+.......+@+++........+++@+....",
+".....#+++++++++++++++.........++.+.++++..+.+++.+...........+.+.+.......+...........#+++++++++++++++.......................+.............++.......................#+++++++++++++++........++++++++++++++++++++.......@++++........++++@....",
+"....+++++++++++++++++..........+.+.++.+..+.++..+............++#+..................+++++++++++++++++................#+++...+#...........++.......................+++++++++++++++++........++++++++++++++++++++........@++#........#++@.....",
"...............................+.+..+.+....+.................++....................................................+...+++#...........++..................................................................................................",
".................................+..+.................................................................................................+...................................................................................................",
"..........................................................................................................................................................................................................................................",
diff --git a/XPM/wmsmixer.xpm b/XPM/wmamixer.xpm
index ce9bc20..fa8d4b0 100644
--- a/XPM/wmsmixer.xpm
+++ b/XPM/wmamixer.xpm
@@ -1,5 +1,5 @@
/* XPM */
-static char * wmsmixer_xpm[] = {
+static char * wmamixer_xpm[] = {
"64 64 7 1",
" c None",
". c #000000",
diff --git a/wmamixer.c b/wmamixer.c
index fe0fe12..5a04424 100644
--- a/wmamixer.c
+++ b/wmamixer.c
@@ -16,17 +16,8 @@ struct Mixer *mix;
int main(int argc, char **argv) {
XGCValues gcv;
unsigned long gcm;
- char back_color[] = "back_color";
- char led_color_high[] = "led_color_high";
- char led_color_med[] = "led_color_med";
- char led_color_low[] = "led_color_low";
+
XpmAttributes xpmattr;
- XpmColorSymbol xpmcsym[4] = {
- {back_color, NULL, color[0]},
- {led_color_high, NULL, color[1]},
- {led_color_med, NULL, color[2]},
- {led_color_low, NULL, color[3]}
- };
scanArgs(argc, argv);
initXWin(argc, argv);
@@ -40,12 +31,19 @@ int main(int argc, char **argv) {
color[2] = mixColor(ledcolor, 60, backcolor, 40);
color[3] = mixColor(ledcolor, 25, backcolor, 75);
+ XpmColorSymbol xpmcsym[4] = {
+ {"back_color", NULL, color[0]},
+ {"led_color_high", NULL, color[1]},
+ {"led_color_med", NULL, color[2]},
+ {"led_color_low", NULL, color[3]}
+ };
+
xpmattr.numsymbols = 4;
xpmattr.colorsymbols = xpmcsym;
xpmattr.exactColors = false;
xpmattr.closeness = 40000;
xpmattr.valuemask = XpmColorSymbols | XpmExactColors | XpmCloseness;
- XpmCreatePixmapFromData(d_display, w_root, wmsmixer_xpm, &pm_main,
+ XpmCreatePixmapFromData(d_display, w_root, wmamixer_xpm, &pm_main,
&pm_mask, &xpmattr);
XpmCreatePixmapFromData(d_display, w_root, tile_xpm, &pm_tile, NULL,
&xpmattr);
@@ -89,23 +87,18 @@ int main(int argc, char **argv) {
XNextEvent(d_display, &xev);
switch(xev.type ) {
case Expose:
- printf("DEBUG: Expose ev\n");
repaint();
break;
case ButtonPress:
- printf("DEBUG: ButtonPress ev\n");
pressEvent(&xev.xbutton);
break;
case ButtonRelease:
- printf("DEBUG: ButtonRelease ev\n");
releaseEvent();
break;
case MotionNotify:
- printf("DEBUG: MotionNotify ev\n");
motionEvent(&xev.xmotion);
break;
case ClientMessage:
- printf("DEBUG: ClientMessage ev\n");
if (xev.xclient.data.l[0] == (int) deleteWin)
done=true;
break;
@@ -136,11 +129,10 @@ int main(int argc, char **argv) {
drawVolLevel();
repaint();
}
- // printf("%c", text_counter);
}
XFlush(d_display);
-
+ snd_mixer_handle_events(mix->handle);
usleep(50000);
}
}
@@ -205,7 +197,7 @@ struct Mixer *Mixer_create() {
if (!snd_mixer_selem_is_active(elem))
continue;
- capabilities = Mixer_getcapabilities(elem);
+ capabilities = Mixer_get_capabilities(elem);
if (!capabilities.isvolume)
continue;
@@ -235,11 +227,12 @@ void Mixer_set_selem_props(struct Selem *selem, const char *name) {
*cap = "Capture",
*boost = "Boost",
*line = "Line";
- char variable[4];
+ char variable[5];
// Get the name. Simple match.
if (strcmp("Master", name) == 0) {
selem->name = "mstr";
+ selem->iconIndex = 0;
} else if (strstr(pcm, name)) {
selem->iconIndex = 1;
if (strcmp(pcm, name) == 0) {
@@ -297,9 +290,9 @@ void Mixer_set_selem_props(struct Selem *selem, const char *name) {
selem->iconIndex = 3;
} else {
/* defaults */
+ printf("defaults\n");
sprintf(variable, "vol%d", namesCount.vol);
- selem->name = variable;
- namesCount.pcm++;
+ namesCount.vol++;
selem->iconIndex = 6;
}
}
@@ -345,7 +338,7 @@ void Mixer_set_channels(struct Selem *selem) {
}
}
-slideCaptureMono Mixer_getcapabilities(snd_mixer_elem_t *elem) {
+slideCaptureMono Mixer_get_capabilities(snd_mixer_elem_t *elem) {
slideCaptureMono retval;
retval.mono = false;
retval.capture = false;
@@ -718,7 +711,6 @@ void readFile() {
void checkVol(bool forced) {
int nl = Mixer_read_left(curchannel);
int nr = Mixer_read_right(curchannel);
- printf("DEBUG: checkVol: %d, %d\n", nl, nr);
if (forced) {
curleft = nl;
curright = nr;
@@ -850,8 +842,6 @@ void drawText(char *text) {
char p2;
int i;
- printf("DEBUG: Copy text as a label: %s\n", text);
-
for (i = 0; i < 4; i++, p++) {
p2 = toupper(*p);
if (p2 >= 'A' && p2 <= 'Z') {
diff --git a/wmamixer.h b/wmamixer.h
index 40049e5..f098c4b 100644
--- a/wmamixer.h
+++ b/wmamixer.h
@@ -63,7 +63,7 @@ Pixmap pm_digits;
Pixmap pm_chars;
// Xpm images - standard
-#include "XPM/wmsmixer.xpm"
+#include "XPM/wmamixer.xpm"
#include "XPM/tile.xpm"
// Xpm images - custom
@@ -159,43 +159,40 @@ static int smixer_level = 0;
static struct snd_mixer_selem_regopt smixer_options;
// Procedures and functions - standard
-void initXWin(int argc, char **argv);
-void freeXWin();
void createWin(Window *win, int x, int y);
+void freeXWin();
+void initXWin(int argc, char **argv);
unsigned long mixColor(char *color1, int prop1, char *color2, int prop2);
// Procedures and functions - custom
-void scanArgs(int argc, char **argv);
-void readFile();
-void usage();
void checkVol(bool forced);
+void drawBtn(int x, int y, int w, int h, bool down);
+void drawBtns(int btns);
+void drawLeft();
+void drawMono();
+void drawRight();
+void drawText(char *text);
+void drawVolLevel();
+void motionEvent(XMotionEvent *xev);
void pressEvent(XButtonEvent *xev);
+void readFile();
void releaseEvent();
-void motionEvent(XMotionEvent *xev);
void repaint();
+void scanArgs(int argc, char **argv);
void update();
-void drawLeft();
-void drawRight();
-void drawMono();
-void drawVolLevel();
-void drawText(char *text);
-void drawBtns(int btns);
-void drawBtn(int x, int y, int w, int h, bool down);
+void usage();
+struct Mixer *Mixer_create();
+void Mixer_destroy(struct Mixer *mix);
+slideCaptureMono Mixer_get_capabilities(snd_mixer_elem_t *elem);
+int Mixer_get_volume(int current, int channelIndex);
+int Mixer_read_left(int current);
+int Mixer_read_right(int current);
void Mixer_set_selem_props(struct Selem *selem, const char *name);
void Mixer_set_channels(struct Selem *selem);
-slideCaptureMono Mixer_getcapabilities(snd_mixer_elem_t *elem);
-
-struct Mixer *Mixer_create();
void Mixer_set_left(int current, int value);
void Mixer_set_right(int current, int value);
-int Mixer_read_left(int current);
-int Mixer_read_right(int current);
-
void Mixer_set_limits(snd_mixer_elem_t *elem, struct Selem *selem);
-
-void Mixer_destroy(struct Mixer *mix);
-int Mixer_get_volume(int current, int channelIndex);
void Mixer_set_volume(int current, int channelIndex, int value);
#endif /* WMAMIXER_H */