-
Notifications
You must be signed in to change notification settings - Fork 3
/
msteams.lua
41 lines (36 loc) · 1.23 KB
/
msteams.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--
-- MS Teams (new version) mute by pressing ESCAPE when Teams is active
--
local appname_for_trigger = "Microsoft Teams"
-- Hotkey setup
local teamsHotkey = hs.hotkey.new("", "escape", nil, function()
-- Must send to the "Helper"
local app = hs.application.find("com.microsoft.teams2")
hs.eventtap.event.newKeyEvent({ "shift", "cmd" }, "m", true):post(app)
end, nil, nil)
--
-- Install watcher for MS Teams
--
function applicationWatcher(appName, eventType)
-- App focused
if appName and eventType == hs.application.watcher.activated then
if string.match(appName, appname_for_trigger) then
teamsHotkey:enable()
end
end
-- App lost focus
-- App terminated
if eventType == hs.application.watcher.deactivated or eventType == hs.application.watcher.terminated then
if appName and string.match(appName, appname_for_trigger) then
teamsHotkey:disable()
end
end
end
-- selene: allow(unscoped_variables)
-- selene: allow(unused_variable)
appWatcherTeams = hs.application.watcher.new(applicationWatcher)
appWatcherTeams:start()
--- If teams is already running:
if hs.appfinder.appFromWindowTitlePattern(appname_for_trigger) ~= nil then
applicationWatcher(appname_for_trigger, hs.application.watcher.launched)
end