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
543 lines
18 KiB
MoonBit
543 lines
18 KiB
MoonBit
///| Saved state: what the desktop remembers between sessions, as EDN in
|
|
/// $XDG_CONFIG_HOME/chandra/state.edn (next to panel.edn, which holds the module list):
|
|
///
|
|
/// {:layout :tiling ; the Tile | Float switcher: :tiling, :monocle or :floating
|
|
/// :recent ["foot" "dolphin"] ; the launcher's recently started apps, newest first
|
|
/// :windows {"foot" {:x 80 :y 60 :w 640 :h 480}} ; floating windows' last place, by app id
|
|
/// :desktop-card {:x 900 :y 24} ; where the desktop card was dragged to (absent: default spot)
|
|
/// :wallpaper :aurora ; the settings module's wallpaper (absent: :plasma-glow)
|
|
/// :theme :light ; the settings module's Dark mode switch is off (absent: dark)
|
|
/// :power {:screen-off 5 :suspend 30} ; minutes without input before the screen goes off /
|
|
/// ; the computer suspends, 0 never (absent: 10 and 0)
|
|
/// :shortcuts {:show-desktop "Super+Ctrl+D" :screenshot-full ""}
|
|
/// ; keyboard shortcuts changed from their defaults ("" unbinds;
|
|
/// ; ids and combo syntax in shortcuts.mbt)
|
|
/// :terminal "kitty" ; the Apps tab's terminal (desktop file id) for terminal apps
|
|
/// ; (absent: xdg-terminals.list, else foot; see default_apps.mbt)
|
|
/// :session [{:app "foot"} {:app "org.gnome.Nautilus" :minimized true}]
|
|
/// ; the windows open when the last session ended, reopened at
|
|
/// ; the next start (see session.mbt in compositor/host)
|
|
/// :restore-session false ; don't reopen them (absent: reopen); the session settings module
|
|
/// ; or a hand edit sets it
|
|
/// :remember-windows false} ; don't place windows where they were left (absent: do)
|
|
///
|
|
/// Saving merges into what is already in the file, so keys this build doesn't know (a future
|
|
/// widget's state, hand-written notes) survive. Everything is a no-op unless `persist` is on
|
|
/// (the compositor binary turns it on; tests leave it off). The Interface Explorer toggle is not
|
|
/// saved on purpose: while it is on, clicks don't reach windows, which is no way to start a session.
|
|
|
|
///| What state.edn held. A field is None when the file doesn't say.
|
|
pub(all) struct SavedState {
|
|
/// 0 tiling, 1 monocle, 2 floating (the order of the layout list).
|
|
layout : Int?
|
|
recent : Array[String]?
|
|
/// Top-left of the desktop card, when it was moved.
|
|
desk : (Int, Int)?
|
|
windows : Map[String, (Int, Int, Int, Int)]
|
|
/// Index into `@libshell.wallpaper_names`.
|
|
wallpaper : Int?
|
|
/// Session settings; None when the file doesn't say (both default to on).
|
|
restore_session : Bool?
|
|
remember_windows : Bool?
|
|
/// From `:theme`: true for :dark, false for :light.
|
|
dark_mode : Bool?
|
|
/// From `:power`: (screen-off, suspend) minutes; a missing one keeps its default.
|
|
power : (Int?, Int?)
|
|
/// From `:shortcuts`: (id, combo text) pairs; empty when the file doesn't say.
|
|
shortcuts : Array[(String, String)]
|
|
/// From `:terminal`: the chosen terminal's desktop id.
|
|
terminal : String?
|
|
}
|
|
|
|
///|
|
|
fn state_path() -> String {
|
|
panel_config_dir() + "/state.edn"
|
|
}
|
|
|
|
///|
|
|
let layout_names : Array[String] = ["tiling", "monocle", "floating"]
|
|
|
|
///| The keys this build owns; everything else in the file is kept as it is.
|
|
let owned_keys : Array[String] = [
|
|
"layout", "recent", "desktop-card", "windows", "wallpaper", "restore-session", "remember-windows",
|
|
"theme", "power", "shortcuts", "terminal",
|
|
]
|
|
|
|
///| How state.edn names each wallpaper, in `@libshell.wallpaper_names` order.
|
|
let wallpaper_keys : Array[String] = ["plasma-glow", "aurora", "starfield", "dusk", "solid"]
|
|
|
|
///|
|
|
fn read_state_file() -> Array[(@edn.Value, @edn.Value)] {
|
|
let text = @utf8.decode_lossy(read_config_file("state.edn"))
|
|
if text.length() == 0 {
|
|
return []
|
|
}
|
|
let parsed : @edn.Value? = try Some(@edn.read(text)) catch { _ => None }
|
|
match parsed {
|
|
Some(Mapping(entries)) => entries
|
|
_ => [] // unreadable or not a map: start afresh rather than refuse to run
|
|
}
|
|
}
|
|
|
|
///|
|
|
fn lookup_key(
|
|
entries : Array[(@edn.Value, @edn.Value)],
|
|
name : String,
|
|
) -> @edn.Value? {
|
|
for e in entries {
|
|
match e.0 {
|
|
Keyword(k) if k == name => return Some(e.1)
|
|
_ => ()
|
|
}
|
|
}
|
|
None
|
|
}
|
|
|
|
///| Read state.edn. Without `persist` nothing is read.
|
|
pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
|
|
if !self.persist {
|
|
return {
|
|
layout: None,
|
|
recent: None,
|
|
desk: None,
|
|
windows: {},
|
|
wallpaper: None,
|
|
restore_session: None,
|
|
remember_windows: None,
|
|
dark_mode: None,
|
|
power: (None, None),
|
|
shortcuts: [],
|
|
terminal: None,
|
|
}
|
|
}
|
|
let entries = read_state_file()
|
|
let layout = match lookup_key(entries, "layout") {
|
|
Some(Keyword(k)) => {
|
|
let mut found : Int? = None
|
|
for i = 0; i < layout_names.length(); i = i + 1 {
|
|
if layout_names[i] == k {
|
|
found = Some(i)
|
|
}
|
|
}
|
|
found
|
|
}
|
|
_ => None
|
|
}
|
|
let recent = match lookup_key(entries, "recent") {
|
|
Some(Vector(items)) => {
|
|
let out : Array[String] = []
|
|
for it in items {
|
|
match it {
|
|
Text(s) => out.push(s)
|
|
_ => ()
|
|
}
|
|
}
|
|
Some(out)
|
|
}
|
|
_ => None
|
|
}
|
|
// Older builds kept the recents in a plain-text file under ~/.cache. Migrate them once: only
|
|
// when there is no state.edn yet (its first save then carries them over).
|
|
let recent = match recent {
|
|
Some(_) => recent
|
|
None =>
|
|
if @sys.read_file_bytes(state_path()).length() == 0 {
|
|
let old = load_recents()
|
|
if old.length() > 0 { Some(old) } else { None }
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
let desk = match lookup_key(entries, "desktop-card") {
|
|
Some(Mapping(m)) =>
|
|
match (lookup_key(m, "x"), lookup_key(m, "y")) {
|
|
(Some(Integer(x)), Some(Integer(y))) => match (parse_int_str(x), parse_int_str(y)) {
|
|
(Some(a), Some(b)) => Some((a, b))
|
|
_ => None
|
|
}
|
|
_ => None
|
|
}
|
|
_ => None
|
|
}
|
|
let windows : Map[String, (Int, Int, Int, Int)] = {}
|
|
match lookup_key(entries, "windows") {
|
|
Some(Mapping(ws)) =>
|
|
for e in ws {
|
|
match e {
|
|
(Text(app), Mapping(m)) => {
|
|
let f = fn(k : String) -> Int? {
|
|
match lookup_key(m, k) {
|
|
Some(Integer(v)) => parse_int_str(v)
|
|
_ => None
|
|
}
|
|
}
|
|
match (f("x"), f("y"), f("w"), f("h")) {
|
|
(Some(x), Some(y), Some(w), Some(h)) if w > 0 && h > 0 => windows.set(app, (x, y, w, h))
|
|
_ => ()
|
|
}
|
|
}
|
|
_ => ()
|
|
}
|
|
}
|
|
_ => ()
|
|
}
|
|
let wallpaper = match lookup_key(entries, "wallpaper") {
|
|
Some(Keyword(k)) => {
|
|
let mut found : Int? = None
|
|
for i = 0; i < wallpaper_keys.length(); i = i + 1 {
|
|
if wallpaper_keys[i] == k {
|
|
found = Some(i)
|
|
}
|
|
}
|
|
found
|
|
}
|
|
_ => None
|
|
}
|
|
let flag = fn(k : String) -> Bool? {
|
|
match lookup_key(entries, k) {
|
|
Some(Bool(b)) => Some(b)
|
|
_ => None
|
|
}
|
|
}
|
|
{
|
|
layout,
|
|
recent,
|
|
desk,
|
|
windows,
|
|
wallpaper,
|
|
restore_session: flag("restore-session"),
|
|
remember_windows: flag("remember-windows"),
|
|
power: match lookup_key(entries, "power") {
|
|
Some(Mapping(m)) => {
|
|
let f = fn(k : String) -> Int? {
|
|
match lookup_key(m, k) {
|
|
Some(Integer(v)) => parse_int_str(v)
|
|
_ => None
|
|
}
|
|
}
|
|
(f("screen-off"), f("suspend"))
|
|
}
|
|
_ => (None, None)
|
|
},
|
|
terminal: match lookup_key(entries, "terminal") {
|
|
Some(Text(t)) if t.length() > 0 => Some(t)
|
|
_ => None
|
|
},
|
|
shortcuts: match lookup_key(entries, "shortcuts") {
|
|
Some(Mapping(m)) => {
|
|
let out : Array[(String, String)] = []
|
|
for e in m {
|
|
match e {
|
|
(Keyword(k), Text(v)) | (Text(k), Text(v)) => out.push((k, v))
|
|
_ => ()
|
|
}
|
|
}
|
|
out
|
|
}
|
|
_ => []
|
|
},
|
|
dark_mode: match lookup_key(entries, "theme") {
|
|
Some(Keyword("light")) => Some(false)
|
|
Some(Keyword("dark")) => Some(true)
|
|
_ => None
|
|
},
|
|
}
|
|
}
|
|
|
|
///| Take the saved recents (the layout is the compositor's to apply).
|
|
pub fn DesktopShell::apply_state(self : DesktopShell, st : SavedState) -> Unit {
|
|
for app, g in st.windows {
|
|
self.win_geoms.set(app, g)
|
|
}
|
|
match st.wallpaper {
|
|
Some(i) => self.wallpaper_sel = i
|
|
None => ()
|
|
}
|
|
match st.restore_session {
|
|
Some(b) => self.restore_session = b
|
|
None => ()
|
|
}
|
|
match st.remember_windows {
|
|
Some(b) => self.remember_windows = b
|
|
None => ()
|
|
}
|
|
match st.dark_mode {
|
|
Some(b) => self.dark_mode = b
|
|
None => ()
|
|
}
|
|
match st.power.0 {
|
|
Some(m) if m >= 0 => self.screen_off_min = m
|
|
_ => ()
|
|
}
|
|
match st.power.1 {
|
|
Some(m) if m >= 0 => self.suspend_min = m
|
|
_ => ()
|
|
}
|
|
self.shortcuts.apply_saved(st.shortcuts)
|
|
match st.terminal {
|
|
Some(t) => {
|
|
self.terminal = t
|
|
self.default_apps_dirty = true
|
|
if self.handler_apps is Some(_) {
|
|
self.refresh_default_apps()
|
|
}
|
|
}
|
|
None => ()
|
|
}
|
|
match st.desk {
|
|
Some((x, y)) => {
|
|
self.desk_set = true
|
|
self.desk_x = x
|
|
self.desk_y = y
|
|
}
|
|
None => ()
|
|
}
|
|
match st.recent {
|
|
Some(r) => {
|
|
self.recents.clear()
|
|
for id in r {
|
|
self.recents.push(id)
|
|
}
|
|
self.order_apps()
|
|
}
|
|
None => ()
|
|
}
|
|
}
|
|
|
|
///| Write the current layout mode and recents, keeping any other keys. `layout_sel` is kept in
|
|
/// step with the window manager by the compositor. A no-op unless `persist` is on.
|
|
pub fn DesktopShell::save_state(self : DesktopShell) -> Unit {
|
|
if !self.persist {
|
|
return
|
|
}
|
|
let entries : Array[(@edn.Value, @edn.Value)] = []
|
|
for e in read_state_file() {
|
|
let owned = match e.0 {
|
|
Keyword(k) => owned_keys.contains(k)
|
|
_ => false
|
|
}
|
|
if !owned {
|
|
entries.push(e)
|
|
}
|
|
}
|
|
let layout = if self.layout_sel >= 0 && self.layout_sel < layout_names.length() {
|
|
layout_names[self.layout_sel]
|
|
} else {
|
|
"tiling"
|
|
}
|
|
let recent : Array[@edn.Value] = []
|
|
for r in self.recents {
|
|
recent.push(@edn.Value::Text(r))
|
|
}
|
|
entries.insert(0, (@edn.Value::Keyword("layout"), @edn.Value::Keyword(layout)))
|
|
entries.insert(1, (@edn.Value::Keyword("recent"), @edn.Value::Vector(recent)))
|
|
if self.win_geoms.length() > 0 {
|
|
let ws : Array[(@edn.Value, @edn.Value)] = []
|
|
for app, g in self.win_geoms {
|
|
let (x, y, w, h) = g
|
|
let n = fn(v : Int) { @edn.Value::Integer(v.to_string()) }
|
|
ws.push((@edn.Value::Text(app), @edn.Value::Mapping([
|
|
(@edn.Value::Keyword("x"), n(x)),
|
|
(@edn.Value::Keyword("y"), n(y)),
|
|
(@edn.Value::Keyword("w"), n(w)),
|
|
(@edn.Value::Keyword("h"), n(h)),
|
|
])))
|
|
}
|
|
entries.insert(2, (@edn.Value::Keyword("windows"), @edn.Value::Mapping(ws)))
|
|
}
|
|
if self.desk_set {
|
|
let (x, y) = self.desk_pos()
|
|
entries.insert(2, (@edn.Value::Keyword("desktop-card"), @edn.Value::Mapping([
|
|
(@edn.Value::Keyword("x"), @edn.Value::Integer(x.to_string())),
|
|
(@edn.Value::Keyword("y"), @edn.Value::Integer(y.to_string())),
|
|
])))
|
|
}
|
|
if self.wallpaper_sel > 0 && self.wallpaper_sel < wallpaper_keys.length() {
|
|
entries.insert(2, (@edn.Value::Keyword("wallpaper"), @edn.Value::Keyword(wallpaper_keys[self.wallpaper_sel])))
|
|
}
|
|
// Session settings are written only when off: absent means on, as for a hand-written file.
|
|
if self.screen_off_min != default_screen_off_min || self.suspend_min != default_suspend_min {
|
|
entries.insert(2, (@edn.Value::Keyword("power"), @edn.Value::Mapping([
|
|
(@edn.Value::Keyword("screen-off"), @edn.Value::Integer(self.screen_off_min.to_string())),
|
|
(@edn.Value::Keyword("suspend"), @edn.Value::Integer(self.suspend_min.to_string())),
|
|
])))
|
|
}
|
|
if self.terminal.length() > 0 {
|
|
entries.insert(2, (@edn.Value::Keyword("terminal"), @edn.Value::Text(self.terminal)))
|
|
}
|
|
let changed = self.shortcuts.changed()
|
|
if changed.length() > 0 {
|
|
entries.insert(2, (@edn.Value::Keyword("shortcuts"), @edn.Value::Mapping(
|
|
changed.map(c => (@edn.Value::Keyword(c.0), @edn.Value::Text(c.1))),
|
|
)))
|
|
}
|
|
if !self.dark_mode {
|
|
entries.insert(2, (@edn.Value::Keyword("theme"), @edn.Value::Keyword("light")))
|
|
}
|
|
if !self.remember_windows {
|
|
entries.insert(2, (@edn.Value::Keyword("remember-windows"), @edn.Value::Bool(false)))
|
|
}
|
|
if !self.restore_session {
|
|
entries.insert(2, (@edn.Value::Keyword("restore-session"), @edn.Value::Bool(false)))
|
|
}
|
|
write_state_file(entries)
|
|
}
|
|
|
|
///|
|
|
fn write_state_file(entries : Array[(@edn.Value, @edn.Value)]) -> Unit {
|
|
let body : String? = try Some(@edn.pretty(@edn.Value::Mapping(entries), layout={ width: 100, indent: 1 })) catch { _ => None }
|
|
match body {
|
|
Some(b) => {
|
|
let dir = panel_config_dir()
|
|
if @sys.mkdir_p(dir) {
|
|
let text = ";; Chandra state: restored at the next start\n" + b + "\n"
|
|
ignore(@sys.write_file_bytes(state_path(), @utf8.encode(text)))
|
|
}
|
|
}
|
|
None => ()
|
|
}
|
|
}
|
|
|
|
///| Parse an optionally negative decimal integer.
|
|
fn parse_int_str(s : String) -> Int? {
|
|
let neg = s.length() > 0 && s[0] == '-'
|
|
let start = if neg { 1 } else { 0 }
|
|
if s.length() <= start || s.length() > start + 6 {
|
|
return None
|
|
}
|
|
let mut n = 0
|
|
for i = start; i < s.length(); i = i + 1 {
|
|
let d = s[i].to_int() - 48
|
|
if d < 0 || d > 9 {
|
|
return None
|
|
}
|
|
n = n * 10 + d
|
|
}
|
|
Some(if neg { -n } else { n })
|
|
}
|
|
|
|
///| Remember where an app's window was left (a no-op without an app id) and save.
|
|
pub fn DesktopShell::remember_window(self : DesktopShell, app_id : String, x : Int, y : Int, w : Int, h : Int) -> Unit {
|
|
if app_id.length() == 0 || w <= 0 || h <= 0 || !self.remember_windows {
|
|
return
|
|
}
|
|
self.win_geoms.set(app_id, (x, y, w, h))
|
|
self.save_state()
|
|
}
|
|
|
|
///| The saved place of an app's window, if persistence is on and one was saved.
|
|
pub fn DesktopShell::saved_window(self : DesktopShell, app_id : String) -> (Int, Int, Int, Int)? {
|
|
if self.persist && self.remember_windows { self.win_geoms.get(app_id) } else { None }
|
|
}
|
|
|
|
///| One window of a saved session: the app id its window carried and how it was left.
|
|
pub(all) struct SessionEntry {
|
|
app : String
|
|
minimized : Bool
|
|
maximized : Bool
|
|
} derive(Eq, Show, Debug)
|
|
|
|
///| Parse a `:session` vector; entries without an app id are skipped.
|
|
fn parse_session(v : @edn.Value) -> Array[SessionEntry] {
|
|
let out : Array[SessionEntry] = []
|
|
match v {
|
|
Vector(items) =>
|
|
for it in items {
|
|
match it {
|
|
Mapping(m) =>
|
|
match lookup_key(m, "app") {
|
|
Some(Text(app)) if app.length() > 0 => {
|
|
let flag = fn(k : String) { lookup_key(m, k) is Some(Bool(true)) }
|
|
out.push({ app, minimized: flag("minimized"), maximized: flag("maximized") })
|
|
}
|
|
_ => ()
|
|
}
|
|
Text(app) if app.length() > 0 => out.push({ app, minimized: false, maximized: false })
|
|
_ => ()
|
|
}
|
|
}
|
|
_ => ()
|
|
}
|
|
out
|
|
}
|
|
|
|
///|
|
|
fn session_value(entries : Array[SessionEntry]) -> @edn.Value {
|
|
let items : Array[@edn.Value] = []
|
|
for e in entries {
|
|
let m : Array[(@edn.Value, @edn.Value)] = [(@edn.Value::Keyword("app"), @edn.Value::Text(e.app))]
|
|
if e.minimized {
|
|
m.push((@edn.Value::Keyword("minimized"), @edn.Value::Bool(true)))
|
|
}
|
|
if e.maximized {
|
|
m.push((@edn.Value::Keyword("maximized"), @edn.Value::Bool(true)))
|
|
}
|
|
items.push(@edn.Value::Mapping(m))
|
|
}
|
|
@edn.Value::Vector(items)
|
|
}
|
|
|
|
///| The windows the last session ended with, to reopen. Empty without `persist`, or when
|
|
/// state.edn says `:restore-session false`.
|
|
pub fn DesktopShell::load_session(self : DesktopShell) -> Array[SessionEntry] {
|
|
if !self.persist {
|
|
return []
|
|
}
|
|
let entries = read_state_file()
|
|
if lookup_key(entries, "restore-session") is Some(Bool(false)) {
|
|
return []
|
|
}
|
|
match lookup_key(entries, "session") {
|
|
Some(v) => parse_session(v)
|
|
None => []
|
|
}
|
|
}
|
|
|
|
///| Write the open windows as `:session`, keeping every other key. A no-op without `persist`.
|
|
pub fn DesktopShell::save_session(self : DesktopShell, session : Array[SessionEntry]) -> Unit {
|
|
if !self.persist {
|
|
return
|
|
}
|
|
let entries : Array[(@edn.Value, @edn.Value)] = []
|
|
let mut placed = false
|
|
for e in read_state_file() {
|
|
match e.0 {
|
|
Keyword("session") => {
|
|
entries.push((e.0, session_value(session)))
|
|
placed = true
|
|
}
|
|
_ => entries.push(e)
|
|
}
|
|
}
|
|
if !placed {
|
|
entries.push((@edn.Value::Keyword("session"), session_value(session)))
|
|
}
|
|
write_state_file(entries)
|
|
}
|
|
|
|
///| Start the app whose windows carry `app_id` (see `resolve_app_id`), without counting it as
|
|
/// a recent launch. False when no installed app matches or it could not be started.
|
|
pub fn DesktopShell::launch_app_id(self : DesktopShell, app_id : String) -> Bool {
|
|
match resolve_app_id(app_id, self.exec, self.wm_classes) {
|
|
Some(id) =>
|
|
match self.command_for(id) {
|
|
Some(cmd) => @sys.spawn(cmd, self.display)
|
|
None => false
|
|
}
|
|
None => false
|
|
}
|
|
}
|
|
|
|
///|
|
|
test "session entries round-trip through EDN" {
|
|
let s : Array[SessionEntry] = [
|
|
{ app: "foot", minimized: false, maximized: false },
|
|
{ app: "org.gnome.Nautilus", minimized: true, maximized: false },
|
|
{ app: "firefox", minimized: false, maximized: true },
|
|
]
|
|
let text = @edn.pretty(session_value(s), layout={ width: 100, indent: 1 })
|
|
assert_eq(parse_session(@edn.read(text)), s)
|
|
// A plain vector of app ids works too (hand-written).
|
|
assert_eq(parse_session(@edn.read("[\"foot\" \"\" 3]")), [{ app: "foot", minimized: false, maximized: false }])
|
|
}
|