Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Meißner
Scripts
Commits
682b9429
Commit
682b9429
authored
Sep 24, 2023
by
Florian Meissner
Browse files
Options
Downloads
Patches
Plain Diff
wait: increase dB linearly
parent
d2bd445b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
helpers/wake/dB_to_volume.c
+29
-0
29 additions, 0 deletions
helpers/wake/dB_to_volume.c
wake.sh
+12
-2
12 additions, 2 deletions
wake.sh
with
41 additions
and
2 deletions
helpers/wake/dB_to_volume.c
0 → 100644
+
29
−
0
View file @
682b9429
#include
<assert.h>
#include
<stdio.h>
#include
<errno.h>
#include
<stdlib.h>
#include
<pulse/volume.h>
int
main
(
int
argc
,
char
**
argv
)
{
assert
(
argc
==
2
);
errno
=
0
;
char
*
endptr
;
double
dB
=
strtod
(
argv
[
1
],
&
endptr
);
if
(
errno
!=
0
||
*
endptr
!=
'\0'
)
{
fprintf
(
stderr
,
"Failed to parse dB value
\n
"
);
return
1
;
}
// somehow pa_sw_volume_from_dB returns approx. power of db/3
uint32_t
volume
=
pa_sw_volume_from_dB
(
dB
*
3
);
// double vol_out = pa_sw_volume_to_linear(volume);
// printf("%f\n", vol_out);
printf
(
"%f
\n
"
,
((
double
)
volume
)
/
65536
.
0
);
return
0
;
}
This diff is collapsed.
Click to expand it.
wake.sh
+
12
−
2
View file @
682b9429
#!/usr/bin/env fish
#!/usr/bin/env fish
set
dB_to_vol
(
mktemp
)
gcc
-lpulse
-o
$dB_to_vol
~/scripts/helpers/wake/dB_to_volume.c
||
begin
;
echo
'gcc failed on dB_to_volume.c; status = '
$status
;
exit
1
;
end
;
# delta - time between 0.01 increase
# delta - time between 0.01 increase
# when - date formatted string for target datetime
# when - date formatted string for target datetime
argparse
--name
wake
--min-args
1
'd/delta='
'w/when='
--
$argv
argparse
--name
wake
--min-args
1
'd/delta='
'w/when='
--
$argv
...
@@ -7,12 +10,19 @@ set -q _flag_when _flag_delta || exit 1
...
@@ -7,12 +10,19 @@ set -q _flag_when _flag_delta || exit 1
sudo
rtcwake
-m
mem
-u
-t
$(
date
+%s
-d
$_flag_when
)
sudo
rtcwake
-m
mem
-u
-t
$(
date
+%s
-d
$_flag_when
)
# set to analog profile
# also sink name changes with profile. TODO match only part of profile name
pactl set-card-profile alsa_card.pci-0000_00_1b.0 output:analog-stereo+input:analog-stereo
set
sink
(
pactl list sinks | string match
--regex
--groups-only
'Name:\s+(alsa_output.pci-0000_00_1b.0\S+)'
)
pactl set-default-sink
$sink
mpv
--loop-playlist
$argv
&
mpv
--loop-playlist
$argv
&
# TODO catch Ctrl+C or do sth that volume raising is interruptible but we still get mpv console
# TODO catch Ctrl+C or do sth that volume raising is interruptible but we still get mpv console
for
i
in
(
LC_NUMERIC
=
seq
0.01 0.01 1
)
pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo.3
$i
for
i
in
(
LC_NUMERIC
=
seq
-40
0.4 0
)
#dB
pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo.3
(
$dB_to_vol
$i
)
sleep
$_flag_delta
sleep
$_flag_delta
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment