Skip to content

Commit e43a704

Browse files
Added:
- Build step for other binaries, and downloading from github repo (hopefully less, pre-built binaries in the code) - Formatted entire project - New shell and spawn commands to safely execute commands and spawn processes. - Few design changes - Migrated from NPM and Node to Bun - Other code QOL things
1 parent ab9cfc3 commit e43a704

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1879
-7376
lines changed

.github/assets/logo.png

84.2 KB
Loading

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
/bun.lockb
1+
# Pre-built binaries
2+
build/lib/MacOS/discordrpc_ablox
3+
build/lib/MacOS/urlscheme
4+
build/lib/MacOS/watchdog
5+
build/lib/MacOS/window_manager
6+
27
.tmp
38
.tmpbuild
49
window_state_config.json

.prettierignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
node_modules
22
dist
3-
build
3+
/build
44
.tmp
5-
scripts
65
.github
76
.git
87
bin

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ If you're worried that those could be modified by me or another contributor to i
6363

6464
## Developpement
6565

66-
To setup the app on your machine, clone this repo and run `npm install`. You will also need to install some packages with the command: `brew install create-dmg`.
66+
To setup the app on your machine, clone this repo and run `bun install`. You will also need to install some packages with the command: `brew install create-dmg`.
6767

68-
To start the **dev environnement**, run `npm run dev`.
68+
To start the **dev environnement**, run `bun run --bun dev`.
6969

70-
To **build**, run `npm run build`. (If you don't want to create dmgs)
70+
To **package**, run `bun run --bun package`. (If you don't want to create dmgs)
7171

72-
To **build and package the app**, run `npm run build:release`.
72+
To **package and create a dmg of the app**, run `bun run --bun package:release`.
7373

7474
The app is made with [Svelte](https://svelte.dev) (Frontend) and [NeutralinoJS](https://neutralino.js.org) (Backend).
7575
If you haven't heard about NeutralinoJS, it is a lightweight alternative coded in **c++** to frameworks like Electron or NW.JS. It is still growing, but is stable enough to be used on one platform. You can learn more about it on https://neutralino.js.org/docs.
@@ -92,5 +92,6 @@ All contributions are welcome! Feel free to open issues and pull requests. For f
9292

9393
## Credits
9494

95-
Logo found on https://macosicons.com (Sorry but I couldn't find the designer's name ^^').
96-
Features inspirations from BloxStrap.
95+
- Logo by @typeofnull
96+
- Inspired from @pizzaboxer's Bloxstrap
97+
- Icons by lucide-svelte & icons8

build/binaries/urlscheme.m

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#import <Foundation/Foundation.h>
2+
#import <CoreServices/CoreServices.h>
3+
4+
int main(int argc, const char * argv[]) {
5+
@autoreleasepool {
6+
if (argc != 4) {
7+
NSLog(@"Usage: %s <set/check> <URL_SCHEME> <BUNDLE_IDENTIFIER>", argv[0]);
8+
return 1;
9+
}
10+
11+
NSString *command = [NSString stringWithUTF8String:argv[1]];
12+
NSString *urlScheme = [NSString stringWithUTF8String:argv[2]];
13+
NSString *bundleIdentifier = [NSString stringWithUTF8String:argv[3]];
14+
15+
if ([command isEqualToString:@"set"]) {
16+
OSStatus status = LSSetDefaultHandlerForURLScheme((__bridge CFStringRef)urlScheme, (__bridge CFStringRef)bundleIdentifier);
17+
18+
if (status == noErr) {
19+
NSLog(@"Successfully set %@ as the default handler for %@://", bundleIdentifier, urlScheme);
20+
return 0;
21+
} else {
22+
NSLog(@"Failed to set default handler. Error code: %d", (int)status);
23+
return 1;
24+
}
25+
} else if ([command isEqualToString:@"check"]) {
26+
CFStringRef currentHandler = LSCopyDefaultHandlerForURLScheme((__bridge CFStringRef)urlScheme);
27+
28+
if (currentHandler) {
29+
BOOL isDefault = [(__bridge NSString *)currentHandler isEqualToString:bundleIdentifier];
30+
CFRelease(currentHandler);
31+
32+
if (isDefault) {
33+
NSLog(@"true");
34+
return 0;
35+
} else {
36+
NSLog(@"false");
37+
return 1;
38+
}
39+
} else {
40+
NSLog(@"No default handler found for %@://", urlScheme);
41+
return 1;
42+
}
43+
} else {
44+
NSLog(@"Invalid command. Use 'set' to set the handler or 'check' to check the handler.");
45+
return 1;
46+
}
47+
}
48+
return 0;
49+
}

build/binaries/watchdog.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <unistd.h>
4+
#include <signal.h>
5+
#include <sys/types.h>
6+
#include <errno.h>
7+
8+
int main() {
9+
// Get the parent process ID (PPID)
10+
pid_t parent_pid = getppid();
11+
pid_t piped_process_pid = getpid();
12+
13+
// Monitor the parent process (your app/shell)
14+
while (1) {
15+
// Check if the parent process is still running
16+
if (kill(parent_pid, 0) == -1) {
17+
if (errno == ESRCH) {
18+
// Parent process doesn't exist, terminate the piped process
19+
printf("Parent process exited. Exiting watchdog and terminating piped process.\n");
20+
exit(0);
21+
} else {
22+
perror("Error checking parent process");
23+
exit(1);
24+
}
25+
}
26+
27+
// Sleep a bit to avoid busy-looping (adjust as necessary)
28+
sleep(1);
29+
}
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)