Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7b9d999
add safari support,tested and is working
bugparty May 16, 2025
3817c87
feat: add Safari build support to CI workflow
bugparty May 17, 2025
45bde99
fix: remove unesaary safari isTesting flags
bugparty May 17, 2025
de164a7
chore: remove unnecessary blank line in manifest.json
bugparty May 17, 2025
8cc6b06
feat: add Safari build targets to Makefile
bugparty May 17, 2025
947afa9
fix: update bundle identifier and Xcode project path in CI workflow
bugparty May 17, 2025
9cca4c0
fix ci
bugparty May 17, 2025
db3a0d4
fix ci
bugparty May 17, 2025
9b23740
fix
bugparty May 17, 2025
364cacb
more debug
bugparty May 17, 2025
a716a02
list xcode schema
bugparty May 17, 2025
970bae7
fix: update Xcode scheme in CI workflow
bugparty May 17, 2025
3d3aa0e
chore: update artifact upload path in CI workflow
bugparty May 17, 2025
09f3d27
chore: remove deprecated Xcode project files and resources
bugparty May 17, 2025
ad62354
docs: add instructions for building and enabling Safari extension
bugparty May 17, 2025
1efb0d4
chore: update README for Safari extension build instructions and remo…
bugparty May 17, 2025
cdd0e8d
docs: improve formatting in README for Safari extension build instruc…
bugparty May 17, 2025
3a6e53e
chore: update artifact paths in CI workflow to include Safari zip file
bugparty May 17, 2025
7fb053c
Update README.md
bugparty May 17, 2025
307e40b
Update .github/workflows/build.yml
bugparty May 17, 2025
add8fb0
chore: add test for reproducibility of Safari build artifacts
bugparty May 17, 2025
c659cb2
Update Makefile
bugparty May 19, 2025
4d05938
Update README.md
bugparty May 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,42 @@ jobs:
path: artifacts/chrome.zip
- name: Check reproducibility from src-zip
run: make test-reproducibility-chrome
build-safari:
runs-on: macos-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build Safari
run: make build-safari

- name: Check reproducibility from src-zip
run: make test-reproducibility-firefox

- name: Convert Chrome Extension to Safari
run: |
xcrun safari-web-extension-converter ./build \
--project-location . \
--bundle-identifier net.activitywatch.activitywatchwebwatcher \
--macos-only \
--force

- name: Build Xcode Project
run: |
xcodebuild -project "ActivityWatch Web Watcher/ActivityWatch Web Watcher.xcodeproj" -list
xcodebuild -project "ActivityWatch Web Watcher/ActivityWatch Web Watcher.xcodeproj" \
-scheme "ActivityWatch Web Watcher" \
-configuration Release \
clean build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: safari
path: |
~/Library/Developer/Xcode/DerivedData/**/Build/Products/Release/
artifacts/safari.zip
typecheck:
runs-on: ubuntu-latest

Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ build-firefox: install update-firefox zip-build-firefox
update-firefox:
VITE_TARGET_BROWSER=firefox npx vite build

# Add Safari build targets
build-safari: install update-safari zip-build-safari

update-safari:
VITE_TARGET_BROWSER=safari npx vite build

#---------
## Zipping

Expand All @@ -40,6 +46,9 @@ zip-build-chrome:
zip-build-firefox:
mkdir -p artifacts && cd build && zip -FS ../artifacts/firefox.zip -r *

zip-build-safari:
mkdir -p artifacts && cd build && zip -FS ../artifacts/safari.zip -r *

# To build a source archive, wanted by Mozilla reviewers. Include media subdir.
# NOTE: we include the .git in the media archive so that it lines up with the output
# of vite
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,40 @@ This will create zip files in the `artifacts` directory:
- `artifacts/firefox.zip` for Firefox
- `artifacts/chrome.zip` for Chrome

## if you want to build safari version

1. First follow the steps above to build the extension:

```sh
make install
make build-safari
```

2. Convert the extension to Safari format:

```sh
xcrun safari-web-extension-converter ./build
```

after finished, xcode will open automatively.

3. In Xcode:

- Select build target of Macos
- Build the project (⌘B)
- Run the extension (⌘R)

4. Enable the extension in Safari:
- Open Safari
- Go to Safari > Settings > Extensions
- Enable "aw-watcher-web"

> [!NOTE]
>
> - You need Xcode installed to build Safari extensions
> - The extension needs to be signed with your Apple Developer account
> - Safari extensions require macOS 11.0 or later

### Installing the Development Build

#### Chrome
Expand Down
5 changes: 4 additions & 1 deletion src/consent/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { setConsentStatus, setEnabled } from '../storage'

const consentRefused = document.getElementById('consent-refused')!
consentRefused.addEventListener('click', () => {
browser.management.uninstallSelf()
// Conditionally uninstall if not Safari
if (import.meta.env.VITE_TARGET_BROWSER !== 'safari') {
browser.management.uninstallSelf()
}
window.close()
})

Expand Down
16 changes: 15 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"{{chrome}}.manifest_version": 3,
"{{firefox}}.manifest_version": 2,
"{{safari}}.manifest_version": 3,

"name": "ActivityWatch Web Watcher",
"description": "Log the current tab and your browser activity with ActivityWatch.",
Expand All @@ -17,11 +18,16 @@
"default_icon": "logo-128.png",
"default_popup": "src/popup/index.html"
},
"{{safari}}.action": {
"default_icon": { "128": "logo-128.png" },
"default_popup": "src/popup/index.html"
},

"background": {
"{{chrome}}.service_worker": "src/background/main.ts",
"{{firefox}}.scripts": ["src/background/main.ts"],
"{{firefox}}.persistent": true
"{{firefox}}.persistent": true,
"{{safari}}.service_worker": "src/background/main.ts"
},

"options_ui": {
Expand All @@ -44,7 +50,15 @@
"activeTab",
"storage"
],
"{{safari}}.permissions": [
"tabs",
"alarms",
"notifications",
"activeTab",
"storage"
],
"{{chrome}}.host_permissions": ["<all_urls>"],
"{{safari}}.host_permissions": ["<all_urls>"],

"{{firefox}}.browser_specific_settings": {
"gecko": {
Expand Down
1 change: 1 addition & 0 deletions src/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<select id="browser" name="browser">
<option value="chrome">Chrome</option>
<option value="firefox">Firefox</option>
<option value="safari">Safari</option>
<option value="opera">Opera</option>
<option value="brave">Brave</option>
<option value="edge">Edge</option>
Expand Down