Skip to content

Commit 85272b3

Browse files
authored
Merge pull request #31 from Avivbens/feat/noise-cancellation-workflow
2 parents 59c980c + ec7b69f commit 85272b3

File tree

12 files changed

+280
-0
lines changed

12 files changed

+280
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const { resolve } = require('node:path');
2+
const { author, description, homepage } = require('./package.json');
3+
const { env } = require('node:process');
4+
5+
const README = `
6+
#### Thank you for using Noise Cancellation! ✨
7+
8+
## Features
9+
10+
Toggle noise cancellation on and off directly from Alfred.
11+
Currently, MacOS 26 does not provide a public API for noise cancellation, so this workflow uses private APIs with AppleScripts. Use at your own risk!
12+
13+
## Usage
14+
15+
Use the keyword \`nct\` to toggle noise cancellation on or off.
16+
17+
To view the workflow codebase, click here:
18+
${homepage}
19+
`.trim();
20+
21+
/**
22+
* @type {import('fast-alfred').FastAlfredConfig}
23+
*/
24+
module.exports = {
25+
bundlerOptions: {
26+
targetDir: resolve(__dirname, '../../../', 'dist', env.NX_TASK_TARGET_PROJECT, 'esbuild'),
27+
},
28+
workflowMetadata: {
29+
name: 'Noise Cancellation',
30+
createdby: author.name,
31+
webaddress: homepage,
32+
description,
33+
readme: README,
34+
},
35+
tabSize: 2,
36+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div align="center">
2+
3+
# Alfred Noise Cancellation
4+
5+
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/kcao7snkgx)
6+
7+
</div>
8+
9+
## Description
10+
11+
Toggle noise cancellation on and off directly from Alfred.
12+
13+
> **Note:** Currently, MacOS 26 does not provide a public API for noise cancellation, so this workflow uses private APIs with AppleScripts. Use at your own risk!
14+
15+
## Usage
16+
17+
Use the keyword `nct` to toggle noise cancellation on or off.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { defineConfig } from 'eslint/config';
2+
import rootConfig from '../../../eslint.config.mjs';
3+
4+
export default defineConfig([rootConfig]);
27.2 KB
Loading
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>bundleid</key>
6+
<string>com.alfredapp.avivbens.noise-cancellation</string>
7+
<key>category</key>
8+
<string>Tools</string>
9+
<key>connections</key>
10+
<dict>
11+
<key>172F9A79-83D6-48B6-ADC5-BBA3E2F2D447</key>
12+
<array>
13+
<dict>
14+
<key>destinationuid</key>
15+
<string>FDD54B33-1C83-4284-BB56-48B893CEFC88</string>
16+
<key>modifiers</key>
17+
<integer>0</integer>
18+
<key>modifiersubtext</key>
19+
<string></string>
20+
<key>vitoclose</key>
21+
<false></false>
22+
</dict>
23+
</array>
24+
</dict>
25+
<key>createdby</key>
26+
<string>Aviv Ben Shahar</string>
27+
<key>description</key>
28+
<string>Toggle noise cancellation on and off from Alfred</string>
29+
<key>disabled</key>
30+
<false></false>
31+
<key>name</key>
32+
<string>Noise Cancellation</string>
33+
<key>objects</key>
34+
<array>
35+
<dict>
36+
<key>config</key>
37+
<dict>
38+
<key>argumenttype</key>
39+
<integer>2</integer>
40+
<key>keyword</key>
41+
<string>nct</string>
42+
<key>subtext</key>
43+
<string></string>
44+
<key>text</key>
45+
<string>Toggle Noise Cancellation</string>
46+
<key>withspace</key>
47+
<false></false>
48+
</dict>
49+
<key>type</key>
50+
<string>alfred.workflow.input.keyword</string>
51+
<key>uid</key>
52+
<string>172F9A79-83D6-48B6-ADC5-BBA3E2F2D447</string>
53+
<key>version</key>
54+
<integer>1</integer>
55+
</dict>
56+
<dict>
57+
<key>config</key>
58+
<dict>
59+
<key>concurrently</key>
60+
<false></false>
61+
<key>escaping</key>
62+
<integer>102</integer>
63+
<key>script</key>
64+
<string>-- CONFIGURATION VARIABLES (User Settable) --
65+
set cc_localization_string to "Sound"
66+
67+
-- AirPods Listening Mode Checkboxes (counting only checkboxes)
68+
-- Checkbox 3 = Off, 4 = Transparency, 5 = Adaptive, 6 = Noise Cancellation
69+
set transparency_checkbox_index to 4
70+
set noise_cancellation_checkbox_index to 6
71+
---------------------------------------------
72+
73+
tell application "System Events"
74+
tell application process "ControlCenter"
75+
76+
-- Open Sound Menu
77+
click (first UI element of menu bar 1 whose description starts with cc_localization_string)
78+
delay 0.3
79+
80+
-- Toggle Logic
81+
try
82+
set transparencyCheckbox to checkbox transparency_checkbox_index of scroll area 1 of group 1 of window 1
83+
set noiseCancellationCheckbox to checkbox noise_cancellation_checkbox_index of scroll area 1 of group 1 of window 1
84+
85+
if value of transparencyCheckbox is 1 then
86+
click noiseCancellationCheckbox
87+
else
88+
click transparencyCheckbox
89+
end if
90+
91+
on error errMsg number errNum
92+
display dialog "Error: " &amp; errNum &amp; ": " &amp; errMsg
93+
end try
94+
delay 0.1
95+
96+
-- Close Control Center
97+
click (first UI element of menu bar 1 whose description starts with cc_localization_string)
98+
delay 0.01
99+
100+
end tell
101+
end tell</string>
102+
<key>scriptargtype</key>
103+
<integer>1</integer>
104+
<key>scriptfile</key>
105+
<string></string>
106+
<key>type</key>
107+
<integer>6</integer>
108+
</dict>
109+
<key>type</key>
110+
<string>alfred.workflow.action.script</string>
111+
<key>uid</key>
112+
<string>FDD54B33-1C83-4284-BB56-48B893CEFC88</string>
113+
<key>version</key>
114+
<integer>2</integer>
115+
</dict>
116+
</array>
117+
<key>readme</key>
118+
<string>#### Thank you for using Noise Cancellation! ✨
119+
120+
## Features
121+
122+
Toggle noise cancellation on and off directly from Alfred.
123+
Currently, MacOS 26 does not provide a public API for noise cancellation, so this workflow uses private APIs with AppleScripts. Use at your own risk!
124+
125+
## Usage
126+
127+
Use the keyword `nct` to toggle noise cancellation on or off.
128+
129+
To view the workflow codebase, click here:
130+
https://github.com/Avivbens/alfredo</string>
131+
<key>uidata</key>
132+
<dict>
133+
<key>172F9A79-83D6-48B6-ADC5-BBA3E2F2D447</key>
134+
<dict>
135+
<key>xpos</key>
136+
<integer>140</integer>
137+
<key>ypos</key>
138+
<integer>185</integer>
139+
</dict>
140+
<key>FDD54B33-1C83-4284-BB56-48B893CEFC88</key>
141+
<dict>
142+
<key>xpos</key>
143+
<integer>475</integer>
144+
<key>ypos</key>
145+
<integer>185</integer>
146+
</dict>
147+
</dict>
148+
<key>userconfigurationconfig</key>
149+
<array></array>
150+
<key>webaddress</key>
151+
<string>https://github.com/Avivbens/alfredo</string>
152+
<key>version</key>
153+
<string>1.0.0</string>
154+
</dict>
155+
</plist>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "noise-cancellation",
3+
"version": "1.0.0",
4+
"description": "Toggle noise cancellation on and off from Alfred",
5+
"keywords": [
6+
"alfred",
7+
"workflow",
8+
"noise cancellation",
9+
"toggle",
10+
"MacOS 26"
11+
],
12+
"homepage": "https://github.com/Avivbens/alfredo",
13+
"author": {
14+
"name": "Aviv Ben Shahar",
15+
"email": "avivbens87@gmail.com"
16+
}
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "noise-cancellation",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "{projectRoot}/src",
5+
"projectType": "application",
6+
"tags": [],
7+
"targets": {
8+
"build": {
9+
"defaultConfiguration": "local"
10+
},
11+
"serve": {},
12+
"lint": {
13+
"executor": "nx:noop"
14+
}
15+
}
16+
}

projects/packages/noise-cancellation/src/.gitkeep

Whitespace-only changes.

projects/packages/noise-cancellation/src/main/.gitkeep

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"types": ["node"],
6+
"target": "es2021"
7+
},
8+
"include": ["src/**/*.ts"],
9+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10+
}

0 commit comments

Comments
 (0)