From c30d4a74001e1b61fb64a8716bcc957ff657b169 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Fri, 18 Nov 2022 16:28:40 -0800 Subject: [PATCH] system-mute swiftbar plugin --- macos/swift-bar/system-mute.30s.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 macos/swift-bar/system-mute.30s.rb diff --git a/macos/swift-bar/system-mute.30s.rb b/macos/swift-bar/system-mute.30s.rb new file mode 100755 index 0000000..fadcafa --- /dev/null +++ b/macos/swift-bar/system-mute.30s.rb @@ -0,0 +1,26 @@ +#!/usr/bin/env ruby + +# true +# true +# true +# true + +require "json" + +muted = `osascript -e "input volume of (get volume settings)"`.to_i.zero? + +unless ARGV.empty? + vol = ARGV.shift + `osascript -e "set volume input volume #{vol}"` + name = File.basename(__FILE__).split(?.)[0..-3].join(?.) + `open swiftbar://refreshplugin?name=#{name}` +end + +icon = [:mic, muted ? :slash : nil, :fill].compact.join(?.) +params = { + symbolize: true, + bash: __FILE__, + param0: muted ? 75 : 0, + terminal: false, +} +puts ":#{icon}: | #{params.map {|k,v| "#{k}=#{v}"}.join(" ")}"