Ship default config/panels/themes with the app: --init, XDG discovery, build/CI bundling
- tui-wm --init [DIR] writes an embedded default config.toml,
panels/topbar.toml and themes/{dark,light}.toml (default target
~/.config/tui-wm, existing files untouched)
- Config discovery: ./config.toml wins, otherwise ~/.config/tui-wm/
is used (process switches working dir there so panels/themes/saves/
hot-reload all resolve consistently); spawned PTYs still start in
the user's original working directory
- VS Code build tasks copy themes/ into builds/, dist/ sample configs
refreshed with all new keys and the settings gear
- CI release now also uploads tui-wm-config.tar.gz (config + panels +
themes) alongside the binaries
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,10 @@ jobs:
|
|||||||
mkdir -p build
|
mkdir -p build
|
||||||
cp target/release/tui-wm build/tui-wm-linux-arm64
|
cp target/release/tui-wm build/tui-wm-linux-arm64
|
||||||
cp target/x86_64-unknown-linux-gnu/release/tui-wm build/tui-wm-linux-x64
|
cp target/x86_64-unknown-linux-gnu/release/tui-wm build/tui-wm-linux-x64
|
||||||
(cd build && sha256sum tui-wm-linux-* > checksums.txt && ls -la)
|
# Standardkonfiguration (config + paneler + teman) som eget paket.
|
||||||
|
# Binären kan också skapa allt själv med `tui-wm --init`.
|
||||||
|
tar czf build/tui-wm-config.tar.gz config.toml panels themes
|
||||||
|
(cd build && sha256sum tui-wm-linux-* tui-wm-config.tar.gz > checksums.txt && ls -la)
|
||||||
|
|
||||||
- name: Skapa/uppdatera latest-release + ladda upp binärer
|
- name: Skapa/uppdatera latest-release + ladda upp binärer
|
||||||
env:
|
env:
|
||||||
@@ -55,7 +58,7 @@ jobs:
|
|||||||
[ -z "$rid" ] && rid=$(curl -s "$API/repos/$REPO/releases/tags/$TAG" \
|
[ -z "$rid" ] && rid=$(curl -s "$API/repos/$REPO/releases/tags/$TAG" \
|
||||||
-H "Authorization: token $TOKEN" | jq -r '.id')
|
-H "Authorization: token $TOKEN" | jq -r '.id')
|
||||||
echo "release id: $rid"
|
echo "release id: $rid"
|
||||||
for f in tui-wm-linux-x64 tui-wm-linux-arm64 checksums.txt; do
|
for f in tui-wm-linux-x64 tui-wm-linux-arm64 tui-wm-config.tar.gz checksums.txt; do
|
||||||
aid=$(curl -s "$API/repos/$REPO/releases/$rid/assets" \
|
aid=$(curl -s "$API/repos/$REPO/releases/$rid/assets" \
|
||||||
-H "Authorization: token $TOKEN" | jq -r ".[] | select(.name==\"$f\") | .id")
|
-H "Authorization: token $TOKEN" | jq -r ".[] | select(.name==\"$f\") | .id")
|
||||||
if [ -n "$aid" ] && [ "$aid" != "null" ]; then
|
if [ -n "$aid" ] && [ "$aid" != "null" ]; then
|
||||||
|
|||||||
8
.vscode/tasks.json
vendored
8
.vscode/tasks.json
vendored
@@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"label": "Build alla (Linux + Windows)",
|
"label": "Build alla (Linux + Windows)",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cargo build --release && cargo build --release --target x86_64-pc-windows-gnu && mkdir -p builds/linux/panels builds/win/panels && cp target/release/tui-wm builds/linux/tui-wm && cp target/x86_64-pc-windows-gnu/release/tui-wm.exe builds/win/tui-wm.exe && cp dist/linux/config.toml builds/linux/config.toml && cp dist/linux/panels/topbar.toml builds/linux/panels/topbar.toml && cp dist/win/config.toml builds/win/config.toml && cp dist/win/panels/topbar.toml builds/win/panels/topbar.toml && echo 'Done: builds/linux/tui-wm + builds/win/tui-wm.exe'",
|
"command": "cargo build --release && cargo build --release --target x86_64-pc-windows-gnu && mkdir -p builds/linux/panels builds/win/panels && cp target/release/tui-wm builds/linux/tui-wm && cp target/x86_64-pc-windows-gnu/release/tui-wm.exe builds/win/tui-wm.exe && cp dist/linux/config.toml builds/linux/config.toml && cp dist/linux/panels/topbar.toml builds/linux/panels/topbar.toml && cp dist/win/config.toml builds/win/config.toml && cp dist/win/panels/topbar.toml builds/win/panels/topbar.toml && cp -r themes builds/linux/themes && cp -r themes builds/win/themes && echo 'Done: builds/linux/tui-wm + builds/win/tui-wm.exe (inkl. themes/)'",
|
||||||
"options": { "shell": { "executable": "bash", "args": ["-c"] } },
|
"options": { "shell": { "executable": "bash", "args": ["-c"] } },
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"presentation": { "reveal": "always", "panel": "shared" },
|
"presentation": { "reveal": "always", "panel": "shared" },
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"label": "Build (native)",
|
"label": "Build (native)",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"linux": {
|
"linux": {
|
||||||
"command": "cargo build --release && mkdir -p builds/linux/panels && cp target/release/tui-wm builds/linux/tui-wm && cp dist/linux/config.toml builds/linux/config.toml && cp dist/linux/panels/topbar.toml builds/linux/panels/topbar.toml && echo 'Done: builds/linux/tui-wm'"
|
"command": "cargo build --release && mkdir -p builds/linux/panels && cp target/release/tui-wm builds/linux/tui-wm && cp dist/linux/config.toml builds/linux/config.toml && cp dist/linux/panels/topbar.toml builds/linux/panels/topbar.toml && cp -r themes builds/linux/themes && echo 'Done: builds/linux/tui-wm'"
|
||||||
},
|
},
|
||||||
"windows": {
|
"windows": {
|
||||||
"command": "& \"$env:USERPROFILE\\.cargo\\bin\\cargo.exe\" build --release; if ($LASTEXITCODE -eq 0) { New-Item -Force -ItemType Directory builds\\win\\panels | Out-Null; Copy-Item target\\release\\tui-wm.exe builds\\win\\tui-wm.exe -Force; Copy-Item dist\\win\\config.toml builds\\win\\config.toml -Force; Copy-Item dist\\win\\panels\\topbar.toml builds\\win\\panels\\topbar.toml -Force; Write-Host 'Done: builds\\win\\tui-wm.exe' }",
|
"command": "& \"$env:USERPROFILE\\.cargo\\bin\\cargo.exe\" build --release; if ($LASTEXITCODE -eq 0) { New-Item -Force -ItemType Directory builds\\win\\panels | Out-Null; Copy-Item target\\release\\tui-wm.exe builds\\win\\tui-wm.exe -Force; Copy-Item dist\\win\\config.toml builds\\win\\config.toml -Force; Copy-Item dist\\win\\panels\\topbar.toml builds\\win\\panels\\topbar.toml -Force; Write-Host 'Done: builds\\win\\tui-wm.exe' }",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
{
|
{
|
||||||
"label": "Build Linux",
|
"label": "Build Linux",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cargo build --release --target x86_64-unknown-linux-gnu && mkdir -p builds/linux/panels && cp target/x86_64-unknown-linux-gnu/release/tui-wm builds/linux/tui-wm && cp dist/linux/config.toml builds/linux/config.toml && cp dist/linux/panels/topbar.toml builds/linux/panels/topbar.toml && echo 'Done: builds/linux/tui-wm'",
|
"command": "cargo build --release --target x86_64-unknown-linux-gnu && mkdir -p builds/linux/panels && cp target/x86_64-unknown-linux-gnu/release/tui-wm builds/linux/tui-wm && cp dist/linux/config.toml builds/linux/config.toml && cp dist/linux/panels/topbar.toml builds/linux/panels/topbar.toml && cp -r themes builds/linux/themes && echo 'Done: builds/linux/tui-wm'",
|
||||||
"options": { "shell": { "executable": "bash", "args": ["-c"] } },
|
"options": { "shell": { "executable": "bash", "args": ["-c"] } },
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"presentation": { "reveal": "always", "panel": "shared" },
|
"presentation": { "reveal": "always", "panel": "shared" },
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
{
|
{
|
||||||
"label": "Build Windows cross (GNU, från Linux)",
|
"label": "Build Windows cross (GNU, från Linux)",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cargo build --release --target x86_64-pc-windows-gnu && mkdir -p builds/win/panels && cp target/x86_64-pc-windows-gnu/release/tui-wm.exe builds/win/tui-wm.exe && cp dist/win/config.toml builds/win/config.toml && cp dist/win/panels/topbar.toml builds/win/panels/topbar.toml && echo 'Done: builds/win/tui-wm.exe'",
|
"command": "cargo build --release --target x86_64-pc-windows-gnu && mkdir -p builds/win/panels && cp target/x86_64-pc-windows-gnu/release/tui-wm.exe builds/win/tui-wm.exe && cp dist/win/config.toml builds/win/config.toml && cp dist/win/panels/topbar.toml builds/win/panels/topbar.toml && cp -r themes builds/win/themes && echo 'Done: builds/win/tui-wm.exe'",
|
||||||
"options": { "shell": { "executable": "bash", "args": ["-c"] } },
|
"options": { "shell": { "executable": "bash", "args": ["-c"] } },
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"presentation": { "reveal": "always", "panel": "shared" },
|
"presentation": { "reveal": "always", "panel": "shared" },
|
||||||
|
|||||||
86
assets/default-config.toml
Normal file
86
assets/default-config.toml
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# TUI-WM konfiguration
|
||||||
|
# Skapad av `tui-wm --init`. Dokumentation: `tui-wm --help` och README.md.
|
||||||
|
# Filen (och panels/teman den pekar på) hot-reloadas när den sparas.
|
||||||
|
|
||||||
|
# Tema — egna teman läggs som TOML-filer i themes/
|
||||||
|
theme = "themes/dark.toml"
|
||||||
|
|
||||||
|
# Skugga under/till höger om fönster
|
||||||
|
shadow = true
|
||||||
|
|
||||||
|
# Scrollback-historik per terminal + scrollbar på högerkanten
|
||||||
|
scrollback_lines = 1000
|
||||||
|
show_scrollbar = true
|
||||||
|
|
||||||
|
# Standardstorlek [bredd, höjd] för nya terminalfönster
|
||||||
|
default_window_size = [82, 26]
|
||||||
|
|
||||||
|
# Standard-shell för nya terminaler. Om inte satt → $SHELL eller /bin/bash.
|
||||||
|
# default_shell = "/bin/fish"
|
||||||
|
|
||||||
|
# Bakgrundsbild (Kitty graphics — kräver Kitty/Ghostty/WezTerm)
|
||||||
|
# background_image = "/sökväg/till/bild.jpg"
|
||||||
|
|
||||||
|
# Bakgrundsfärg för virtuella terminaler ("#RRGGBB", "0"-"255" eller färgnamn)
|
||||||
|
# terminal_bg_color = "#1a1a2e"
|
||||||
|
|
||||||
|
[[panel]]
|
||||||
|
position = "top"
|
||||||
|
file = "panels/topbar.toml"
|
||||||
|
|
||||||
|
# ── Keybinds ────────────────────────────────────────────────────────────
|
||||||
|
# scope = "global" → alltid aktiv, även när en terminal har fokus
|
||||||
|
# scope = "wm" → bara aktiv när ingen terminal är fokuserad (default)
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "ctrl+space"
|
||||||
|
scope = "global"
|
||||||
|
label = "Öppna kommandodialog"
|
||||||
|
action = { type = "spawn_run_dialog" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+enter"
|
||||||
|
scope = "global"
|
||||||
|
label = "Ny terminal"
|
||||||
|
action = { type = "spawn_terminal" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+tab"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fönsterväxlare"
|
||||||
|
action = { type = "window_switcher" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+w"
|
||||||
|
scope = "global"
|
||||||
|
action = { type = "window_switcher" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+left"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fäst vänster"
|
||||||
|
action = { type = "snap_left" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+right"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fäst höger"
|
||||||
|
action = { type = "snap_right" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+up"
|
||||||
|
scope = "global"
|
||||||
|
label = "Maximera/återställ"
|
||||||
|
action = { type = "maximize" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+c"
|
||||||
|
scope = "global"
|
||||||
|
label = "Copy-mode (sök i historik)"
|
||||||
|
action = { type = "copy_mode" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "ctrl+q"
|
||||||
|
scope = "wm"
|
||||||
|
label = "Avsluta TUI-WM"
|
||||||
|
action = { type = "exit" }
|
||||||
27
assets/default-topbar.toml
Normal file
27
assets/default-topbar.toml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Standardpanel för TUI-WM (skapad av `tui-wm --init`)
|
||||||
|
|
||||||
|
[[item]]
|
||||||
|
label = "Terminal"
|
||||||
|
action = { type = "spawn_terminal" }
|
||||||
|
|
||||||
|
# Inbyggda inställningar (tema/panel/skugga/scrollbar)
|
||||||
|
[[item]]
|
||||||
|
label = "≡ Inställningar"
|
||||||
|
action = { type = "spawn_settings" }
|
||||||
|
|
||||||
|
[[item]]
|
||||||
|
label = "Exit"
|
||||||
|
action = { type = "exit" }
|
||||||
|
|
||||||
|
# Status-widgets (körs periodiskt, visas till höger)
|
||||||
|
[[status]]
|
||||||
|
command = "date '+%H:%M:%S'"
|
||||||
|
interval = 1
|
||||||
|
width = 10
|
||||||
|
align = "right"
|
||||||
|
|
||||||
|
[[status]]
|
||||||
|
command = "date '+%Y-%m-%d'"
|
||||||
|
interval = 60
|
||||||
|
width = 12
|
||||||
|
align = "right"
|
||||||
64
dist/linux/config.toml
vendored
64
dist/linux/config.toml
vendored
@@ -1,28 +1,84 @@
|
|||||||
# TUI-WM konfiguration – Linux
|
# TUI-WM konfiguration – Linux
|
||||||
|
# Skapad av `tui-wm --init`. Dokumentation: `tui-wm --help` och README.md.
|
||||||
|
# Filen (och panels/teman den pekar på) hot-reloadas när den sparas.
|
||||||
|
|
||||||
|
# Tema — egna teman läggs som TOML-filer i themes/
|
||||||
|
theme = "themes/dark.toml"
|
||||||
|
|
||||||
|
# Skugga under/till höger om fönster
|
||||||
|
shadow = true
|
||||||
|
|
||||||
|
# Scrollback-historik per terminal + scrollbar på högerkanten
|
||||||
|
scrollback_lines = 1000
|
||||||
|
show_scrollbar = true
|
||||||
|
|
||||||
|
# Standardstorlek [bredd, höjd] för nya terminalfönster
|
||||||
|
default_window_size = [82, 26]
|
||||||
|
|
||||||
|
# Standard-shell för nya terminaler. Om inte satt → $SHELL eller /bin/bash.
|
||||||
|
# default_shell = "/bin/fish"
|
||||||
|
|
||||||
|
# Bakgrundsbild (Kitty graphics — kräver Kitty/Ghostty/WezTerm)
|
||||||
|
# background_image = "/sökväg/till/bild.jpg"
|
||||||
|
|
||||||
|
# Bakgrundsfärg för virtuella terminaler ("#RRGGBB", "0"-"255" eller färgnamn)
|
||||||
|
# terminal_bg_color = "#1a1a2e"
|
||||||
|
|
||||||
[[panel]]
|
[[panel]]
|
||||||
position = "top"
|
position = "top"
|
||||||
file = "panels/topbar.toml"
|
file = "panels/topbar.toml"
|
||||||
|
|
||||||
# ── Keybinds ──────────────────────────────────────────────────────────────────
|
# ── Keybinds ────────────────────────────────────────────────────────────
|
||||||
# scope = "global" → alltid aktiv, även när en terminal har fokus
|
# scope = "global" → alltid aktiv, även när en terminal har fokus
|
||||||
# scope = "wm" → bara aktiv när ingen terminal är fokuserad (default)
|
# scope = "wm" → bara aktiv när ingen terminal är fokuserad (default)
|
||||||
|
|
||||||
# Öppna Tui-run kommandodialog (global – funkar alltid)
|
|
||||||
[[keybind]]
|
[[keybind]]
|
||||||
key = "ctrl+space"
|
key = "ctrl+space"
|
||||||
scope = "global"
|
scope = "global"
|
||||||
label = "Öppna kommandodialog"
|
label = "Öppna kommandodialog"
|
||||||
action = { type = "spawn_run_dialog" }
|
action = { type = "spawn_run_dialog" }
|
||||||
|
|
||||||
# Starta ny terminal med Alt+Enter
|
|
||||||
[[keybind]]
|
[[keybind]]
|
||||||
key = "alt+enter"
|
key = "alt+enter"
|
||||||
scope = "global"
|
scope = "global"
|
||||||
label = "Ny terminal"
|
label = "Ny terminal"
|
||||||
action = { type = "spawn_terminal" }
|
action = { type = "spawn_terminal" }
|
||||||
|
|
||||||
# Avsluta TUI-WM när skrivbordet är fokuserat
|
[[keybind]]
|
||||||
|
key = "alt+tab"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fönsterväxlare"
|
||||||
|
action = { type = "window_switcher" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+w"
|
||||||
|
scope = "global"
|
||||||
|
action = { type = "window_switcher" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+left"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fäst vänster"
|
||||||
|
action = { type = "snap_left" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+right"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fäst höger"
|
||||||
|
action = { type = "snap_right" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+up"
|
||||||
|
scope = "global"
|
||||||
|
label = "Maximera/återställ"
|
||||||
|
action = { type = "maximize" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+c"
|
||||||
|
scope = "global"
|
||||||
|
label = "Copy-mode (sök i historik)"
|
||||||
|
action = { type = "copy_mode" }
|
||||||
|
|
||||||
[[keybind]]
|
[[keybind]]
|
||||||
key = "ctrl+q"
|
key = "ctrl+q"
|
||||||
scope = "wm"
|
scope = "wm"
|
||||||
|
|||||||
10
dist/linux/panels/topbar.toml
vendored
10
dist/linux/panels/topbar.toml
vendored
@@ -1,21 +1,25 @@
|
|||||||
# Topbar – Linux
|
# Standardpanel för TUI-WM (skapad av `tui-wm --init`)
|
||||||
|
|
||||||
[[item]]
|
[[item]]
|
||||||
label = "Terminal"
|
label = "Terminal"
|
||||||
action = { type = "spawn_terminal" }
|
action = { type = "spawn_terminal" }
|
||||||
|
|
||||||
|
# Inbyggda inställningar (tema/panel/skugga/scrollbar)
|
||||||
|
[[item]]
|
||||||
|
label = "≡ Inställningar"
|
||||||
|
action = { type = "spawn_settings" }
|
||||||
|
|
||||||
[[item]]
|
[[item]]
|
||||||
label = "Exit"
|
label = "Exit"
|
||||||
action = { type = "exit" }
|
action = { type = "exit" }
|
||||||
|
|
||||||
# Klocka – uppdateras varje sekund
|
# Status-widgets (körs periodiskt, visas till höger)
|
||||||
[[status]]
|
[[status]]
|
||||||
command = "date '+%H:%M:%S'"
|
command = "date '+%H:%M:%S'"
|
||||||
interval = 1
|
interval = 1
|
||||||
width = 10
|
width = 10
|
||||||
align = "right"
|
align = "right"
|
||||||
|
|
||||||
# Datum – uppdateras varje minut
|
|
||||||
[[status]]
|
[[status]]
|
||||||
command = "date '+%Y-%m-%d'"
|
command = "date '+%Y-%m-%d'"
|
||||||
interval = 60
|
interval = 60
|
||||||
|
|||||||
66
dist/win/config.toml
vendored
66
dist/win/config.toml
vendored
@@ -1,28 +1,84 @@
|
|||||||
# TUI-WM konfiguration – Windows
|
# TUI-WM konfiguration – Windows
|
||||||
|
# Skapad av `tui-wm --init`. Dokumentation: `tui-wm --help` och README.md.
|
||||||
|
# Filen (och panels/teman den pekar på) hot-reloadas när den sparas.
|
||||||
|
|
||||||
|
# Tema — egna teman läggs som TOML-filer i themes/
|
||||||
|
theme = "themes/dark.toml"
|
||||||
|
|
||||||
|
# Skugga under/till höger om fönster
|
||||||
|
shadow = true
|
||||||
|
|
||||||
|
# Scrollback-historik per terminal + scrollbar på högerkanten
|
||||||
|
scrollback_lines = 1000
|
||||||
|
show_scrollbar = true
|
||||||
|
|
||||||
|
# Standardstorlek [bredd, höjd] för nya terminalfönster
|
||||||
|
default_window_size = [82, 26]
|
||||||
|
|
||||||
|
# Standard-shell för nya terminaler. Om inte satt → $SHELL eller /bin/bash.
|
||||||
|
# default_shell = "/bin/fish"
|
||||||
|
|
||||||
|
# Bakgrundsbild (Kitty graphics — kräver Kitty/Ghostty/WezTerm)
|
||||||
|
# background_image = "/sökväg/till/bild.jpg"
|
||||||
|
|
||||||
|
# Bakgrundsfärg för virtuella terminaler ("#RRGGBB", "0"-"255" eller färgnamn)
|
||||||
|
# terminal_bg_color = "#1a1a2e"
|
||||||
|
|
||||||
[[panel]]
|
[[panel]]
|
||||||
position = "top"
|
position = "top"
|
||||||
file = "panels/topbar.toml"
|
file = "panels/topbar.toml"
|
||||||
|
|
||||||
# ── Keybinds ──────────────────────────────────────────────────────────────────
|
# ── Keybinds ────────────────────────────────────────────────────────────
|
||||||
# scope = "global" → alltid aktiv, även när en terminal har fokus
|
# scope = "global" → alltid aktiv, även när en terminal har fokus
|
||||||
# scope = "wm" → bara aktiv när ingen terminal är fokuserad (default)
|
# scope = "wm" → bara aktiv när ingen terminal är fokuserad (default)
|
||||||
|
|
||||||
# Öppna Tui-run kommandodialog (global – funkar alltid)
|
|
||||||
[[keybind]]
|
[[keybind]]
|
||||||
key = "ctrl+space"
|
key = "ctrl+space"
|
||||||
scope = "global"
|
scope = "global"
|
||||||
label = "Öppna kommandodialog"
|
label = "Öppna kommandodialog"
|
||||||
action = { type = "spawn_run_dialog" }
|
action = { type = "spawn_run_dialog" }
|
||||||
|
|
||||||
# Starta ny PowerShell-terminal
|
|
||||||
[[keybind]]
|
[[keybind]]
|
||||||
key = "alt+enter"
|
key = "alt+enter"
|
||||||
scope = "global"
|
scope = "global"
|
||||||
label = "Ny terminal"
|
label = "Ny PowerShell-terminal"
|
||||||
action = { type = "spawn_terminal", shell = "powershell.exe" }
|
action = { type = "spawn_terminal", shell = "powershell.exe" }
|
||||||
|
|
||||||
# Avsluta TUI-WM när skrivbordet är fokuserat
|
[[keybind]]
|
||||||
|
key = "alt+tab"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fönsterväxlare"
|
||||||
|
action = { type = "window_switcher" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+w"
|
||||||
|
scope = "global"
|
||||||
|
action = { type = "window_switcher" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+left"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fäst vänster"
|
||||||
|
action = { type = "snap_left" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+right"
|
||||||
|
scope = "global"
|
||||||
|
label = "Fäst höger"
|
||||||
|
action = { type = "snap_right" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+up"
|
||||||
|
scope = "global"
|
||||||
|
label = "Maximera/återställ"
|
||||||
|
action = { type = "maximize" }
|
||||||
|
|
||||||
|
[[keybind]]
|
||||||
|
key = "alt+c"
|
||||||
|
scope = "global"
|
||||||
|
label = "Copy-mode (sök i historik)"
|
||||||
|
action = { type = "copy_mode" }
|
||||||
|
|
||||||
[[keybind]]
|
[[keybind]]
|
||||||
key = "ctrl+q"
|
key = "ctrl+q"
|
||||||
scope = "wm"
|
scope = "wm"
|
||||||
|
|||||||
14
dist/win/panels/topbar.toml
vendored
14
dist/win/panels/topbar.toml
vendored
@@ -1,23 +1,27 @@
|
|||||||
# Topbar – Windows (PowerShell-kommandon)
|
# Standardpanel för TUI-WM (skapad av `tui-wm --init`)
|
||||||
|
|
||||||
[[item]]
|
[[item]]
|
||||||
label = "Terminal"
|
label = "Terminal"
|
||||||
action = { type = "spawn_terminal", shell = "powershell.exe" }
|
action = { type = "spawn_terminal", shell = "powershell.exe" }
|
||||||
|
|
||||||
|
# Inbyggda inställningar (tema/panel/skugga/scrollbar)
|
||||||
|
[[item]]
|
||||||
|
label = "≡ Inställningar"
|
||||||
|
action = { type = "spawn_settings" }
|
||||||
|
|
||||||
[[item]]
|
[[item]]
|
||||||
label = "Exit"
|
label = "Exit"
|
||||||
action = { type = "exit" }
|
action = { type = "exit" }
|
||||||
|
|
||||||
# Klocka – uppdateras varje sekund (PowerShell)
|
# Status-widgets (körs periodiskt, visas till höger)
|
||||||
[[status]]
|
[[status]]
|
||||||
command = "Get-Date -Format 'HH:mm:ss'"
|
command = "powershell -NoProfile -Command Get-Date -Format HH:mm:ss"
|
||||||
interval = 1
|
interval = 1
|
||||||
width = 10
|
width = 10
|
||||||
align = "right"
|
align = "right"
|
||||||
|
|
||||||
# Datum – uppdateras varje minut (PowerShell)
|
|
||||||
[[status]]
|
[[status]]
|
||||||
command = "Get-Date -Format 'yyyy-MM-dd'"
|
command = "powershell -NoProfile -Command Get-Date -Format yyyy-MM-dd"
|
||||||
interval = 60
|
interval = 60
|
||||||
width = 12
|
width = 12
|
||||||
align = "right"
|
align = "right"
|
||||||
|
|||||||
77
src/main.rs
77
src/main.rs
@@ -28,6 +28,7 @@ enum Mode {
|
|||||||
Standalone,
|
Standalone,
|
||||||
Daemon,
|
Daemon,
|
||||||
Client(String),
|
Client(String),
|
||||||
|
Init(Option<String>),
|
||||||
Help,
|
Help,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +38,10 @@ fn parse_args() -> Mode {
|
|||||||
while i < args.len() {
|
while i < args.len() {
|
||||||
match args[i].as_str() {
|
match args[i].as_str() {
|
||||||
"-h" | "--help" => return Mode::Help,
|
"-h" | "--help" => return Mode::Help,
|
||||||
|
"--init" => {
|
||||||
|
let dir = args.get(i + 1).filter(|s| !s.starts_with('-')).cloned();
|
||||||
|
return Mode::Init(dir);
|
||||||
|
}
|
||||||
"-d" | "--daemon" => return Mode::Daemon,
|
"-d" | "--daemon" => return Mode::Daemon,
|
||||||
"-c" | "--connect" => {
|
"-c" | "--connect" => {
|
||||||
let path = args
|
let path = args
|
||||||
@@ -58,6 +63,7 @@ fn main() -> io::Result<()> {
|
|||||||
Mode::Standalone => run_standalone(),
|
Mode::Standalone => run_standalone(),
|
||||||
Mode::Daemon => run_daemon_mode(),
|
Mode::Daemon => run_daemon_mode(),
|
||||||
Mode::Client(path) => client::run(&path),
|
Mode::Client(path) => client::run(&path),
|
||||||
|
Mode::Init(dir) => run_init(dir.as_deref()),
|
||||||
Mode::Help => {
|
Mode::Help => {
|
||||||
print_help();
|
print_help();
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -65,6 +71,70 @@ fn main() -> io::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Standardkatalog för konfiguration: $XDG_CONFIG_HOME/tui-wm
|
||||||
|
/// (~/.config/tui-wm), på Windows %APPDATA%\tui-wm.
|
||||||
|
fn default_config_dir() -> std::path::PathBuf {
|
||||||
|
if let Ok(x) = std::env::var("XDG_CONFIG_HOME") {
|
||||||
|
return std::path::PathBuf::from(x).join("tui-wm");
|
||||||
|
}
|
||||||
|
#[cfg(windows)]
|
||||||
|
if let Ok(a) = std::env::var("APPDATA") {
|
||||||
|
return std::path::PathBuf::from(a).join("tui-wm");
|
||||||
|
}
|
||||||
|
if let Ok(h) = std::env::var("HOME") {
|
||||||
|
return std::path::PathBuf::from(h).join(".config").join("tui-wm");
|
||||||
|
}
|
||||||
|
std::path::PathBuf::from(".")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `tui-wm --init [KATALOG]` — skriv ut standardkonfiguration
|
||||||
|
/// (config.toml, panels/, themes/). Befintliga filer rörs inte.
|
||||||
|
fn run_init(dir: Option<&str>) -> io::Result<()> {
|
||||||
|
let base = dir
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_else(default_config_dir);
|
||||||
|
let files: &[(&str, &str)] = &[
|
||||||
|
("config.toml", include_str!("../assets/default-config.toml")),
|
||||||
|
("panels/topbar.toml", include_str!("../assets/default-topbar.toml")),
|
||||||
|
("themes/dark.toml", include_str!("../themes/dark.toml")),
|
||||||
|
("themes/light.toml", include_str!("../themes/light.toml")),
|
||||||
|
];
|
||||||
|
for (rel, content) in files {
|
||||||
|
let path = base.join(rel);
|
||||||
|
if path.exists() {
|
||||||
|
println!(" finns redan: {}", path.display());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if let Some(parent) = path.parent() {
|
||||||
|
std::fs::create_dir_all(parent)?;
|
||||||
|
}
|
||||||
|
std::fs::write(&path, content)?;
|
||||||
|
println!(" skapade: {}", path.display());
|
||||||
|
}
|
||||||
|
println!("\nKlart. Starta med `tui-wm` — konfigurationen hittas automatiskt");
|
||||||
|
println!("i {} när ./config.toml saknas.", base.display());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hitta konfigurationskatalogen: ./config.toml vinner, annars
|
||||||
|
/// XDG-katalogen. Byter arbetskatalog dit så att alla relativa
|
||||||
|
/// sökvägar (panels/, themes/, config-sparningar, hot-reload) fungerar
|
||||||
|
/// enhetligt. Ursprungliga arbetskatalogen sparas för PTY-spawns.
|
||||||
|
fn enter_config_dir() {
|
||||||
|
if let Ok(cwd) = std::env::current_dir() {
|
||||||
|
crate::pty::set_spawn_cwd(cwd.clone());
|
||||||
|
if cwd.join("config.toml").exists() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let xdg = default_config_dir();
|
||||||
|
if xdg.join("config.toml").exists() {
|
||||||
|
if let Err(e) = std::env::set_current_dir(&xdg) {
|
||||||
|
eprintln!("Kunde inte byta till {}: {}", xdg.display(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn print_help() {
|
fn print_help() {
|
||||||
println!(
|
println!(
|
||||||
"\
|
"\
|
||||||
@@ -84,9 +154,12 @@ FLAGGOR:
|
|||||||
SSH). Tangentbord, mus (klick/scroll/drag) och
|
SSH). Tangentbord, mus (klick/scroll/drag) och
|
||||||
resize vidarebefordras. Koppla ner med Ctrl+Shift+Q
|
resize vidarebefordras. Koppla ner med Ctrl+Shift+Q
|
||||||
— servern och dess program fortsätter köra.
|
— servern och dess program fortsätter köra.
|
||||||
|
--init [KATALOG] Skriv standardkonfiguration (config.toml, panels/,
|
||||||
|
themes/) till KATALOG — default ~/.config/tui-wm.
|
||||||
|
Befintliga filer rörs inte.
|
||||||
-h, --help Visa den här hjälpen.
|
-h, --help Visa den här hjälpen.
|
||||||
|
|
||||||
KONFIGURATION (./config.toml + panels/*.toml):
|
KONFIGURATION (./config.toml, annars ~/.config/tui-wm/config.toml):
|
||||||
default_shell = \"/bin/bash\" # skal för nya terminaler
|
default_shell = \"/bin/bash\" # skal för nya terminaler
|
||||||
default_window_size = [82, 26] # [bredd, höjd] för nya fönster
|
default_window_size = [82, 26] # [bredd, höjd] för nya fönster
|
||||||
scrollback_lines = 1000 # historikrader per terminal
|
scrollback_lines = 1000 # historikrader per terminal
|
||||||
@@ -121,6 +194,7 @@ SOCKET-API:
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_standalone() -> io::Result<()> {
|
fn run_standalone() -> io::Result<()> {
|
||||||
|
enter_config_dir();
|
||||||
log::init();
|
log::init();
|
||||||
let socket_path = ipc::default_socket_path();
|
let socket_path = ipc::default_socket_path();
|
||||||
let (ipc_tx, ipc_rx) = mpsc::channel::<IpcEvent>();
|
let (ipc_tx, ipc_rx) = mpsc::channel::<IpcEvent>();
|
||||||
@@ -346,6 +420,7 @@ fn update_background(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_daemon_mode() -> io::Result<()> {
|
fn run_daemon_mode() -> io::Result<()> {
|
||||||
|
enter_config_dir();
|
||||||
log::init();
|
log::init();
|
||||||
let socket_path = ipc::default_socket_path();
|
let socket_path = ipc::default_socket_path();
|
||||||
let (ipc_tx, ipc_rx) = mpsc::channel::<IpcEvent>();
|
let (ipc_tx, ipc_rx) = mpsc::channel::<IpcEvent>();
|
||||||
|
|||||||
13
src/pty.rs
13
src/pty.rs
@@ -28,6 +28,16 @@ fn build_command(shell: &str) -> CommandBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Arbetskatalogen som nya PTY-processer ska starta i. Sätts av main
|
||||||
|
/// innan processen ev. byter till konfig-katalogen — annars skulle
|
||||||
|
/// spawnade skal öppnas i ~/.config/tui-wm i stället för där
|
||||||
|
/// användaren startade TUI-WM.
|
||||||
|
static SPAWN_CWD: std::sync::OnceLock<std::path::PathBuf> = std::sync::OnceLock::new();
|
||||||
|
|
||||||
|
pub fn set_spawn_cwd(dir: std::path::PathBuf) {
|
||||||
|
let _ = SPAWN_CWD.set(dir);
|
||||||
|
}
|
||||||
|
|
||||||
pub struct PtyTerminal {
|
pub struct PtyTerminal {
|
||||||
pub master: Box<dyn portable_pty::MasterPty + Send>,
|
pub master: Box<dyn portable_pty::MasterPty + Send>,
|
||||||
pub writer: Box<dyn std::io::Write + Send>,
|
pub writer: Box<dyn std::io::Write + Send>,
|
||||||
@@ -45,6 +55,9 @@ impl PtyTerminal {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let mut cmd = build_command(shell);
|
let mut cmd = build_command(shell);
|
||||||
|
if let Some(cwd) = SPAWN_CWD.get() {
|
||||||
|
cmd.cwd(cwd);
|
||||||
|
}
|
||||||
cmd.env("TERM", "xterm-256color");
|
cmd.env("TERM", "xterm-256color");
|
||||||
cmd.env("COLORTERM", "truecolor");
|
cmd.env("COLORTERM", "truecolor");
|
||||||
for (key, val) in extra_env {
|
for (key, val) in extra_env {
|
||||||
|
|||||||
Reference in New Issue
Block a user