Settings > Apps: choose the default browser, email, files, terminal, editor, viewers and players
CI / test (push) Failing after 45s
CI / test (push) Failing after 45s
- A sixth Settings tab, Apps (key 6, SettingsTab::Apps; the popup is 390 px wide for it): Web
browser, Email, File manager, Terminal, Text editor, Image viewer, Video player, Music player,
PDF and documents, Archive manager. Each row shows the current default with its real icon (the
icon-theme lookup the task manager uses; a letter tile when there is none). Click a row to list
the installed apps that can take it, click one to make it the default. A chosen app that has
been uninstalled since is named in red under its row ("gthumb is not installed any more").
- Installed apps come from the .desktop files in the XDG data dirs (and flatpak's exports), with
MimeType= and Categories= (desktop_entry_keys, now shared with the launcher's parse_desktop).
A kind lists the shown apps that handle one of its MIME types; the terminal lists
TerminalEmulator apps; browsers are only offered as browsers.
- Reading follows the mimeapps.list spec: $XDG_CONFIG_HOME/[chandra-]mimeapps.list, then
$XDG_CONFIG_DIRS (/etc/xdg), then $XDG_DATA_HOME and $XDG_DATA_DIRS applications/; the first
installed [Default Applications] entry wins, else [Added Associations], else mimeinfo.cache
(minus [Removed Associations]), else the first installed app that handles the type. A hidden
(NoDisplay) default still counts and its name is shown.
- Setting writes [Default Applications] in ~/.config/mimeapps.list for each of the kind's MIME
types the app handles (always the main one: http/https/text/html for browsers, mailto,
inode/directory, text/plain, image/png..., video/mp4..., audio/mpeg..., application/pdf...,
application/zip...), as xdg-mime default / xdg-settings do, without running them. Every other
section, entry, comment and blank line is kept; the app leaves those types' [Removed
Associations]; a chandra-mimeapps.list that already names one of those types is updated too.
- The terminal has no MIME type: state.edn :terminal "kitty" (desktop id), also written first in
~/.config/xdg-terminals.list (xdg-terminal-exec). Terminal=true apps from the launcher (and
session restore) now start in it (foot -e, kgx/gnome-terminal/ptyxis --, kitty <cmd>, wezterm
start --) instead of always foot; with no choice: xdg-terminals.list, then foot, then any
installed terminal. Terminal apps are listed when any terminal emulator is installed, not only
foot.
- New `default-apps` capability (categories, apps, set-default, refresh): host tables 11 (sss:
name current missing) and 12 (issii: category id name icon current), request 19 (category *
1000 + app, -1 rescans) in the wasmer/wasmtime stub, host-wasm and the MoonBit wasmhost
(chandra:host/plasmoids default-app(s32)). Nothing is scanned until the tab opens (refresh).
- Tests with a temporary XDG tree: categories and current defaults (user file, system file,
Added Associations, mimeinfo.cache, missing apps, hidden defaults), writing that keeps other
entries, desktop-specific files, the terminal list and commands, the Apps tab end to end, and
the :terminal round trip through state.edn.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgywj7RPmFdFhpzGZj
This commit is contained in:
26 files changed
+1605
-73
No files matched your search
@@ -0,0 +1,5 @@
|
||||
Default applications: which installed app opens web links, mail, folders, text, images, video,
|
||||
music, documents and archives, kept in the freedesktop mimeapps.list that other apps and
|
||||
xdg-open follow, and which terminal Chandra runs terminal apps in (state.edn, exported as
|
||||
xdg-terminals.list). A module with this capability (the settings module's Apps tab) lists the
|
||||
choices and sets them.
|
||||
@@ -0,0 +1,40 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
fn wasmImportCategories(p0 : Int) = "chandra:desktop/default-apps@0.1.0" "categories"
|
||||
|
||||
///|
|
||||
fn wasmImportApps(p0 : Int) = "chandra:desktop/default-apps@0.1.0" "apps"
|
||||
|
||||
///|
|
||||
fn wasmImportSetDefault(p0 : Int, p1 : Int) = "chandra:desktop/default-apps@0.1.0" "set-default"
|
||||
|
||||
///|
|
||||
fn wasmImportRefresh() = "chandra:desktop/default-apps@0.1.0" "refresh"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,73 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct AppCategory {
|
||||
name : String; current : String; missing : String
|
||||
}
|
||||
///|
|
||||
pub(all) struct AppChoice {
|
||||
category : UInt; id : String; name : String; icon : UInt; current : Bool
|
||||
}
|
||||
///|
|
||||
/// The categories, in the order they are shown.
|
||||
pub fn categories() -> Array[AppCategory] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportCategories(return_area);
|
||||
|
||||
let array : Array[AppCategory] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 24)
|
||||
|
||||
let result = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 0), mbt_ffi_load32((iter_base) + 4))
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 8), mbt_ffi_load32((iter_base) + 12))
|
||||
|
||||
let result1 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 16), mbt_ffi_load32((iter_base) + 20))
|
||||
|
||||
array.push(AppCategory::{name : result, current : result0, missing : result1})
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// The installed apps that can be each category's default, grouped by category in category
|
||||
/// order, each group in name order.
|
||||
pub fn apps() -> Array[AppChoice] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportApps(return_area);
|
||||
|
||||
let array : Array[AppChoice] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 28)
|
||||
|
||||
let result = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 4), mbt_ffi_load32((iter_base) + 8))
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 12), mbt_ffi_load32((iter_base) + 16))
|
||||
|
||||
array.push(AppChoice::{category : (mbt_ffi_load32((iter_base) + 0)).reinterpret_as_uint(), id : result, name : result0, icon : (mbt_ffi_load32((iter_base) + 20)).reinterpret_as_uint(), current : (mbt_ffi_load8_u((iter_base) + 24) != 0)})
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// Make the category's `app`-th app (counting within the category, from 0) its default.
|
||||
pub fn set_default(category : UInt, app : UInt) -> Unit {
|
||||
|
||||
wasmImportSetDefault((category).reinterpret_as_int(), (app).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
/// Scan the installed apps and the defaults again (another program may have changed them).
|
||||
pub fn refresh() -> Unit {
|
||||
|
||||
wasmImportRefresh();
|
||||
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ pub(all) enum Request {
|
||||
MoveInstance(InstanceMove)
|
||||
Shortcut(Int32)
|
||||
ReloadSession
|
||||
DefaultApp(Int32)
|
||||
}
|
||||
|
||||
pub(all) struct SettingChange {
|
||||
|
||||
@@ -60,6 +60,7 @@ pub(all) enum Request {
|
||||
MoveInstance(InstanceMove)
|
||||
Shortcut(Int)
|
||||
ReloadSession
|
||||
DefaultApp(Int)
|
||||
}
|
||||
///|
|
||||
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
|
||||
@@ -393,7 +394,8 @@ pub fn set_config(handle : UInt, key : String, value : String) -> Bool {
|
||||
/// settings (s), 7 icons (si: app id, raster image handle from `raster.load-image`) served by `icons.app-icon`,
|
||||
/// 8 network status (one row, iissiiii: state signal name message wifi-enabled airplane
|
||||
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved), 10 keyboard
|
||||
/// shortcuts (ssssi: name binding default-binding conflict capturing).
|
||||
/// shortcuts (ssssi: name binding default-binding conflict capturing), 11 default-app
|
||||
/// categories (sss: name current missing), 12 default-app choices (issii: category id name icon current).
|
||||
pub fn publish_table(which : UInt, rows : FixedArray[Byte]) -> Unit {
|
||||
|
||||
let ptr = mbt_ffi_bytes2ptr(rows)
|
||||
@@ -575,6 +577,10 @@ pub fn next_request() -> Request? {
|
||||
|
||||
Request::ReloadSession
|
||||
}
|
||||
18 => {
|
||||
|
||||
Request::DefaultApp(mbt_ffi_load32((return_area) + 8))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user