Linux Mint Corners 音楽シーケンス連想配列

Linux Mint Corners 音楽シーケンス連想配列

私は次のようなスクリプトを書いています。ホットコーナーは、コーナーの上にマウスを置くと特定のノートを再生し、音楽シーケンスに基づいて特定のコマンドを実行します。

左下から-d、bから右から-e、左上から-g、右上から-bパラメータを使用してスクリプトを呼び出すと、シーケンスがファイル(for_hot)に追加され、シーケンスが私の連想配列比較と比較されます。します。シーケンスが認識されると、ミュージカルB ''が正常に再生されます。

質問2:

時にはコマンドが実行されないことがあります。

電源を切ることができません。

これはスクリプトです。

#!/bin/bash

#switch###############################
case "$1" in
-d) play -q -n synth 3 pluck 293.665 &
sleep 0.5
echo -n "d" >> ~/bin/for_hot;
;;
-e) play -q -n synth 3 pluck 311.127 &
sleep 0.5
echo -n "e" >> ~/bin/for_hot;
;;
-g) play -q -n synth 3 pluck 391.995 &
sleep 0.5
echo -n "g" >> ~/bin/for_hot;
;;
-b) play -q -n synth 3 pluck 466.164 &
sleep 0.5
echo -n "b" >> ~/bin/for_hot;
;;
esac
######################################

#midi mappings########################
declare -A commands
commands=( 
["egbd"]="firefox -n" 
["ebgb"]="idea" 
["ebb"]="notify-send "$instr "" 
["egdgb"]="echo pass | sudo -S poweroff"
["ee"]="nemo /home/mintbwoy");
######################################


s=$(<~/bin/for_hot);

for pattern in "${!commands[@]}";
do
echo "$pattern - ${commands["$pattern"]}";

if [[ "$s" == *"$pattern"* ]]
then
echo -n "" > ~/bin/for_hot;
play -q -n synth 3 pluck 932.328 &
var=$(${commands["$s"]});
$var;
notify-send "[$pattern] = ${commands["$pattern"]} "$var"";
fi

done
######################################

ベストアンサー1

おすすめ記事