Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
panelcontrol
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
minus
panelcontrol
Commits
5a66e1d5
Commit
5a66e1d5
authored
Nov 11, 2019
by
minus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stewdio faving & display
parent
0504b5d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
panelcontrol.c
panelcontrol.c
+62
-0
No files found.
panelcontrol.c
View file @
5a66e1d5
...
...
@@ -19,6 +19,15 @@ struct show_mute_and_speakers_config {
enum
button
button_speakers
;
};
struct
fav_config
{
struct
seq_port
*
sp
;
enum
button
button
;
char
*
hash
;
bool
is_fav
;
char
*
username
;
int
stdin
;
};
void
show_mute_and_speakers
(
struct
siso_watch
*
w
)
{
struct
show_mute_and_speakers_config
*
c
=
w
->
userdata
;
midi_button_led
(
c
->
sp
->
seq
,
c
->
sp
->
port
,
c
->
button_mute
,
w
->
mute
?
BUTTON_LED_ON
:
BUTTON_LED_OFF
);
...
...
@@ -53,6 +62,36 @@ void encoder_volume(enum encoder encoder, int delta, void *userdata) {
xpa_sink_input_set_volume
(
w
,
delta
/
100
.
0
f
);
}
static
gboolean
on_fav_info
(
GIOChannel
*
source
,
GIOCondition
condition
,
gpointer
data
)
{
struct
fav_config
*
fc
=
data
;
char
*
line
;
size_t
len
;
g_io_channel_read_line
(
source
,
&
line
,
&
len
,
NULL
,
NULL
);
if
(
len
<
13
||
memcmp
(
line
,
"playing song"
,
12
)
==
0
)
{
char
*
hash
=
strtok
(
&
line
[
13
],
" "
);
if
(
fc
->
hash
)
free
(
fc
->
hash
);
fc
->
hash
=
strdup
(
hash
);
}
if
(
len
<
20
||
memcmp
(
line
,
"playing favorite"
,
16
)
==
0
)
{
fc
->
is_fav
=
strcmp
(
&
line
[
17
],
"true
\n
"
)
==
0
;
midi_button_led
(
fc
->
sp
->
seq
,
fc
->
sp
->
port
,
fc
->
button
,
fc
->
is_fav
?
BUTTON_LED_ON
:
BUTTON_LED_OFF
);
}
g_free
(
line
);
return
TRUE
;
}
void
button_fav
(
enum
button
button
,
enum
button_direction
direction
,
void
*
userdata
)
{
fprintf
(
stdout
,
"button pressed: %i dir=%i
\n
"
,
button
,
direction
);
if
(
direction
!=
BUTTON_PRESS
)
return
;
struct
fav_config
*
fc
=
userdata
;
char
buf
[
1024
];
const
char
*
verb
=
fc
->
is_fav
?
"DELETE"
:
"PUT"
;
int
n
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s favorites/%s/%s
\n
"
,
verb
,
fc
->
username
,
fc
->
hash
);
fwrite
(
buf
,
n
,
1
,
stderr
);
write
(
fc
->
stdin
,
buf
,
n
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
2
)
{
fprintf
(
stderr
,
"usage: %s CLIENT_ID
\n
"
,
argv
[
0
]);
...
...
@@ -92,6 +131,29 @@ int main(int argc, char *argv[]) {
button_callback_add
(
BOTTOM2
,
button_sink
,
mpv
);
encoder_callback_add
(
ENC2
,
encoder_volume
,
mpv
);
gchar
*
args
[]
=
{
"stewdio-textcmd"
,
"https://radio.stew.moe/api/"
,
"minus"
,
NULL
};
int
child_stdout
,
child_stdin
;
g_autoptr
(
GError
)
error
=
NULL
;
g_spawn_async_with_pipes
(
NULL
,
args
,
NULL
,
G_SPAWN_SEARCH_PATH
,
NULL
,
NULL
,
NULL
,
&
child_stdin
,
&
child_stdout
,
NULL
,
&
error
);
if
(
error
!=
NULL
)
{
g_error
(
"Spawning child failed: %s"
,
error
->
message
);
return
-
1
;
}
struct
fav_config
fc
=
{
.
sp
=
&
sp
,
.
button
=
BOTTOM7
,
.
username
=
"minus"
,
.
stdin
=
child_stdin
,
};
GIOChannel
*
ch
=
g_io_channel_unix_new
(
child_stdout
);
guint
evsrcid
=
g_io_add_watch
(
ch
,
G_IO_IN
,
&
on_fav_info
,
&
fc
);
button_callback_add
(
BOTTOM7
,
button_fav
,
&
fc
);
pa
();
GMainLoop
*
main_loop
=
g_main_loop_new
(
NULL
,
FALSE
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment