mirror of
https://github.com/gryf/wmamixer.git
synced 2025-12-17 11:30:21 +01:00
Cleanup the code, added some info to readme, realigned the master volume icon
This commit is contained in:
4
Makefile
4
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
|
||||
|
||||
51
README
51
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
|
||||
|
||||
BIN
XPM/icons.xcf
BIN
XPM/icons.xcf
Binary file not shown.
@@ -15,17 +15,17 @@ static char *icons_xpm[] = {
|
||||
"....................................+...............................................#..........................#++..............................................#++#.............................##@@..##................#@++++@#.........",
|
||||
"....................................+........................++...................#+++#.......................#++#+......................#++++++#...............+.#+............................#+@##@@@................#+@#..#@+#........",
|
||||
".................................+.++....+..+.+.............++#+..................+++++.......................++#+#+....................#++++++++++++#+............+...........................#+......................#+#......#+#.......",
|
||||
"...................#+............+.++....+..+.+............+#+.+.......+.........#+++++#......................+#+#++...................#+++++++....+.+.+.........#+#...........................#+......................+#........#+.......",
|
||||
".................#+++.......+.+.++.++...++..+.++..........+#+.###......#+.........+++++........................+#++.+..................+#++++++++++++#+..........+#.............................#+....................#+..........+#......",
|
||||
"...............#+++++.......+.+.+++++.+.++.++.++.........+##+#.#+..+....+.........#+++#..........#+.............++##.+.................+.#++++++#................#.............#+................#+...................@+..........+@......",
|
||||
".............#+++++++.......+++.+++++++.+++++++++........###++#.+..#+.#.#+..........#..........#+++...............+##.+................+.........................+#..........#+++..........#++++++++++++++#..........@++#........#++@.....",
|
||||
"...........#+++++++++.......+++++++++++++++++++++........###+#+.#.+.+.+..+...................#+++++................+##.+...............#+..................................#+++++..........+##..#..#..#.@#+.........@++++........++++@....",
|
||||
".........#+++++++++++.......@@@@@@@@@@@@@@@@@@@@@........#.#+#+.+.#.+.#..+.................#+++++++.................+##.+...............#+...............................#+++++++.........#+#@.#@.#@.#@.#.+#........+@+++........+++@+....",
|
||||
".......#+++++++++++++.......+++++++++++++++++++++.........#.++..+..#+....+...............#+++++++++..................+##.+...............+.............................#+++++++++.........+#..#..#..#..#.##+........+#+++........+++#+....",
|
||||
".....#+++++++++++++++.......+.+++++++++++++++++++........+.#+...+..+....+..............#+++++++++++...................+##+...............+...........................#+++++++++++........#+@.#@.#@.#@.#@.@#+#.......+#+++........+++#+....",
|
||||
"....+++++++++++++++++.......+.++++.++++.++++++++..........+#+..##......#+............#+++++++++++++....................+++...............+.........................#+++++++++++++........+#.#..#..#..#..#..#+.......+@+++........+++@+....",
|
||||
"..............................++.+.++++..+.+++.+...........+.+.+.......+...........#+++++++++++++++.......................+.............++.......................#+++++++++++++++........++++++++++++++++++++.......@++++........++++@....",
|
||||
"...............................+.+.++.+..+.++..+............++#+..................+++++++++++++++++................#+++...+#...........++.......................+++++++++++++++++........++++++++++++++++++++........@++#........#++@.....",
|
||||
".................................+.++....+..+.+............+#+.+.......+.........#+++++#......................+#+#++...................#+++++++....+.+.+.........#+#...........................#+......................+#........#+.......",
|
||||
"............................+.+.++.++...++..+.++..........+#+.###......#+.........+++++........................+#++.+..................+#++++++++++++#+..........+#.............................#+....................#+..........+#......",
|
||||
"...................#+.......+.+.+++++.+.++.++.++.........+##+#.#+..+....+.........#+++#..........#+.............++##.+.................+.#++++++#................#.............#+................#+...................@+..........+@......",
|
||||
".................#+++.......+++.+++++++.+++++++++........###++#.+..#+.#.#+..........#..........#+++...............+##.+................+.........................+#..........#+++..........#++++++++++++++#..........@++#........#++@.....",
|
||||
"...............#+++++.......+++++++++++++++++++++........###+#+.#.+.+.+..+...................#+++++................+##.+...............#+..................................#+++++..........+##..#..#..#.@#+.........@++++........++++@....",
|
||||
".............#+++++++.......@@@@@@@@@@@@@@@@@@@@@........#.#+#+.+.#.+.#..+.................#+++++++.................+##.+...............#+...............................#+++++++.........#+#@.#@.#@.#@.#.+#........+@+++........+++@+....",
|
||||
"...........#+++++++++.......+++++++++++++++++++++.........#.++..+..#+....+...............#+++++++++..................+##.+...............+.............................#+++++++++.........+#..#..#..#..#.##+........+#+++........+++#+....",
|
||||
".........#+++++++++++.......+.+++++++++++++++++++........+.#+...+..+....+..............#+++++++++++...................+##+...............+...........................#+++++++++++........#+@.#@.#@.#@.#@.@#+#.......+#+++........+++#+....",
|
||||
".......#+++++++++++++.......+.++++.++++.++++++++..........+#+..##......#+............#+++++++++++++....................+++...............+.........................#+++++++++++++........+#.#..#..#..#..#..#+.......+@+++........+++@+....",
|
||||
".....#+++++++++++++++.........++.+.++++..+.+++.+...........+.+.+.......+...........#+++++++++++++++.......................+.............++.......................#+++++++++++++++........++++++++++++++++++++.......@++++........++++@....",
|
||||
"....+++++++++++++++++..........+.+.++.+..+.++..+............++#+..................+++++++++++++++++................#+++...+#...........++.......................+++++++++++++++++........++++++++++++++++++++........@++#........#++@.....",
|
||||
"...............................+.+..+.+....+.................++....................................................+...+++#...........++..................................................................................................",
|
||||
".................................+..+.................................................................................................+...................................................................................................",
|
||||
"..........................................................................................................................................................................................................................................",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* XPM */
|
||||
static char * wmsmixer_xpm[] = {
|
||||
static char * wmamixer_xpm[] = {
|
||||
"64 64 7 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
42
wmamixer.c
42
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') {
|
||||
|
||||
51
wmamixer.h
51
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 pressEvent(XButtonEvent *xev);
|
||||
void releaseEvent();
|
||||
void motionEvent(XMotionEvent *xev);
|
||||
void repaint();
|
||||
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 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);
|
||||
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 repaint();
|
||||
void scanArgs(int argc, char **argv);
|
||||
void update();
|
||||
void usage();
|
||||
|
||||
struct Mixer *Mixer_create();
|
||||
void Mixer_set_left(int current, int value);
|
||||
void Mixer_set_right(int current, int value);
|
||||
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);
|
||||
void Mixer_set_left(int current, int value);
|
||||
void Mixer_set_right(int current, int value);
|
||||
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 */
|
||||
|
||||
Reference in New Issue
Block a user