Skip to content

Commit 6561550

Browse files
committed
2 parents e19069d + 7ff17af commit 6561550

12 files changed

Lines changed: 213 additions & 89 deletions

File tree

.github/workflows/build-nightly.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- main
77
workflow_dispatch:
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
permissions:
1014
contents: write
1115

@@ -20,7 +24,7 @@ jobs:
2024
- name: Set up Node.js
2125
uses: actions/setup-node@v4
2226
with:
23-
node-version: '20'
27+
node-version: '22'
2428

2529
- name: Install dependencies
2630
run: npm ci
@@ -44,7 +48,7 @@ jobs:
4448
- name: Set up Node.js
4549
uses: actions/setup-node@v4
4650
with:
47-
node-version: '20'
51+
node-version: '22'
4852

4953
- name: Install dependencies
5054
run: npm ci
@@ -58,6 +62,31 @@ jobs:
5862
name: glancething-nightly-macos-${{ github.ref_name }}
5963
path: ./dist/glancething-nightly-*.dmg
6064

65+
build-linux:
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Checkout the repository
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Node.js
73+
uses: actions/setup-node@v4
74+
with:
75+
node-version: '22'
76+
77+
- name: Install dependencies
78+
run: npm ci
79+
80+
- name: Build the project
81+
run: npm run build:linux:nightly
82+
83+
- name: Upload artifact
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: glancething-nightly-linux-${{ github.ref_name }}
87+
path: ./dist/glancething-nightly-*.AppImage
88+
89+
6190
build-client:
6291
runs-on: ubuntu-latest
6392
defaults:
@@ -71,7 +100,7 @@ jobs:
71100
- name: Set up Node.js
72101
uses: actions/setup-node@v4
73102
with:
74-
node-version: '20'
103+
node-version: '22'
75104

76105
- name: Install dependencies
77106
run: npm ci

.github/workflows/build-release.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Node.js
2020
uses: actions/setup-node@v4
2121
with:
22-
node-version: '20'
22+
node-version: '22'
2323

2424
- name: Install dependencies
2525
run: npm ci
@@ -49,7 +49,7 @@ jobs:
4949
- name: Set up Node.js
5050
uses: actions/setup-node@v4
5151
with:
52-
node-version: '20'
52+
node-version: '22'
5353

5454
- name: Install dependencies
5555
run: npm ci
@@ -69,6 +69,36 @@ jobs:
6969
with:
7070
files: ./dist/glancething-*.dmg
7171

72+
build-linux:
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Checkout the repository
77+
uses: actions/checkout@v4
78+
79+
- name: Set up Node.js
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: '22'
83+
84+
- name: Install dependencies
85+
run: npm ci
86+
87+
- name: Build the project
88+
run: npm run build:linux
89+
90+
- name: Upload artifact
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: glancething-linux-${{ github.ref_name }}
94+
path: ./dist/glancething-*.AppImage
95+
96+
- name: Upload to GitHub Releases
97+
if: github.event_name == 'release' && github.event.action == 'created'
98+
uses: softprops/action-gh-release@v2
99+
with:
100+
files: ./dist/glancething-*.AppImage
101+
72102
build-client:
73103
runs-on: ubuntu-latest
74104
defaults:
@@ -82,7 +112,7 @@ jobs:
82112
- name: Set up Node.js
83113
uses: actions/setup-node@v4
84114
with:
85-
node-version: '20'
115+
node-version: '22'
86116

87117
- name: Install dependencies
88118
run: npm ci

electron-builder.nightly.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ dmg:
3535
linux:
3636
target:
3737
- AppImage
38-
- deb
3938
maintainer: BluDood
4039
category: Utility
4140
appImage:
@@ -47,4 +46,4 @@ publish:
4746
electronDownload:
4847
mirror: https://npmmirror.com/mirrors/electron/
4948
extraMetadata:
50-
name: glancething-nightly
49+
name: glancething-nightly

electron-builder.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ dmg:
3535
linux:
3636
target:
3737
- AppImage
38-
- deb
3938
maintainer: BluDood
4039
category: Utility
4140
appImage:

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
"build:unpack": "npm run build && electron-builder --dir",
1616
"build:win": "npm run build && electron-builder --win",
1717
"build:mac": "npm run build && electron-builder --mac",
18+
"build:linux": "npm run build && electron-builder --linux",
1819
"build:win:nightly": "npm run build && electron-builder --win --config electron-builder.nightly.yml",
19-
"build:mac:nightly": "npm run build && electron-builder --mac --config electron-builder.nightly.yml"
20+
"build:mac:nightly": "npm run build && electron-builder --mac --config electron-builder.nightly.yml",
21+
"build:linux:nightly": "npm run build && electron-builder --linux --config electron-builder.nightly.yml"
2022
},
2123
"dependencies": {
2224
"@electron-toolkit/preload": "^3.0.2",
@@ -57,6 +59,7 @@
5759
},
5860
"optionalDependencies": {
5961
"node-nowplaying-win32-x64-msvc": "0.1.0",
60-
"node-nowplaying-darwin-universal": "0.1.0"
62+
"node-nowplaying-darwin-universal": "0.1.0",
63+
"node-nowplaying-linux-x64-gnu": "0.1.0"
6164
}
6265
}

src/main/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from 'electron'
1313
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
1414
import { join } from 'path'
15-
import os from 'os'
1615

1716
import {
1817
getPlaybackHandlerConfig,
@@ -475,7 +474,7 @@ async function setupIpcHandlers() {
475474

476475
async function setupTray() {
477476
const icon =
478-
os.platform() === 'darwin'
477+
process.platform === 'darwin'
479478
? nativeImage
480479
.createFromPath(`${resourceFolder}/tray.png`)
481480
.resize({ height: 24, width: 24 })
@@ -515,7 +514,7 @@ async function setupTray() {
515514
)
516515

517516
tray.on('click', () => {
518-
if (os.platform() === 'darwin') return
517+
if (process.platform === 'darwin') return
519518
if (mainWindow) {
520519
mainWindow.show()
521520
} else {

src/main/lib/adb.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import path from 'path'
55
import fs from 'fs'
66

77
import {
8+
buildUnzipCommand,
89
execAsync,
910
getLogLevel,
1011
getPlatformADB,
11-
getPlatformTar,
1212
log,
1313
LogLevel
1414
} from './utils.js'
@@ -21,10 +21,15 @@ export async function getAdbExecutable() {
2121

2222
if (res && platform() !== 'darwin') return 'adb'
2323

24-
const { downloadURL, executable } = getPlatformADB()
24+
const adbInfo = getPlatformADB()
25+
if (!adbInfo) {
26+
log('Failed to find adb for platform', 'adb', LogLevel.ERROR)
27+
throw new Error('adb_platform_not_found')
28+
}
29+
const { url, cmd } = adbInfo
2530
const userDataPath = app.getPath('userData')
2631
const platformToolsPath = path.join(userDataPath, 'platform-tools')
27-
const adbPath = path.join(platformToolsPath, executable)
32+
const adbPath = path.join(platformToolsPath, cmd)
2833

2934
if (fs.existsSync(adbPath)) return `"${adbPath}"`
3035

@@ -37,7 +42,7 @@ export async function getAdbExecutable() {
3742

3843
if (fs.existsSync(downloadPath)) fs.unlinkSync(downloadPath)
3944

40-
const download = await axios.get(downloadURL, {
45+
const download = await axios.get(url, {
4146
responseType: 'stream',
4247
validateStatus: () => true
4348
})
@@ -51,16 +56,20 @@ export async function getAdbExecutable() {
5156

5257
download.data.pipe(writer)
5358

54-
await new Promise((resolve, reject) => {
59+
await new Promise<void>((resolve, reject) => {
5560
writer.on('finish', resolve)
5661
writer.on('error', reject)
5762
})
5863

5964
log('Downloaded ADB!', 'adb')
6065

61-
const extract = await execAsync(
62-
`${getPlatformTar()} -xf ${downloadPath} -C "${userDataPath}"`
63-
)
66+
const unzipCommand = buildUnzipCommand(downloadPath, userDataPath)
67+
if (!unzipCommand) {
68+
log('Failed to find unzip command for platform', 'adb', LogLevel.ERROR)
69+
throw new Error('adb_platform_not_found')
70+
}
71+
72+
const extract = await execAsync(unzipCommand)
6473

6574
if (extract === null) {
6675
log('Failed to extract adb', 'adb')

src/main/lib/playback/native.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { log } from '../utils.js'
33

44
import { PlaybackData, RepeatMode } from '../../types/Playback.js'
55
import { createRequire } from 'node:module'
6+
import axios from 'axios'
67

78
declare class NowPlaying {
89
constructor(
@@ -115,6 +116,15 @@ function importAddon() {
115116
log('Failed to import native addon', 'Native')
116117
return null
117118
}
119+
} else if (process.platform === 'linux') {
120+
if (process.arch === 'x64') {
121+
try {
122+
return require('node-nowplaying-linux-x64-gnu')
123+
} catch (e) {
124+
log('Failed to import native addon', 'Native')
125+
return null
126+
}
127+
}
118128
}
119129

120130
log('No native addon available for this platform', 'Native')
@@ -259,14 +269,23 @@ class NativeHandler extends BasePlaybackHandler {
259269
}
260270

261271
async getImage(): Promise<Buffer | null> {
262-
if (!this.current?.thumbnail) return null
263-
264-
const base64 = this.current.thumbnail.replace(
265-
/^data:image\/\w+;base64,/,
266-
''
267-
)
268-
const buffer = Buffer.from(base64, 'base64')
269-
return buffer
272+
const thumb = this.current?.thumbnail
273+
if (!thumb) return null
274+
275+
if (thumb.startsWith('data:image')) {
276+
const base64 = thumb.replace(/^data:image\/\w+;base64,/, '')
277+
const buffer = Buffer.from(base64, 'base64')
278+
return buffer
279+
} else if (
280+
thumb.startsWith('https://') ||
281+
thumb.startsWith('http://')
282+
) {
283+
const res = await axios.get(thumb, {
284+
responseType: 'arraybuffer'
285+
})
286+
287+
return res.data
288+
} else return null
270289
}
271290
}
272291

0 commit comments

Comments
 (0)