From 3af2b9d97d00d50f5a72528f48b9b04cb8d3ffb5 Mon Sep 17 00:00:00 2001 From: "Rune Juhl (Atea)" Date: Fri, 23 Feb 2024 11:45:12 +0100 Subject: [PATCH] Output emojis matching sound card profile --- toggle_headset | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/toggle_headset b/toggle_headset index fd96ef6..6d2654b 100755 --- a/toggle_headset +++ b/toggle_headset @@ -40,6 +40,11 @@ (map :name) ))) +(defn profile->emoji [profile] + (if (re-find #"a2dp" (name profile)) + "🎧" + "🎤")) + (defn toggle-card-profile [card] (let [current (get-card-current-profile card) profiles (get-card-profiles card)] @@ -47,7 +52,12 @@ (if-let [next-profile (some->> profiles (remove (partial = current)) first)] - (sh "pactl" "set-card-profile" card (name next-profile)) + (do + (sh "pactl" "set-card-profile" card (name next-profile)) + (profile->emoji next-profile)) (prn "Error selecting next profile")))) -(toggle-card-profile (get-current-sink-name)) +(case (some->> *command-line-args* + first) + "get" (println (profile->emoji (get-card-current-profile (get-current-sink-name)))) + "toggle" (println (toggle-card-profile (get-current-sink-name))))