This commit is contained in:
parent
41efe10dd4
commit
52e9726ba7
@ -3,7 +3,7 @@
|
|||||||
config = lib.mkIf (config.homecfg.make.gui) {
|
config = lib.mkIf (config.homecfg.make.gui) {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
custom.vosk.base
|
custom.vosk.base
|
||||||
jq
|
jaq
|
||||||
(python3.withPackages (ps: with ps; [ translatepy ]))
|
(python3.withPackages (ps: with ps; [ translatepy ]))
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -46,13 +46,13 @@
|
|||||||
export VOSK_MODEL=$MODEL
|
export VOSK_MODEL=$MODEL
|
||||||
case $TRANS in
|
case $TRANS in
|
||||||
"None")
|
"None")
|
||||||
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' 2>/dev/null
|
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jaq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' 2>/dev/null
|
||||||
;;
|
;;
|
||||||
"None-prog")
|
"None-prog")
|
||||||
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty, .partial // empty | select(length > 0)' 2>/dev/null
|
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jaq --unbuffered -r '.alternatives[0].text // empty, .partial // empty | select(length > 0)' 2>/dev/null
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' | python ~/.config/script/transcript-translate.py $TRANS
|
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jaq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' | python ~/.config/script/transcript-translate.py $TRANS
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
'';
|
'';
|
||||||
|
@ -19,11 +19,11 @@ PAUSED=$(( $PID == 0 || $RADIO_ID == 0 ? 1 : 0 ))
|
|||||||
STATUS="{}"
|
STATUS="{}"
|
||||||
|
|
||||||
get_radio() {
|
get_radio() {
|
||||||
echo "$STATIONS" | jq -r --argjson sel_id "$RADIO_ID" 'map(select(.id == $sel_id)).[0]'
|
echo "$STATIONS" | jaq -r --argjson sel_id "$RADIO_ID" 'map(select(.id == $sel_id)).[0]'
|
||||||
}
|
}
|
||||||
|
|
||||||
get_song() {
|
get_song() {
|
||||||
echo $(curl -s "$URL_BASE/station/history/?id=$RADIO_ID" | jq '.result.history[0] | ({id, artist, song, image600})')
|
echo $(curl -s "$URL_BASE/station/history/?id=$RADIO_ID" | jaq '.result.history[0] | ({id, artist, song, image600})')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
STATIONS=$(curl -s "$URL_BASE/stations/" | jq --argjson ids '[507,522,523,536,537,42532,42602]' '.result.stations | map(select(.id | IN($ids[]))) | map({id, title, stream_hls, icon_fill_white})')
|
STATIONS=$(curl -s "$URL_BASE/stations/" | jaq --argjson ids '[507,522,523,536,537,42532,42602]' '.result.stations | map(select(.id | IN($ids[]))) | map({id, title, stream_hls, icon_fill_white})')
|
||||||
RADIO_URL=$(get_radio | jq -r '.stream_hls')
|
RADIO_URL=$(get_radio | jaq -r '.stream_hls')
|
||||||
if [ "$PAUSED" = 0 ]; then
|
if [ "$PAUSED" = 0 ]; then
|
||||||
kill -9 $PID
|
kill -9 $PID
|
||||||
fi
|
fi
|
||||||
@ -55,14 +55,14 @@ toggle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
status() {
|
status() {
|
||||||
echo $(jq -cnr --argjson pid "$PID" --argjson stations "$STATIONS" --argjson radio_id "$RADIO_ID" --argjson is_paused "$PAUSED" --argjson info "$INFO" '{"is_paused": $is_paused, "song": $info, "radio": $radio_id, "stations": $stations}')
|
echo $(jaq -cnr --argjson pid "$PID" --argjson stations "$STATIONS" --argjson radio_id "$RADIO_ID" --argjson is_paused "$PAUSED" --argjson info "$INFO" '{"is_paused": $is_paused, "song": $info, "radio": $radio_id, "stations": $stations}')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_loop() {
|
status_loop() {
|
||||||
STATUS=$(status)
|
STATUS=$(status)
|
||||||
echo $STATUS
|
echo $STATUS
|
||||||
STATIONS=$(curl -s "$URL_BASE/stations/" | jq --argjson ids '[507,522,523,536,537,42532,42602]' '.result.stations | map(select(.id | IN($ids[]))) | map({id, title, stream_hls, icon_fill_white})')
|
STATIONS=$(curl -s "$URL_BASE/stations/" | jaq --argjson ids '[507,522,523,536,537,42532,42602]' '.result.stations | map(select(.id | IN($ids[]))) | map({id, title, stream_hls, icon_fill_white})')
|
||||||
last_time_info=0
|
last_time_info=0
|
||||||
last_time=0
|
last_time=0
|
||||||
while true; do
|
while true; do
|
||||||
@ -82,9 +82,9 @@ status_loop() {
|
|||||||
fi
|
fi
|
||||||
if [[ $delta_i -gt 15000 ]]; then
|
if [[ $delta_i -gt 15000 ]]; then
|
||||||
if [ "$PAUSED" = 1 ]; then
|
if [ "$PAUSED" = 1 ]; then
|
||||||
INFO="{\"id\":null,\"artist\":null,\"song\":null,\"image600\": \"$(get_radio | jq -r '.icon_fill_white')\"}"
|
INFO="{\"id\":null,\"artist\":null,\"song\":null,\"image600\": \"$(get_radio | jaq -r '.icon_fill_white')\"}"
|
||||||
else
|
else
|
||||||
INFO=$(echo "$INFO" "$(get_song)" | jq -s ' reduce .[] as $item ( {}; . + (
|
INFO=$(echo "$INFO" "$(get_song)" | jaq -s ' reduce .[] as $item ( {}; . + (
|
||||||
reduce ($item | to_entries[]) as $entry ( {}; if $entry.value != null then .[$entry.key] = $entry.value else . end
|
reduce ($item | to_entries[]) as $entry ( {}; if $entry.value != null then .[$entry.key] = $entry.value else . end
|
||||||
)) )')
|
)) )')
|
||||||
fi
|
fi
|
||||||
|
@ -7,7 +7,7 @@ let
|
|||||||
pkgs.writeShellScriptBin "waybar-${name}" ''
|
pkgs.writeShellScriptBin "waybar-${name}" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${pre}
|
${pre}
|
||||||
${pkgs.jq}/bin/jq -cn \
|
${pkgs.jaq}/bin/jaq -cn \
|
||||||
--arg text "${text}" \
|
--arg text "${text}" \
|
||||||
--arg tooltip "${tooltip}" \
|
--arg tooltip "${tooltip}" \
|
||||||
--arg alt "${alt}" \
|
--arg alt "${alt}" \
|
||||||
@ -19,7 +19,7 @@ let
|
|||||||
in {
|
in {
|
||||||
config = lib.mkIf (config.homecfg.wm == "Wayland") {
|
config = lib.mkIf (config.homecfg.wm == "Wayland") {
|
||||||
|
|
||||||
home.packages = [ pkgs.custom.amdgpu_top pkgs.jq ];
|
home.packages = [ pkgs.custom.amdgpu_top pkgs.jaq ];
|
||||||
|
|
||||||
programs.waybar = {
|
programs.waybar = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@ -204,7 +204,7 @@ in {
|
|||||||
"exec" = jsonOutput "gpu" {
|
"exec" = jsonOutput "gpu" {
|
||||||
tooltip = "...";
|
tooltip = "...";
|
||||||
percentage = ''
|
percentage = ''
|
||||||
$(amdgpu_top -J -n 1 | jq -r '.devices[0].GRBM2."Command Processor - Graphics".value')'';
|
$(amdgpu_top -J -n 1 | jaq -r '.devices[0].GRBM2."Command Processor - Graphics".value')'';
|
||||||
};
|
};
|
||||||
"return-type" = "json";
|
"return-type" = "json";
|
||||||
"interval" = 5;
|
"interval" = 5;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user