mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-07 19:59:14 -04:00
feat(keybinds): add default app IPC actions (#2546)
This commit is contained in:
+48
@@ -532,6 +532,54 @@ dms ipc call systemupdater close
|
|||||||
dms ipc call systemupdater updatestatus
|
dms ipc call systemupdater updatestatus
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Target: `defaultApp`
|
||||||
|
|
||||||
|
Launch applications configured in Settings > Default Apps.
|
||||||
|
|
||||||
|
### Functions
|
||||||
|
|
||||||
|
**`browser`**
|
||||||
|
- Launch the configured default web browser
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`fileManager`**
|
||||||
|
- Launch the configured default file manager
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`textEditor`**
|
||||||
|
- Launch the configured default text editor
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`pdfReader`**
|
||||||
|
- Launch the configured default PDF reader
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`imageViewer`**
|
||||||
|
- Launch the configured default image viewer
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`videoPlayer`**
|
||||||
|
- Launch the configured default video player
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`musicPlayer`**
|
||||||
|
- Launch the configured default music player
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`mail`**
|
||||||
|
- Launch the configured default mail client
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
**`calendar`**
|
||||||
|
- Launch the configured default calendar application
|
||||||
|
- Returns: Launch request confirmation
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
```bash
|
||||||
|
dms ipc call defaultApp browser
|
||||||
|
dms ipc call defaultApp fileManager
|
||||||
|
```
|
||||||
|
|
||||||
## Modal Controls
|
## Modal Controls
|
||||||
|
|
||||||
These targets control various modal windows and overlays.
|
These targets control various modal windows and overlays.
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ const DMS_ACTIONS = [
|
|||||||
{ id: "spawn dms ipc call spotlight toggle", label: "Default Launcher: Toggle" },
|
{ id: "spawn dms ipc call spotlight toggle", label: "Default Launcher: Toggle" },
|
||||||
{ id: "spawn dms ipc call spotlight open", label: "Default Launcher: Open" },
|
{ id: "spawn dms ipc call spotlight open", label: "Default Launcher: Open" },
|
||||||
{ id: "spawn dms ipc call spotlight close", label: "Default Launcher: Close" },
|
{ id: "spawn dms ipc call spotlight close", label: "Default Launcher: Close" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp browser", label: "Default Web Browser: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp fileManager", label: "Default File Manager: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp mail", label: "Default Mail: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp calendar", label: "Default Calendar: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp textEditor", label: "Default Text Editor: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp pdfReader", label: "Default PDF Reader: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp imageViewer", label: "Default Image Viewer: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp videoPlayer", label: "Default Video Player: Open" },
|
||||||
|
{ id: "spawn dms ipc call defaultApp musicPlayer", label: "Default Music Player: Open" },
|
||||||
{ id: "spawn dms ipc call spotlight-bar toggle", label: "Spotlight Bar: Toggle" },
|
{ id: "spawn dms ipc call spotlight-bar toggle", label: "Spotlight Bar: Toggle" },
|
||||||
{ id: "spawn dms ipc call spotlight-bar open", label: "Spotlight Bar: Open" },
|
{ id: "spawn dms ipc call spotlight-bar open", label: "Spotlight Bar: Open" },
|
||||||
{ id: "spawn dms ipc call spotlight-bar close", label: "Spotlight Bar: Close" },
|
{ id: "spawn dms ipc call spotlight-bar close", label: "Spotlight Bar: Close" },
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
@@ -56,6 +57,93 @@ Item {
|
|||||||
return currentBar;
|
return currentBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property var defaultAppMimeTypes: ({
|
||||||
|
browser: "x-scheme-handler/https",
|
||||||
|
fileManager: "inode/directory",
|
||||||
|
textEditor: "text/plain",
|
||||||
|
imageViewer: "image/png",
|
||||||
|
videoPlayer: "video/mp4",
|
||||||
|
musicPlayer: "audio/mpeg",
|
||||||
|
pdfReader: "application/pdf",
|
||||||
|
mail: "x-scheme-handler/mailto",
|
||||||
|
calendar: "x-scheme-handler/calendar"
|
||||||
|
})
|
||||||
|
|
||||||
|
function launchDesktopId(desktopId, appName) {
|
||||||
|
if (!desktopId || desktopId.length === 0) {
|
||||||
|
log.warn("No default app configured for:", appName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let entry = DesktopEntries.heuristicLookup(desktopId);
|
||||||
|
if (!entry && desktopId.endsWith(".desktop")) {
|
||||||
|
entry = DesktopEntries.heuristicLookup(desktopId.slice(0, -8));
|
||||||
|
}
|
||||||
|
if (!entry) {
|
||||||
|
log.warn("Default app desktop entry not found:", desktopId, "for:", appName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionService.launchDesktopEntry(entry);
|
||||||
|
AppUsageHistoryData.addAppUsage(entry);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function launchDefaultMimeApp(appName, mimeType) {
|
||||||
|
DMSService.sendRequest("mime.getDefault", {
|
||||||
|
"mimeType": mimeType
|
||||||
|
}, response => {
|
||||||
|
if (response.error) {
|
||||||
|
log.warn("Failed to resolve default app:", appName, response.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = response.result || {};
|
||||||
|
root.launchDesktopId(result.desktopId || "", appName);
|
||||||
|
});
|
||||||
|
|
||||||
|
return `DEFAULTAPP_LAUNCH_REQUESTED: ${appName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
function browser(): string {
|
||||||
|
return root.launchDefaultMimeApp("browser", root.defaultAppMimeTypes.browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileManager(): string {
|
||||||
|
return root.launchDefaultMimeApp("fileManager", root.defaultAppMimeTypes.fileManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
function textEditor(): string {
|
||||||
|
return root.launchDefaultMimeApp("textEditor", root.defaultAppMimeTypes.textEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
function imageViewer(): string {
|
||||||
|
return root.launchDefaultMimeApp("imageViewer", root.defaultAppMimeTypes.imageViewer);
|
||||||
|
}
|
||||||
|
|
||||||
|
function videoPlayer(): string {
|
||||||
|
return root.launchDefaultMimeApp("videoPlayer", root.defaultAppMimeTypes.videoPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
function musicPlayer(): string {
|
||||||
|
return root.launchDefaultMimeApp("musicPlayer", root.defaultAppMimeTypes.musicPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pdfReader(): string {
|
||||||
|
return root.launchDefaultMimeApp("pdfReader", root.defaultAppMimeTypes.pdfReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mail(): string {
|
||||||
|
return root.launchDefaultMimeApp("mail", root.defaultAppMimeTypes.mail);
|
||||||
|
}
|
||||||
|
|
||||||
|
function calendar(): string {
|
||||||
|
return root.launchDefaultMimeApp("calendar", root.defaultAppMimeTypes.calendar);
|
||||||
|
}
|
||||||
|
|
||||||
|
target: "defaultApp"
|
||||||
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
function open() {
|
function open() {
|
||||||
root.powerMenuModalLoader.active = true;
|
root.powerMenuModalLoader.active = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user