Skip to content

Commit

Permalink
apps/Services -> apps/ServiceManager-Non-Privileged-Agents
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jun 7, 2024
1 parent edabefc commit 0155073
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 245 deletions.
File renamed without changes.
21 changes: 21 additions & 0 deletions src/apps/ServiceManager-Non-Privileged-Agents/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
all:
python3 ../../../scripts/update_version.py
xcodegen generate
xcodebuild -configuration Release -alltargets SYMROOT="$(CURDIR)/build"
# Copy LaunchAgents
mkdir -p build/Release/Karabiner-Elements-Non-Privileged-Agents.app/Contents/Library/LaunchAgents
cp LaunchAgents/*.plist build/Release/Karabiner-Elements-Non-Privileged-Agents.app/Contents/Library/LaunchAgents

clean:
rm -rf *.xcodeproj
rm -rf build

xcode:
open *.xcodeproj

install:
bash ../../../scripts/codesign.sh build/Release

sudo rsync -a --delete \
build/Release/Karabiner-Elements-Non-Privileged-Agents \
'/Library/Application Support/org.pqrs/Karabiner-Elements'
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Karabiner-Elements-Services
name: Karabiner-Elements-Non-Privileged-Agents

targets:
Karabiner-Elements-Services:
Karabiner-Elements-Non-Privileged-Agents:
settings:
PRODUCT_BUNDLE_IDENTIFIER: org.pqrs.Karabiner-Elements-Services
PRODUCT_BUNDLE_IDENTIFIER: org.pqrs.Karabiner-Elements-Non-Privileged-Agents
# SMAppService requires codesigning
CODE_SIGN_ENTITLEMENTS: ''
CODE_SIGN_IDENTITY: 'Apple Development'
Expand All @@ -20,5 +20,6 @@ targets:
excludes:
- Info.plist.in
- path: ../share/Resources/app.icns
- path: ../share/swift/ServiceManagementHelper.swift
dependencies:
- sdk: ServiceManagement.framework
114 changes: 114 additions & 0 deletions src/apps/ServiceManager-Non-Privileged-Agents/src/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import Foundation
import ServiceManagement

enum Subcommand: String {
case registerCoreAgents = "register-core-agents"
case unregisterCoreAgents = "unregister-core-agents"

case registerMenuAgent = "register-menu-agent"
case unregisterMenuAgent = "unregister-menu-agent"

case registerMultitouchExtensionAgent = "register-multitouch-extension-agent"
case unregisterMultitouchExtensionAgent = "unregister-multitouch-extension-agent"

case registerNotificationWindowAgent = "register-notification-window-agent"
case unregisterNotificationWindowAgent = "unregister-notification-window-agent"

case status = "status"
}

RunLoop.main.perform {
let coreAgents: [SMAppService] = [
SMAppService.agent(
plistName: "org.pqrs.service.agent.karabiner_console_user_server.plist"),
SMAppService.agent(
plistName: "org.pqrs.service.agent.karabiner_grabber.plist"),
SMAppService.agent(
plistName: "org.pqrs.service.agent.karabiner_session_monitor.plist"),
]

let menuAgentService = SMAppService.agent(
plistName: "org.pqrs.service.agent.Karabiner-Menu.plist")

let multitouchExtensionAgentService = SMAppService.agent(
plistName: "org.pqrs.service.agent.Karabiner-MultitouchExtension.plist")

let notificationWindowAgentService = SMAppService.agent(
plistName: "org.pqrs.service.agent.Karabiner-NotificationWindow.plist")

var allServices: [SMAppService] = []
for s in coreAgents {
allServices.append(s)
}
allServices.append(menuAgentService)
allServices.append(multitouchExtensionAgentService)
allServices.append(notificationWindowAgentService)

if CommandLine.arguments.count > 1 {
let subcommand = CommandLine.arguments[1]

switch Subcommand(rawValue: subcommand) {
case .registerCoreAgents:
ServiceManagementHelper.register(services: coreAgents)
exit(0)

case .unregisterCoreAgents:
ServiceManagementHelper.unregister(services: coreAgents)
exit(0)

case .registerMenuAgent:
ServiceManagementHelper.register(services: [menuAgentService])
exit(0)

case .unregisterMenuAgent:
ServiceManagementHelper.unregister(services: [menuAgentService])
exit(0)

case .registerMultitouchExtensionAgent:
ServiceManagementHelper.register(services: [multitouchExtensionAgentService])
exit(0)

case .unregisterMultitouchExtensionAgent:
ServiceManagementHelper.unregister(services: [multitouchExtensionAgentService])
exit(0)

case .registerNotificationWindowAgent:
ServiceManagementHelper.register(services: [notificationWindowAgentService])
exit(0)

case .unregisterNotificationWindowAgent:
ServiceManagementHelper.unregister(services: [notificationWindowAgentService])
exit(0)

case .status:
ServiceManagementHelper.printStatuses(services: allServices)
exit(0)

default:
print("Unknown subcommand \(subcommand)")
exit(1)
}
}

print("Usage:")
print(" Karabiner-Elements-Non-Privileged-Agents subcommand")
print("")
print("Subcommands:")
print(" \(Subcommand.registerCoreAgents.rawValue)")
print(" \(Subcommand.unregisterCoreAgents.rawValue)")

print(" \(Subcommand.registerMenuAgent.rawValue)")
print(" \(Subcommand.unregisterMenuAgent.rawValue)")

print(" \(Subcommand.registerMultitouchExtensionAgent.rawValue)")
print(" \(Subcommand.unregisterMultitouchExtensionAgent.rawValue)")

print(" \(Subcommand.registerNotificationWindowAgent.rawValue)")
print(" \(Subcommand.unregisterNotificationWindowAgent.rawValue)")

print(" \(Subcommand.status.rawValue)")

exit(0)
}

RunLoop.main.run()

This file was deleted.

25 changes: 0 additions & 25 deletions src/apps/Services/Makefile

This file was deleted.

Loading

0 comments on commit 0155073

Please sign in to comment.