Skip to content
Snippets Groups Projects
Commit 30c59574 authored by Florian Meißner's avatar Florian Meißner
Browse files

Merge branch 'main' of git.informatik.fh-nuernberg.de:meissnerfl73755/scripts

parents 3dbefee5 1b2e0b42
No related branches found
No related tags found
No related merge requests found
#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;
}
...@@ -22,8 +22,10 @@ args=( # set protocol to globalprotect - probably don't change this ...@@ -22,8 +22,10 @@ args=( # set protocol to globalprotect - probably don't change this
# --passwd-on-stdin # --passwd-on-stdin
# override routing for common servers # override routing for common servers
--resolve fsin.th-nuernberg.de:141.75.149.145 # but servers are not used anymore
--resolve fstest.th-nuernberg.de:141.75.149.143 # and anyway this setting has never worked
# --resolve fsin.th-nuernberg.de:141.75.149.145
# --resolve fstest.th-nuernberg.de:141.75.149.143
# --servercert 'pin-sha256:lm+C0Qgm7ZTPMLZ7KJlRLk5teQGc9qhmGfZavlRv3eQ=' # --servercert 'pin-sha256:lm+C0Qgm7ZTPMLZ7KJlRLk5teQGc9qhmGfZavlRv3eQ='
) )
......
wake.sh 0 → 100755
#!/usr/bin/env fish
set AUDIO_CARD alsa_card.pci-0000_00_1b.0
set AUDIO_PROFILE output:analog-stereo+input:analog-stereo
set AUDIO_SINK_BASE (string replace card output $AUDIO_CARD)
# --------------------------------------------------------------------------
# https://github.com/fish-shell/fish-shell/issues/5202#issuecomment-423474342
status job-control full
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
# when - date formatted string for target datetime
argparse --name wake --min-args 1 'd/delta=' 'w/when=' -- $argv
set -q _flag_when _flag_delta || exit 1
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 $AUDIO_CARD $AUDIO_PROFILE
set sink (pactl list sinks | string match --regex --groups-only 'Name:\s+('(string escape --style regex $AUDIO_SINK_BASE)'\S+)')
pactl set-default-sink $sink
mpv --loop-playlist $argv &
for i in (LC_NUMERIC= seq -40 0.4 0) #dB
set vol ($dB_to_vol $i)
echo $i '=>' $vol
pactl set-sink-volume $sink $vol
sleep $_flag_delta
end
fg
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment