mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-02 18:42:06 -04:00
Compare commits
38 Commits
frame
...
0ab9b1e4e9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ab9b1e4e9 | ||
|
|
6d0953de68 | ||
|
|
bc6bbdbe9d | ||
|
|
eff728fdf5 | ||
|
|
8d415e9568 | ||
|
|
e6ed6a1cc2 | ||
|
|
ca18174da5 | ||
|
|
976b231b93 | ||
|
|
3d75a51378 | ||
|
|
dc4b1529e6 | ||
|
|
f61438e11f | ||
|
|
8f78163941 | ||
|
|
f894d338fc | ||
|
|
f2df53afcd | ||
|
|
4179fcee83 | ||
|
|
a0c9af1ee7 | ||
|
|
049266271a | ||
|
|
0eabda3164 | ||
|
|
32c063aab8 | ||
|
|
37f92677cf | ||
|
|
13e8130858 | ||
|
|
f6e590a518 | ||
|
|
3194fc3fbe | ||
|
|
3318864ece | ||
|
|
e224417593 | ||
|
|
3f7f6c5d2c | ||
|
|
0b88055742 | ||
|
|
2b0826e397 | ||
|
|
7db04c9660 | ||
|
|
14d1e1d985 | ||
|
|
903ab1e61d | ||
|
|
5982655539 | ||
|
|
1021a210cf | ||
|
|
e34edb15bb | ||
|
|
61ee5f4336 | ||
|
|
ce2a92ec27 | ||
|
|
66ce79b9bf | ||
|
|
30dd640314 |
@@ -10,7 +10,7 @@ Go-based backend for DankMaterialShell providing system integration, IPC, and in
|
||||
Command-line interface and daemon for shell management and system control.
|
||||
|
||||
**dankinstall**
|
||||
Distribution-aware installer with TUI for deploying DMS and compositor configurations on Arch, Fedora, Debian, Ubuntu, openSUSE, and Gentoo.
|
||||
Distribution-aware installer for deploying DMS and compositor configurations on Arch, Fedora, Debian, Ubuntu, openSUSE, and Gentoo. Supports both an interactive TUI and a headless (unattended) mode via CLI flags.
|
||||
|
||||
## System Integration
|
||||
|
||||
@@ -147,10 +147,50 @@ go-wayland-scanner -i internal/proto/xml/wlr-gamma-control-unstable-v1.xml \
|
||||
|
||||
## Installation via dankinstall
|
||||
|
||||
**Interactive (TUI):**
|
||||
|
||||
```bash
|
||||
curl -fsSL https://install.danklinux.com | sh
|
||||
```
|
||||
|
||||
**Headless (unattended):**
|
||||
|
||||
Headless mode requires cached sudo credentials. Run `sudo -v` first:
|
||||
|
||||
```bash
|
||||
sudo -v && curl -fsSL https://install.danklinux.com | sh -s -- -c niri -t ghostty -y
|
||||
sudo -v && curl -fsSL https://install.danklinux.com | sh -s -- -c hyprland -t kitty --include-deps dms-greeter -y
|
||||
```
|
||||
|
||||
| Flag | Short | Description |
|
||||
|------|-------|-------------|
|
||||
| `--compositor <niri|hyprland>` | `-c` | Compositor/WM to install (required for headless) |
|
||||
| `--term <ghostty|kitty|alacritty>` | `-t` | Terminal emulator (required for headless) |
|
||||
| `--include-deps <name,...>` | | Enable optional dependencies (e.g. `dms-greeter`) |
|
||||
| `--exclude-deps <name,...>` | | Skip specific dependencies |
|
||||
| `--replace-configs <name,...>` | | Replace specific configuration files (mutually exclusive with `--replace-configs-all`) |
|
||||
| `--replace-configs-all` | | Replace all configuration files (mutually exclusive with `--replace-configs`) |
|
||||
| `--yes` | `-y` | Required for headless mode — confirms installation without interactive prompts |
|
||||
|
||||
Headless mode requires `--yes` to proceed; without it, the installer exits with an error.
|
||||
Configuration files are not replaced by default unless `--replace-configs` or `--replace-configs-all` is specified.
|
||||
`dms-greeter` is disabled by default; use `--include-deps dms-greeter` to enable it.
|
||||
|
||||
When no flags are provided, `dankinstall` launches the interactive TUI.
|
||||
|
||||
### Headless mode validation rules
|
||||
|
||||
Headless mode activates when `--compositor` or `--term` is provided.
|
||||
|
||||
- Both `--compositor` and `--term` are required; providing only one results in an error.
|
||||
- Headless-only flags (`--include-deps`, `--exclude-deps`, `--replace-configs`, `--replace-configs-all`, `--yes`) are rejected in TUI mode.
|
||||
- Positional arguments are not accepted.
|
||||
|
||||
### Log file location
|
||||
|
||||
`dankinstall` writes logs to `/tmp` by default.
|
||||
Set the `DANKINSTALL_LOG_DIR` environment variable to override the log directory.
|
||||
|
||||
## Supported Distributions
|
||||
|
||||
Arch, Fedora, Debian, Ubuntu, openSUSE, Gentoo (and derivatives)
|
||||
|
||||
@@ -3,20 +3,152 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/headless"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/tui"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Version = "dev"
|
||||
|
||||
// Flag variables bound via pflag
|
||||
var (
|
||||
compositor string
|
||||
term string
|
||||
includeDeps []string
|
||||
excludeDeps []string
|
||||
replaceConfigs []string
|
||||
replaceConfigsAll bool
|
||||
yes bool
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "dankinstall",
|
||||
Short: "Install DankMaterialShell and its dependencies",
|
||||
Long: `dankinstall sets up DankMaterialShell with your chosen compositor and terminal.
|
||||
|
||||
Without flags, it launches an interactive TUI. Providing either --compositor
|
||||
or --term activates headless (unattended) mode, which requires both flags.
|
||||
|
||||
Headless mode requires cached sudo credentials. Run 'sudo -v' beforehand, or
|
||||
configure passwordless sudo for your user.`,
|
||||
Args: cobra.NoArgs,
|
||||
RunE: runDankinstall,
|
||||
SilenceErrors: true,
|
||||
SilenceUsage: true,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.Flags().StringVarP(&compositor, "compositor", "c", "", "Compositor/WM to install: niri or hyprland (enables headless mode)")
|
||||
rootCmd.Flags().StringVarP(&term, "term", "t", "", "Terminal emulator to install: ghostty, kitty, or alacritty (enables headless mode)")
|
||||
rootCmd.Flags().StringSliceVar(&includeDeps, "include-deps", []string{}, "Optional deps to enable (e.g. dms-greeter)")
|
||||
rootCmd.Flags().StringSliceVar(&excludeDeps, "exclude-deps", []string{}, "Deps to skip during installation")
|
||||
rootCmd.Flags().StringSliceVar(&replaceConfigs, "replace-configs", []string{}, "Deploy only named configs (e.g. niri,ghostty)")
|
||||
rootCmd.Flags().BoolVar(&replaceConfigsAll, "replace-configs-all", false, "Deploy and replace all configurations")
|
||||
rootCmd.Flags().BoolVarP(&yes, "yes", "y", false, "Auto-confirm all prompts")
|
||||
}
|
||||
|
||||
func main() {
|
||||
if os.Getuid() == 0 {
|
||||
fmt.Fprintln(os.Stderr, "Error: dankinstall must not be run as root")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func runDankinstall(cmd *cobra.Command, args []string) error {
|
||||
headlessMode := compositor != "" || term != ""
|
||||
|
||||
if !headlessMode {
|
||||
// Reject headless-only flags when running in TUI mode.
|
||||
headlessOnly := []string{
|
||||
"include-deps",
|
||||
"exclude-deps",
|
||||
"replace-configs",
|
||||
"replace-configs-all",
|
||||
"yes",
|
||||
}
|
||||
var set []string
|
||||
for _, name := range headlessOnly {
|
||||
if cmd.Flags().Changed(name) {
|
||||
set = append(set, "--"+name)
|
||||
}
|
||||
}
|
||||
if len(set) > 0 {
|
||||
return fmt.Errorf("flags %s are only valid in headless mode (requires both --compositor and --term)", strings.Join(set, ", "))
|
||||
}
|
||||
}
|
||||
|
||||
if headlessMode {
|
||||
return runHeadless()
|
||||
}
|
||||
return runTUI()
|
||||
}
|
||||
|
||||
func runHeadless() error {
|
||||
// Validate required flags
|
||||
if compositor == "" {
|
||||
return fmt.Errorf("--compositor is required for headless mode (niri or hyprland)")
|
||||
}
|
||||
if term == "" {
|
||||
return fmt.Errorf("--term is required for headless mode (ghostty, kitty, or alacritty)")
|
||||
}
|
||||
|
||||
cfg := headless.Config{
|
||||
Compositor: compositor,
|
||||
Terminal: term,
|
||||
IncludeDeps: includeDeps,
|
||||
ExcludeDeps: excludeDeps,
|
||||
ReplaceConfigs: replaceConfigs,
|
||||
ReplaceConfigsAll: replaceConfigsAll,
|
||||
Yes: yes,
|
||||
}
|
||||
|
||||
runner := headless.NewRunner(cfg)
|
||||
|
||||
// Set up file logging
|
||||
fileLogger, err := log.NewFileLogger()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: Failed to create log file: %v\n", err)
|
||||
}
|
||||
|
||||
if fileLogger != nil {
|
||||
fmt.Printf("Logging to: %s\n", fileLogger.GetLogPath())
|
||||
fileLogger.StartListening(runner.GetLogChan())
|
||||
defer func() {
|
||||
if err := fileLogger.Close(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: Failed to close log file: %v\n", err)
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
// Drain the log channel to prevent blocking sends from deadlocking
|
||||
// downstream components (distros, config deployer) that write to it.
|
||||
// Use an explicit stop signal because this code does not own the
|
||||
// runner log channel and cannot assume it will be closed.
|
||||
defer drainLogChan(runner.GetLogChan())()
|
||||
}
|
||||
|
||||
if err := runner.Run(); err != nil {
|
||||
if fileLogger != nil {
|
||||
fmt.Fprintf(os.Stderr, "\nFull logs are available at: %s\n", fileLogger.GetLogPath())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if fileLogger != nil {
|
||||
fmt.Printf("\nFull logs are available at: %s\n", fileLogger.GetLogPath())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func runTUI() error {
|
||||
fileLogger, err := log.NewFileLogger()
|
||||
if err != nil {
|
||||
fmt.Printf("Warning: Failed to create log file: %v\n", err)
|
||||
@@ -38,18 +170,50 @@ func main() {
|
||||
|
||||
if fileLogger != nil {
|
||||
fileLogger.StartListening(model.GetLogChan())
|
||||
} else {
|
||||
// Drain the log channel to prevent blocking sends from deadlocking
|
||||
// downstream components (distros, config deployer) that write to it.
|
||||
// Use an explicit stop signal because this code does not own the
|
||||
// model log channel and cannot assume it will be closed.
|
||||
defer drainLogChan(model.GetLogChan())()
|
||||
}
|
||||
|
||||
p := tea.NewProgram(model, tea.WithAltScreen())
|
||||
if _, err := p.Run(); err != nil {
|
||||
fmt.Printf("Error running program: %v\n", err)
|
||||
if logFilePath != "" {
|
||||
fmt.Printf("\nFull logs are available at: %s\n", logFilePath)
|
||||
fmt.Fprintf(os.Stderr, "\nFull logs are available at: %s\n", logFilePath)
|
||||
}
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("error running program: %w", err)
|
||||
}
|
||||
|
||||
if logFilePath != "" {
|
||||
fmt.Printf("\nFull logs are available at: %s\n", logFilePath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// drainLogChan starts a goroutine that discards all messages from logCh,
|
||||
// preventing blocking sends from deadlocking downstream components. It returns
|
||||
// a cleanup function that signals the goroutine to stop and waits for it to
|
||||
// exit. Callers should defer the returned function.
|
||||
func drainLogChan(logCh <-chan string) func() {
|
||||
drainStop := make(chan struct{})
|
||||
drainDone := make(chan struct{})
|
||||
go func() {
|
||||
defer close(drainDone)
|
||||
for {
|
||||
select {
|
||||
case <-drainStop:
|
||||
return
|
||||
case _, ok := <-logCh:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
return func() {
|
||||
close(drainStop)
|
||||
<-drainDone
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +236,7 @@ func runBrightnessSet(cmd *cobra.Command, args []string) {
|
||||
defer ddc.Close()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if err := ddc.SetBrightnessWithExponent(deviceID, percent, exponential, exponent, nil); err == nil {
|
||||
ddc.WaitPending()
|
||||
fmt.Printf("Set %s to %d%%\n", deviceID, percent)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (ds *DoctorStatus) OKCount() int {
|
||||
}
|
||||
|
||||
var (
|
||||
quickshellVersionRegex = regexp.MustCompile(`quickshell (\d+\.\d+\.\d+)`)
|
||||
quickshellVersionRegex = regexp.MustCompile(`(?i)quickshell (\d+\.\d+\.\d+)`)
|
||||
hyprlandVersionRegex = regexp.MustCompile(`v?(\d+\.\d+\.\d+)`)
|
||||
niriVersionRegex = regexp.MustCompile(`niri (\d+\.\d+)`)
|
||||
swayVersionRegex = regexp.MustCompile(`sway version (\d+\.\d+)`)
|
||||
@@ -820,10 +820,14 @@ func checkOptionalDependencies() []checkResult {
|
||||
results = append(results, checkImageFormatPlugins()...)
|
||||
|
||||
terminals := []string{"ghostty", "kitty", "alacritty", "foot", "wezterm"}
|
||||
if idx := slices.IndexFunc(terminals, utils.CommandExists); idx >= 0 {
|
||||
results = append(results, checkResult{catOptionalFeatures, "Terminal", statusOK, terminals[idx], "", optionalFeaturesURL})
|
||||
terminals = slices.DeleteFunc(terminals, func(t string) bool {
|
||||
return !utils.CommandExists(t)
|
||||
})
|
||||
|
||||
if len(terminals) > 0 {
|
||||
results = append(results, checkResult{catOptionalFeatures, "Terminal", statusOK, strings.Join(terminals, ", "), "", optionalFeaturesURL})
|
||||
} else {
|
||||
results = append(results, checkResult{catOptionalFeatures, "Terminal", statusWarn, "None found", "Install ghostty, kitty, or alacritty", optionalFeaturesURL})
|
||||
results = append(results, checkResult{catOptionalFeatures, "Terminal", statusWarn, "None found", "Install ghostty, kitty, foot or alacritty", optionalFeaturesURL})
|
||||
}
|
||||
|
||||
networkResult, err := network.DetectNetworkStack()
|
||||
|
||||
@@ -109,16 +109,41 @@ func updateArchLinux() error {
|
||||
}
|
||||
|
||||
var packageName string
|
||||
if isArchPackageInstalled("dms-shell-bin") {
|
||||
packageName = "dms-shell-bin"
|
||||
var isAUR bool
|
||||
if isArchPackageInstalled("dms-shell") {
|
||||
packageName = "dms-shell"
|
||||
} else if isArchPackageInstalled("dms-shell-git") {
|
||||
packageName = "dms-shell-git"
|
||||
isAUR = true
|
||||
} else if isArchPackageInstalled("dms-shell-bin") {
|
||||
packageName = "dms-shell-bin"
|
||||
isAUR = true
|
||||
} else {
|
||||
fmt.Println("Info: Neither dms-shell-bin nor dms-shell-git package found.")
|
||||
fmt.Println("Info: No dms-shell package found.")
|
||||
fmt.Println("Info: Falling back to git-based update method...")
|
||||
return updateOtherDistros()
|
||||
}
|
||||
|
||||
if !isAUR {
|
||||
fmt.Printf("This will update %s using pacman.\n", packageName)
|
||||
if !confirmUpdate() {
|
||||
return errdefs.ErrUpdateCancelled
|
||||
}
|
||||
|
||||
fmt.Printf("\nRunning: sudo pacman -S %s\n", packageName)
|
||||
cmd := exec.Command("sudo", "pacman", "-S", "--noconfirm", packageName)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Printf("Error: Failed to update using pacman: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("dms successfully updated")
|
||||
return nil
|
||||
}
|
||||
|
||||
var helper string
|
||||
var updateCmd *exec.Cmd
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/clipboard"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
)
|
||||
|
||||
@@ -30,7 +31,9 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if os.Geteuid() == 0 {
|
||||
clipboard.MaybeServeAndExit()
|
||||
|
||||
if os.Geteuid() == 0 && !isReadOnlyCommand(os.Args) {
|
||||
log.Fatal("This program should not be run as root. Exiting.")
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/clipboard"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
)
|
||||
|
||||
@@ -27,7 +28,9 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if os.Geteuid() == 0 {
|
||||
clipboard.MaybeServeAndExit()
|
||||
|
||||
if os.Geteuid() == 0 && !isReadOnlyCommand(os.Args) {
|
||||
log.Fatal("This program should not be run as root. Exiting.")
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,22 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// isReadOnlyCommand returns true if the CLI args indicate a command that is
|
||||
// safe to run as root (e.g. shell completion, help).
|
||||
func isReadOnlyCommand(args []string) bool {
|
||||
for _, arg := range args[1:] {
|
||||
if strings.HasPrefix(arg, "-") {
|
||||
continue
|
||||
}
|
||||
switch arg {
|
||||
case "completion", "help", "__complete":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isArchPackageInstalled(packageName string) bool {
|
||||
cmd := exec.Command("pacman", "-Q", packageName)
|
||||
err := cmd.Run()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package clipboard
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -13,66 +12,142 @@ import (
|
||||
wlclient "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||
)
|
||||
|
||||
const envServe = "_DMS_CLIPBOARD_SERVE"
|
||||
const envMime = "_DMS_CLIPBOARD_MIME"
|
||||
const envPasteOnce = "_DMS_CLIPBOARD_PASTE_ONCE"
|
||||
const envCacheFile = "_DMS_CLIPBOARD_CACHE"
|
||||
|
||||
// MaybeServeAndExit intercepts before cobra when re-exec'd as a clipboard
|
||||
// child. Reads source data into memory, deletes any cache file, then serves.
|
||||
func MaybeServeAndExit() {
|
||||
if os.Getenv(envServe) == "" {
|
||||
return
|
||||
}
|
||||
|
||||
mimeType := os.Getenv(envMime)
|
||||
pasteOnce := os.Getenv(envPasteOnce) == "1"
|
||||
cachePath := os.Getenv(envCacheFile)
|
||||
|
||||
var data []byte
|
||||
var err error
|
||||
|
||||
switch {
|
||||
case cachePath != "":
|
||||
data, err = os.ReadFile(cachePath)
|
||||
os.Remove(cachePath)
|
||||
default:
|
||||
data, err = io.ReadAll(os.Stdin)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "clipboard: read source: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := serveClipboard(data, mimeType, pasteOnce); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "clipboard: serve: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func Copy(data []byte, mimeType string) error {
|
||||
return CopyReader(bytes.NewReader(data), mimeType, false, false)
|
||||
return copyForkCached(data, mimeType, false)
|
||||
}
|
||||
|
||||
func CopyOpts(data []byte, mimeType string, foreground, pasteOnce bool) error {
|
||||
if foreground {
|
||||
return copyServeWithWriter(func(writer io.Writer) error {
|
||||
total := 0
|
||||
for total < len(data) {
|
||||
n, err := writer.Write(data[total:])
|
||||
total += n
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if total != len(data) {
|
||||
return io.ErrShortWrite
|
||||
}
|
||||
return nil
|
||||
}, mimeType, pasteOnce)
|
||||
return serveClipboard(data, mimeType, pasteOnce)
|
||||
}
|
||||
return CopyReader(bytes.NewReader(data), mimeType, foreground, pasteOnce)
|
||||
return copyForkCached(data, mimeType, pasteOnce)
|
||||
}
|
||||
|
||||
func CopyReader(data io.Reader, mimeType string, foreground, pasteOnce bool) error {
|
||||
if !foreground {
|
||||
return copyFork(data, mimeType, pasteOnce)
|
||||
if foreground {
|
||||
buf, err := io.ReadAll(data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read source: %w", err)
|
||||
}
|
||||
return serveClipboard(buf, mimeType, pasteOnce)
|
||||
}
|
||||
return copyServeReader(data, mimeType, pasteOnce)
|
||||
return copyFork(data, mimeType, pasteOnce)
|
||||
}
|
||||
|
||||
func copyFork(data io.Reader, mimeType string, pasteOnce bool) error {
|
||||
args := []string{os.Args[0], "cl", "copy", "--foreground"}
|
||||
if pasteOnce {
|
||||
args = append(args, "--paste-once")
|
||||
}
|
||||
args = append(args, "--type", mimeType)
|
||||
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
func newForkCmd(mimeType string, pasteOnce bool, extra ...string) *exec.Cmd {
|
||||
cmd := exec.Command(os.Args[0])
|
||||
cmd.Stderr = nil
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
cmd.Env = append(os.Environ(), "DMS_CLIP_FORKED=1")
|
||||
cmd.Env = append(os.Environ(),
|
||||
envServe+"=1",
|
||||
envMime+"="+mimeType,
|
||||
)
|
||||
if pasteOnce {
|
||||
cmd.Env = append(cmd.Env, envPasteOnce+"=1")
|
||||
}
|
||||
cmd.Env = append(cmd.Env, extra...)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func waitReady(cmd *exec.Cmd) error {
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("stdout pipe: %w", err)
|
||||
}
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("start: %w", err)
|
||||
}
|
||||
var buf [1]byte
|
||||
if _, err := stdout.Read(buf[:]); err != nil {
|
||||
return fmt.Errorf("waiting for clipboard ready: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func copyForkCached(data []byte, mimeType string, pasteOnce bool) error {
|
||||
cacheFile, err := createClipboardCacheFile()
|
||||
if err != nil {
|
||||
return fmt.Errorf("create cache file: %w", err)
|
||||
}
|
||||
cachePath := cacheFile.Name()
|
||||
|
||||
if _, err := cacheFile.Write(data); err != nil {
|
||||
cacheFile.Close()
|
||||
os.Remove(cachePath)
|
||||
return fmt.Errorf("write cache file: %w", err)
|
||||
}
|
||||
if err := cacheFile.Close(); err != nil {
|
||||
os.Remove(cachePath)
|
||||
return fmt.Errorf("close cache file: %w", err)
|
||||
}
|
||||
|
||||
cmd := newForkCmd(mimeType, pasteOnce, envCacheFile+"="+cachePath)
|
||||
cmd.Stdin = nil
|
||||
if err := waitReady(cmd); err != nil {
|
||||
os.Remove(cachePath)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func copyFork(data io.Reader, mimeType string, pasteOnce bool) error {
|
||||
cmd := newForkCmd(mimeType, pasteOnce)
|
||||
|
||||
switch src := data.(type) {
|
||||
case *os.File:
|
||||
cmd.Stdin = src
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("start: %w", err)
|
||||
}
|
||||
return waitReady(cmd)
|
||||
|
||||
default:
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("stdin pipe: %w", err)
|
||||
}
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("stdout pipe: %w", err)
|
||||
}
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("start: %w", err)
|
||||
}
|
||||
@@ -83,50 +158,22 @@ func copyFork(data io.Reader, mimeType string, pasteOnce bool) error {
|
||||
if err := stdin.Close(); err != nil {
|
||||
return fmt.Errorf("close stdin: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
var buf [1]byte
|
||||
if _, err := stdout.Read(buf[:]); err != nil {
|
||||
return fmt.Errorf("waiting for clipboard ready: %w", err)
|
||||
var buf [1]byte
|
||||
if _, err := stdout.Read(buf[:]); err != nil {
|
||||
return fmt.Errorf("waiting for clipboard ready: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func signalReady() {
|
||||
if os.Getenv("DMS_CLIP_FORKED") == "" {
|
||||
if os.Getenv(envServe) == "" {
|
||||
return
|
||||
}
|
||||
os.Stdout.Write([]byte{1})
|
||||
}
|
||||
|
||||
func copyServeReader(data io.Reader, mimeType string, pasteOnce bool) error {
|
||||
cachedData, err := createClipboardCacheFile()
|
||||
if err != nil {
|
||||
return fmt.Errorf("create clipboard cache file: %w", err)
|
||||
}
|
||||
defer os.Remove(cachedData.Name())
|
||||
|
||||
if _, err := io.Copy(cachedData, data); err != nil {
|
||||
return fmt.Errorf("cache clipboard data: %w", err)
|
||||
}
|
||||
if err := cachedData.Close(); err != nil {
|
||||
return fmt.Errorf("close temp cache file: %w", err)
|
||||
}
|
||||
|
||||
return copyServeWithWriter(func(writer io.Writer) error {
|
||||
cachedFile, err := os.Open(cachedData.Name())
|
||||
if err != nil {
|
||||
return fmt.Errorf("open temp cache file: %w", err)
|
||||
}
|
||||
defer cachedFile.Close()
|
||||
|
||||
if _, err := io.Copy(writer, cachedFile); err != nil {
|
||||
return fmt.Errorf("write clipboard data: %w", err)
|
||||
}
|
||||
return nil
|
||||
}, mimeType, pasteOnce)
|
||||
}
|
||||
|
||||
func createClipboardCacheFile() (*os.File, error) {
|
||||
preferredDirs := []string{}
|
||||
|
||||
@@ -147,7 +194,7 @@ func createClipboardCacheFile() (*os.File, error) {
|
||||
return os.CreateTemp("", "dms-clipboard-*")
|
||||
}
|
||||
|
||||
func copyServeWithWriter(writeTo func(io.Writer) error, mimeType string, pasteOnce bool) error {
|
||||
func serveClipboard(data []byte, mimeType string, pasteOnce bool) error {
|
||||
display, err := wlclient.Connect("")
|
||||
if err != nil {
|
||||
return fmt.Errorf("wayland connect: %w", err)
|
||||
@@ -189,12 +236,10 @@ func copyServeWithWriter(writeTo func(io.Writer) error, mimeType string, pasteOn
|
||||
if bindErr != nil {
|
||||
return fmt.Errorf("registry bind: %w", bindErr)
|
||||
}
|
||||
|
||||
if dataControlMgr == nil {
|
||||
return fmt.Errorf("compositor does not support ext_data_control_manager_v1")
|
||||
}
|
||||
defer dataControlMgr.Destroy()
|
||||
|
||||
if seat == nil {
|
||||
return fmt.Errorf("no seat available")
|
||||
}
|
||||
@@ -233,18 +278,12 @@ func copyServeWithWriter(writeTo func(io.Writer) error, mimeType string, pasteOn
|
||||
|
||||
cancelled := make(chan struct{})
|
||||
pasted := make(chan struct{}, 1)
|
||||
sendErr := make(chan error, 1)
|
||||
|
||||
source.SetSendHandler(func(e ext_data_control.ExtDataControlSourceV1SendEvent) {
|
||||
defer syscall.Close(e.Fd)
|
||||
_ = syscall.SetNonblock(e.Fd, false)
|
||||
file := os.NewFile(uintptr(e.Fd), "pipe")
|
||||
defer file.Close()
|
||||
if err := writeTo(file); err != nil {
|
||||
select {
|
||||
case sendErr <- err:
|
||||
default:
|
||||
}
|
||||
}
|
||||
_, _ = file.Write(data)
|
||||
select {
|
||||
case pasted <- struct{}{}:
|
||||
default:
|
||||
@@ -266,8 +305,6 @@ func copyServeWithWriter(writeTo func(io.Writer) error, mimeType string, pasteOn
|
||||
select {
|
||||
case <-cancelled:
|
||||
return nil
|
||||
case err := <-sendErr:
|
||||
return err
|
||||
case <-pasted:
|
||||
if pasteOnce {
|
||||
return nil
|
||||
@@ -521,12 +558,10 @@ func copyMultiServe(offers []Offer, pasteOnce bool) error {
|
||||
if bindErr != nil {
|
||||
return fmt.Errorf("registry bind: %w", bindErr)
|
||||
}
|
||||
|
||||
if dataControlMgr == nil {
|
||||
return fmt.Errorf("compositor does not support ext_data_control_manager_v1")
|
||||
}
|
||||
defer dataControlMgr.Destroy()
|
||||
|
||||
if seat == nil {
|
||||
return fmt.Errorf("no seat available")
|
||||
}
|
||||
@@ -554,12 +589,12 @@ func copyMultiServe(offers []Offer, pasteOnce bool) error {
|
||||
pasted := make(chan struct{}, 1)
|
||||
|
||||
source.SetSendHandler(func(e ext_data_control.ExtDataControlSourceV1SendEvent) {
|
||||
defer syscall.Close(e.Fd)
|
||||
_ = syscall.SetNonblock(e.Fd, false)
|
||||
file := os.NewFile(uintptr(e.Fd), "pipe")
|
||||
defer file.Close()
|
||||
|
||||
if data, ok := offerMap[e.MimeType]; ok {
|
||||
file.Write(data)
|
||||
_, _ = file.Write(data)
|
||||
}
|
||||
|
||||
select {
|
||||
|
||||
@@ -39,11 +39,10 @@ type LayerSurface struct {
|
||||
wlSurface *client.Surface
|
||||
layerSurf *wlr_layer_shell.ZwlrLayerSurfaceV1
|
||||
viewport *wp_viewporter.WpViewport
|
||||
wlPool *client.ShmPool
|
||||
wlBuffer *client.Buffer
|
||||
bufferBusy bool
|
||||
oldPool *client.ShmPool
|
||||
oldBuffer *client.Buffer
|
||||
wlPools [2]*client.ShmPool
|
||||
wlBuffers [2]*client.Buffer
|
||||
slotBusy [2]bool
|
||||
needsRedraw bool
|
||||
scopyBuffer *client.Buffer
|
||||
configured bool
|
||||
hidden bool
|
||||
@@ -136,6 +135,7 @@ func (p *Picker) Run() (*Color, error) {
|
||||
break
|
||||
}
|
||||
|
||||
p.flushRedraws()
|
||||
p.checkDone()
|
||||
}
|
||||
|
||||
@@ -164,6 +164,15 @@ func (p *Picker) checkDone() {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Picker) flushRedraws() {
|
||||
for _, ls := range p.surfaces {
|
||||
if !ls.needsRedraw {
|
||||
continue
|
||||
}
|
||||
p.redrawSurface(ls)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Picker) connect() error {
|
||||
display, err := client.Connect("")
|
||||
if err != nil {
|
||||
@@ -507,47 +516,45 @@ func (p *Picker) captureForSurface(ls *LayerSurface) {
|
||||
}
|
||||
|
||||
func (p *Picker) redrawSurface(ls *LayerSurface) {
|
||||
slot := ls.state.FrontIndex()
|
||||
if ls.slotBusy[slot] {
|
||||
ls.needsRedraw = true
|
||||
return
|
||||
}
|
||||
|
||||
var renderBuf *ShmBuffer
|
||||
if ls.hidden {
|
||||
switch {
|
||||
case ls.hidden:
|
||||
renderBuf = ls.state.RedrawScreenOnly()
|
||||
} else {
|
||||
default:
|
||||
renderBuf = ls.state.Redraw()
|
||||
}
|
||||
if renderBuf == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if ls.oldBuffer != nil {
|
||||
ls.oldBuffer.Destroy()
|
||||
ls.oldBuffer = nil
|
||||
}
|
||||
if ls.oldPool != nil {
|
||||
ls.oldPool.Destroy()
|
||||
ls.oldPool = nil
|
||||
ls.needsRedraw = false
|
||||
|
||||
if ls.wlPools[slot] == nil {
|
||||
pool, err := p.shm.CreatePool(renderBuf.Fd(), int32(renderBuf.Size()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ls.wlPools[slot] = pool
|
||||
|
||||
wlBuffer, err := pool.CreateBuffer(0, int32(renderBuf.Width), int32(renderBuf.Height), int32(renderBuf.Stride), uint32(ls.state.ScreenFormat()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ls.wlBuffers[slot] = wlBuffer
|
||||
|
||||
s := slot
|
||||
wlBuffer.SetReleaseHandler(func(e client.BufferReleaseEvent) {
|
||||
ls.slotBusy[s] = false
|
||||
})
|
||||
}
|
||||
|
||||
ls.oldPool = ls.wlPool
|
||||
ls.oldBuffer = ls.wlBuffer
|
||||
ls.wlPool = nil
|
||||
ls.wlBuffer = nil
|
||||
|
||||
pool, err := p.shm.CreatePool(renderBuf.Fd(), int32(renderBuf.Size()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ls.wlPool = pool
|
||||
|
||||
wlBuffer, err := pool.CreateBuffer(0, int32(renderBuf.Width), int32(renderBuf.Height), int32(renderBuf.Stride), uint32(ls.state.ScreenFormat()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ls.wlBuffer = wlBuffer
|
||||
|
||||
lsRef := ls
|
||||
wlBuffer.SetReleaseHandler(func(e client.BufferReleaseEvent) {
|
||||
lsRef.bufferBusy = false
|
||||
})
|
||||
ls.bufferBusy = true
|
||||
ls.slotBusy[slot] = true
|
||||
|
||||
logicalW, logicalH := ls.state.LogicalSize()
|
||||
if logicalW == 0 || logicalH == 0 {
|
||||
@@ -566,7 +573,7 @@ func (p *Picker) redrawSurface(ls *LayerSurface) {
|
||||
}
|
||||
_ = ls.wlSurface.SetBufferScale(bufferScale)
|
||||
}
|
||||
_ = ls.wlSurface.Attach(wlBuffer, 0, 0)
|
||||
_ = ls.wlSurface.Attach(ls.wlBuffers[slot], 0, 0)
|
||||
_ = ls.wlSurface.Damage(0, 0, int32(logicalW), int32(logicalH))
|
||||
_ = ls.wlSurface.Commit()
|
||||
|
||||
@@ -634,7 +641,7 @@ func (p *Picker) setupPointerHandlers() {
|
||||
}
|
||||
|
||||
p.activeSurface.state.OnPointerMotion(e.SurfaceX, e.SurfaceY)
|
||||
p.redrawSurface(p.activeSurface)
|
||||
p.activeSurface.needsRedraw = true
|
||||
})
|
||||
|
||||
p.pointer.SetLeaveHandler(func(e client.PointerLeaveEvent) {
|
||||
@@ -655,7 +662,7 @@ func (p *Picker) setupPointerHandlers() {
|
||||
return
|
||||
}
|
||||
p.activeSurface.state.OnPointerMotion(e.SurfaceX, e.SurfaceY)
|
||||
p.redrawSurface(p.activeSurface)
|
||||
p.activeSurface.needsRedraw = true
|
||||
})
|
||||
|
||||
p.pointer.SetButtonHandler(func(e client.PointerButtonEvent) {
|
||||
@@ -679,17 +686,13 @@ func (p *Picker) cleanup() {
|
||||
if ls.scopyBuffer != nil {
|
||||
ls.scopyBuffer.Destroy()
|
||||
}
|
||||
if ls.oldBuffer != nil {
|
||||
ls.oldBuffer.Destroy()
|
||||
}
|
||||
if ls.oldPool != nil {
|
||||
ls.oldPool.Destroy()
|
||||
}
|
||||
if ls.wlBuffer != nil {
|
||||
ls.wlBuffer.Destroy()
|
||||
}
|
||||
if ls.wlPool != nil {
|
||||
ls.wlPool.Destroy()
|
||||
for i := range ls.wlBuffers {
|
||||
if ls.wlBuffers[i] != nil {
|
||||
ls.wlBuffers[i].Destroy()
|
||||
}
|
||||
if ls.wlPools[i] != nil {
|
||||
ls.wlPools[i].Destroy()
|
||||
}
|
||||
}
|
||||
if ls.viewport != nil {
|
||||
ls.viewport.Destroy()
|
||||
|
||||
@@ -274,6 +274,12 @@ func (s *SurfaceState) FrontRenderBuffer() *ShmBuffer {
|
||||
return s.renderBufs[s.front]
|
||||
}
|
||||
|
||||
func (s *SurfaceState) FrontIndex() int {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.front
|
||||
}
|
||||
|
||||
func (s *SurfaceState) SwapBuffers() {
|
||||
s.mu.Lock()
|
||||
s.front ^= 1
|
||||
|
||||
@@ -62,12 +62,31 @@ func (cd *ConfigDeployer) DeployConfigurationsSelectiveWithReinstalls(ctx contex
|
||||
func (cd *ConfigDeployer) deployConfigurationsInternal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal, installedDeps []deps.Dependency, replaceConfigs map[string]bool, reinstallItems map[string]bool, useSystemd bool) ([]DeploymentResult, error) {
|
||||
var results []DeploymentResult
|
||||
|
||||
// Primary config file paths used to detect fresh installs.
|
||||
configPrimaryPaths := map[string]string{
|
||||
"Niri": filepath.Join(os.Getenv("HOME"), ".config", "niri", "config.kdl"),
|
||||
"Hyprland": filepath.Join(os.Getenv("HOME"), ".config", "hypr", "hyprland.conf"),
|
||||
"Ghostty": filepath.Join(os.Getenv("HOME"), ".config", "ghostty", "config"),
|
||||
"Kitty": filepath.Join(os.Getenv("HOME"), ".config", "kitty", "kitty.conf"),
|
||||
"Alacritty": filepath.Join(os.Getenv("HOME"), ".config", "alacritty", "alacritty.toml"),
|
||||
}
|
||||
|
||||
shouldReplaceConfig := func(configType string) bool {
|
||||
if replaceConfigs == nil {
|
||||
return true
|
||||
}
|
||||
replace, exists := replaceConfigs[configType]
|
||||
return !exists || replace
|
||||
if !exists || replace {
|
||||
return true
|
||||
}
|
||||
// Config is explicitly set to "don't replace" — but still deploy
|
||||
// if the config file doesn't exist yet (fresh install scenario).
|
||||
if primaryPath, ok := configPrimaryPaths[configType]; ok {
|
||||
if _, err := os.Stat(primaryPath); os.IsNotExist(err) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
switch wm {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -624,3 +625,168 @@ func TestAlacrittyConfigDeployment(t *testing.T) {
|
||||
assert.Contains(t, string(newContent), "decorations = \"None\"")
|
||||
})
|
||||
}
|
||||
|
||||
func TestShouldReplaceConfigDeployIfMissing(t *testing.T) {
|
||||
allFalse := map[string]bool{
|
||||
"Niri": false,
|
||||
"Hyprland": false,
|
||||
"Ghostty": false,
|
||||
"Kitty": false,
|
||||
"Alacritty": false,
|
||||
}
|
||||
|
||||
t.Run("replaceConfigs nil deploys config", func(t *testing.T) {
|
||||
tempDir, err := os.MkdirTemp("", "dankinstall-replace-nil-test")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
originalHome := os.Getenv("HOME")
|
||||
os.Setenv("HOME", tempDir)
|
||||
defer os.Setenv("HOME", originalHome)
|
||||
|
||||
logChan := make(chan string, 100)
|
||||
cd := NewConfigDeployer(logChan)
|
||||
|
||||
results, err := cd.DeployConfigurationsSelectiveWithReinstalls(
|
||||
context.Background(),
|
||||
deps.WindowManagerNiri,
|
||||
deps.TerminalGhostty,
|
||||
nil, // installedDeps
|
||||
nil, // replaceConfigs
|
||||
nil, // reinstallItems
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// With replaceConfigs=nil, all configs should be deployed
|
||||
hasDeployed := false
|
||||
for _, r := range results {
|
||||
if r.Deployed {
|
||||
hasDeployed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, hasDeployed, "expected at least one config to be deployed when replaceConfigs is nil")
|
||||
})
|
||||
|
||||
t.Run("replaceConfigs all false and config missing deploys config", func(t *testing.T) {
|
||||
tempDir, err := os.MkdirTemp("", "dankinstall-replace-missing-test")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
originalHome := os.Getenv("HOME")
|
||||
os.Setenv("HOME", tempDir)
|
||||
defer os.Setenv("HOME", originalHome)
|
||||
|
||||
logChan := make(chan string, 100)
|
||||
cd := NewConfigDeployer(logChan)
|
||||
|
||||
results, err := cd.DeployConfigurationsSelectiveWithReinstalls(
|
||||
context.Background(),
|
||||
deps.WindowManagerNiri,
|
||||
deps.TerminalGhostty,
|
||||
nil, // installedDeps
|
||||
allFalse, // replaceConfigs — all false
|
||||
nil, // reinstallItems
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Config files don't exist on disk, so they should still be deployed
|
||||
hasDeployed := false
|
||||
for _, r := range results {
|
||||
if r.Deployed {
|
||||
hasDeployed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, hasDeployed, "expected configs to be deployed when files are missing, even with replaceConfigs all false")
|
||||
})
|
||||
|
||||
t.Run("replaceConfigs false and config exists skips config", func(t *testing.T) {
|
||||
tempDir, err := os.MkdirTemp("", "dankinstall-replace-exists-test")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
originalHome := os.Getenv("HOME")
|
||||
os.Setenv("HOME", tempDir)
|
||||
defer os.Setenv("HOME", originalHome)
|
||||
|
||||
// Create the Ghostty primary config file so shouldReplaceConfig returns false
|
||||
ghosttyPath := filepath.Join(tempDir, ".config", "ghostty", "config")
|
||||
err = os.MkdirAll(filepath.Dir(ghosttyPath), 0o755)
|
||||
require.NoError(t, err)
|
||||
err = os.WriteFile(ghosttyPath, []byte("# existing ghostty config\n"), 0o644)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Also create the Niri primary config file
|
||||
niriPath := filepath.Join(tempDir, ".config", "niri", "config.kdl")
|
||||
err = os.MkdirAll(filepath.Dir(niriPath), 0o755)
|
||||
require.NoError(t, err)
|
||||
err = os.WriteFile(niriPath, []byte("// existing niri config\n"), 0o644)
|
||||
require.NoError(t, err)
|
||||
|
||||
logChan := make(chan string, 100)
|
||||
cd := NewConfigDeployer(logChan)
|
||||
|
||||
results, err := cd.DeployConfigurationsSelectiveWithReinstalls(
|
||||
context.Background(),
|
||||
deps.WindowManagerNiri,
|
||||
deps.TerminalGhostty,
|
||||
nil, // installedDeps
|
||||
allFalse, // replaceConfigs — all false
|
||||
nil, // reinstallItems
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Both Niri and Ghostty config files exist, so with all false they should be skipped
|
||||
for _, r := range results {
|
||||
assert.Fail(t, "expected no configs to be deployed", "got deployed config: %s", r.ConfigType)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("replaceConfigs true and config exists deploys config", func(t *testing.T) {
|
||||
tempDir, err := os.MkdirTemp("", "dankinstall-replace-true-test")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
originalHome := os.Getenv("HOME")
|
||||
os.Setenv("HOME", tempDir)
|
||||
defer os.Setenv("HOME", originalHome)
|
||||
|
||||
// Create the Ghostty primary config file
|
||||
ghosttyPath := filepath.Join(tempDir, ".config", "ghostty", "config")
|
||||
err = os.MkdirAll(filepath.Dir(ghosttyPath), 0o755)
|
||||
require.NoError(t, err)
|
||||
err = os.WriteFile(ghosttyPath, []byte("# existing ghostty config\n"), 0o644)
|
||||
require.NoError(t, err)
|
||||
|
||||
logChan := make(chan string, 100)
|
||||
cd := NewConfigDeployer(logChan)
|
||||
|
||||
replaceConfigs := map[string]bool{
|
||||
"Niri": false,
|
||||
"Hyprland": false,
|
||||
"Ghostty": true, // explicitly true
|
||||
"Kitty": false,
|
||||
"Alacritty": false,
|
||||
}
|
||||
|
||||
results, err := cd.DeployConfigurationsSelectiveWithReinstalls(
|
||||
context.Background(),
|
||||
deps.WindowManagerNiri,
|
||||
deps.TerminalGhostty,
|
||||
nil, // installedDeps
|
||||
replaceConfigs, // Ghostty=true, rest=false
|
||||
nil, // reinstallItems
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Ghostty should be deployed because replaceConfigs["Ghostty"]=true
|
||||
foundGhostty := false
|
||||
for _, r := range results {
|
||||
if r.ConfigType == "Ghostty" && r.Deployed {
|
||||
foundGhostty = true
|
||||
}
|
||||
}
|
||||
assert.True(t, foundGhostty, "expected Ghostty config to be deployed when replaceConfigs is true")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ bind = SUPER, bracketright, layoutmsg, preselect r
|
||||
|
||||
# === Sizing & Layout ===
|
||||
bind = SUPER, R, layoutmsg, togglesplit
|
||||
bind = SUPER CTRL, F, resizeactive, exact 100%
|
||||
bind = SUPER CTRL, F, resizeactive, exact 100% 100%
|
||||
|
||||
# === Move/resize windows with mainMod + LMB/RMB and dragging ===
|
||||
bindmd = SUPER, mouse:272, Move window, movewindow
|
||||
|
||||
@@ -94,6 +94,7 @@ windowrule = tile on, match:class ^(gnome-control-center)$
|
||||
windowrule = tile on, match:class ^(pavucontrol)$
|
||||
windowrule = tile on, match:class ^(nm-connection-editor)$
|
||||
|
||||
windowrule = float on, match:class ^(org\.gnome\.Calculator)$
|
||||
windowrule = float on, match:class ^(gnome-calculator)$
|
||||
windowrule = float on, match:class ^(galculator)$
|
||||
windowrule = float on, match:class ^(blueman-manager)$
|
||||
|
||||
@@ -224,6 +224,7 @@ window-rule {
|
||||
open-floating false
|
||||
}
|
||||
window-rule {
|
||||
match app-id=r#"^org\.gnome\.Calculator$"#
|
||||
match app-id=r#"^gnome-calculator$"#
|
||||
match app-id=r#"^galculator$"#
|
||||
match app-id=r#"^blueman-manager$"#
|
||||
|
||||
@@ -242,11 +242,7 @@ func (a *ArchDistribution) getDMSMapping(variant deps.PackageVariant) PackageMap
|
||||
return PackageMapping{Name: "dms-shell-git", Repository: RepoTypeAUR}
|
||||
}
|
||||
|
||||
if a.packageInstalled("dms-shell-bin") {
|
||||
return PackageMapping{Name: "dms-shell-bin", Repository: RepoTypeAUR}
|
||||
}
|
||||
|
||||
return PackageMapping{Name: "dms-shell-bin", Repository: RepoTypeAUR}
|
||||
return PackageMapping{Name: "dms-shell", Repository: RepoTypeSystem}
|
||||
}
|
||||
|
||||
func (a *ArchDistribution) detectXwaylandSatellite() deps.Dependency {
|
||||
@@ -328,6 +324,13 @@ func (a *ArchDistribution) InstallPackages(ctx context.Context, dependencies []d
|
||||
|
||||
systemPkgs, aurPkgs, manualPkgs, variantMap := a.categorizePackages(dependencies, wm, reinstallFlags, disabledFlags)
|
||||
|
||||
if slices.Contains(aurPkgs, "quickshell-git") && slices.Contains(systemPkgs, "dms-shell") {
|
||||
if err := a.preinstallQuickshellGit(ctx, sudoPassword, progressChan); err != nil {
|
||||
return fmt.Errorf("failed to preinstall quickshell-git: %w", err)
|
||||
}
|
||||
aurPkgs = slices.DeleteFunc(aurPkgs, func(p string) bool { return p == "quickshell-git" })
|
||||
}
|
||||
|
||||
// Phase 3: System Packages
|
||||
if len(systemPkgs) > 0 {
|
||||
progressChan <- InstallProgressMsg{
|
||||
@@ -445,6 +448,37 @@ func (a *ArchDistribution) categorizePackages(dependencies []deps.Dependency, wm
|
||||
return systemPkgs, aurPkgs, manualPkgs, variantMap
|
||||
}
|
||||
|
||||
func (a *ArchDistribution) preinstallQuickshellGit(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||
if a.packageInstalled("quickshell-git") {
|
||||
return nil
|
||||
}
|
||||
|
||||
if a.packageInstalled("quickshell") {
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseAURPackages,
|
||||
Progress: 0.15,
|
||||
Step: "Removing stable quickshell...",
|
||||
IsComplete: false,
|
||||
NeedsSudo: true,
|
||||
CommandInfo: "sudo pacman -Rdd --noconfirm quickshell",
|
||||
LogOutput: "Removing stable quickshell so quickshell-git can be installed",
|
||||
}
|
||||
cmd := ExecSudoCommand(ctx, sudoPassword, "pacman -Rdd --noconfirm quickshell")
|
||||
if err := a.runWithProgress(cmd, progressChan, PhaseAURPackages, 0.15, 0.18); err != nil {
|
||||
return fmt.Errorf("failed to remove stable quickshell: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseAURPackages,
|
||||
Progress: 0.18,
|
||||
Step: "Building quickshell-git before system packages...",
|
||||
IsComplete: false,
|
||||
CommandInfo: "Installing quickshell-git ahead of dms-shell to avoid conflict",
|
||||
}
|
||||
return a.installSingleAURPackage(ctx, "quickshell-git", sudoPassword, progressChan, 0.18, 0.32)
|
||||
}
|
||||
|
||||
func (a *ArchDistribution) installSystemPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||
if len(packages) == 0 {
|
||||
return nil
|
||||
@@ -453,6 +487,9 @@ func (a *ArchDistribution) installSystemPackages(ctx context.Context, packages [
|
||||
a.log(fmt.Sprintf("Installing system packages: %s", strings.Join(packages, ", ")))
|
||||
|
||||
args := []string{"pacman", "-S", "--needed", "--noconfirm"}
|
||||
if slices.Contains(packages, "dms-shell") {
|
||||
args = append(args, "--assume-installed", "dms-shell-compositor=1")
|
||||
}
|
||||
args = append(args, packages...)
|
||||
|
||||
progressChan <- InstallProgressMsg{
|
||||
@@ -540,7 +577,7 @@ func (a *ArchDistribution) reorderAURPackages(packages []string) []string {
|
||||
var dmsShell []string
|
||||
|
||||
for _, pkg := range packages {
|
||||
if pkg == "dms-shell-git" || pkg == "dms-shell-bin" {
|
||||
if pkg == "dms-shell-git" {
|
||||
dmsShell = append(dmsShell, pkg)
|
||||
} else {
|
||||
isDep := false
|
||||
@@ -621,7 +658,7 @@ func (a *ArchDistribution) installSingleAURPackageInternal(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
if pkg == "dms-shell-git" || pkg == "dms-shell-bin" {
|
||||
if pkg == "dms-shell-git" {
|
||||
srcinfoPath := filepath.Join(packageDir, ".SRCINFO")
|
||||
depsToRemove := []string{
|
||||
"depends = quickshell",
|
||||
@@ -644,15 +681,7 @@ func (a *ArchDistribution) installSingleAURPackageInternal(ctx context.Context,
|
||||
}
|
||||
|
||||
srcinfoPath = filepath.Join(packageDir, ".SRCINFO")
|
||||
if pkg == "dms-shell-bin" {
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseAURPackages,
|
||||
Progress: startProgress + 0.35*(endProgress-startProgress),
|
||||
Step: fmt.Sprintf("Skipping dependency installation for %s (manually managed)...", pkg),
|
||||
IsComplete: false,
|
||||
LogOutput: fmt.Sprintf("Dependencies for %s are installed separately", pkg),
|
||||
}
|
||||
} else {
|
||||
{
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseAURPackages,
|
||||
Progress: startProgress + 0.3*(endProgress-startProgress),
|
||||
@@ -739,42 +768,9 @@ func (a *ArchDistribution) installSingleAURPackageInternal(ctx context.Context,
|
||||
CommandInfo: "sudo pacman -U built-package",
|
||||
}
|
||||
|
||||
// Find .pkg.tar* files - for split packages, install the base and any installed compositor variants
|
||||
var files []string
|
||||
if pkg == "dms-shell-git" || pkg == "dms-shell-bin" {
|
||||
// For DMS split packages, install base package
|
||||
pattern := filepath.Join(packageDir, fmt.Sprintf("%s-%s*.pkg.tar*", pkg, "*"))
|
||||
matches, err := filepath.Glob(pattern)
|
||||
if err == nil {
|
||||
for _, match := range matches {
|
||||
basename := filepath.Base(match)
|
||||
// Always include base package
|
||||
if !strings.Contains(basename, "hyprland") && !strings.Contains(basename, "niri") {
|
||||
files = append(files, match)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Also update compositor-specific packages if they're installed
|
||||
if strings.HasSuffix(pkg, "-git") {
|
||||
if a.packageInstalled("dms-shell-hyprland-git") {
|
||||
hyprlandPattern := filepath.Join(packageDir, "dms-shell-hyprland-git-*.pkg.tar*")
|
||||
if hyprlandMatches, err := filepath.Glob(hyprlandPattern); err == nil && len(hyprlandMatches) > 0 {
|
||||
files = append(files, hyprlandMatches[0])
|
||||
}
|
||||
}
|
||||
if a.packageInstalled("dms-shell-niri-git") {
|
||||
niriPattern := filepath.Join(packageDir, "dms-shell-niri-git-*.pkg.tar*")
|
||||
if niriMatches, err := filepath.Glob(niriPattern); err == nil && len(niriMatches) > 0 {
|
||||
files = append(files, niriMatches[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// For other packages, install all built packages
|
||||
matches, _ := filepath.Glob(filepath.Join(packageDir, "*.pkg.tar*"))
|
||||
files = matches
|
||||
}
|
||||
matches, _ := filepath.Glob(filepath.Join(packageDir, "*.pkg.tar*"))
|
||||
files = matches
|
||||
|
||||
if len(files) == 0 {
|
||||
return fmt.Errorf("no package files found after building %s", pkg)
|
||||
|
||||
418
core/internal/headless/runner.go
Normal file
418
core/internal/headless/runner.go
Normal file
@@ -0,0 +1,418 @@
|
||||
package headless
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/config"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/deps"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/distros"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/greeter"
|
||||
)
|
||||
|
||||
// ErrConfirmationRequired is returned when --yes is not set and the user
|
||||
// must explicitly confirm the operation.
|
||||
var ErrConfirmationRequired = fmt.Errorf("confirmation required: pass --yes to proceed")
|
||||
|
||||
// validConfigNames maps lowercase CLI input to the deployer key used in
|
||||
// replaceConfigs. Keep in sync with the config types checked by
|
||||
// shouldReplaceConfig in deployer.go.
|
||||
var validConfigNames = map[string]string{
|
||||
"niri": "Niri",
|
||||
"hyprland": "Hyprland",
|
||||
"ghostty": "Ghostty",
|
||||
"kitty": "Kitty",
|
||||
"alacritty": "Alacritty",
|
||||
}
|
||||
|
||||
// orderedConfigNames defines the canonical order for config names in output.
|
||||
// Must be kept in sync with validConfigNames.
|
||||
var orderedConfigNames = []string{"niri", "hyprland", "ghostty", "kitty", "alacritty"}
|
||||
|
||||
// Config holds all CLI parameters for unattended installation.
|
||||
type Config struct {
|
||||
Compositor string // "niri" or "hyprland"
|
||||
Terminal string // "ghostty", "kitty", or "alacritty"
|
||||
IncludeDeps []string
|
||||
ExcludeDeps []string
|
||||
ReplaceConfigs []string // specific configs to deploy (e.g. "niri", "ghostty")
|
||||
ReplaceConfigsAll bool // deploy/replace all configurations
|
||||
Yes bool
|
||||
}
|
||||
|
||||
// Runner orchestrates unattended (headless) installation.
|
||||
type Runner struct {
|
||||
cfg Config
|
||||
logChan chan string
|
||||
}
|
||||
|
||||
// NewRunner creates a new headless runner.
|
||||
func NewRunner(cfg Config) *Runner {
|
||||
return &Runner{
|
||||
cfg: cfg,
|
||||
logChan: make(chan string, 1000),
|
||||
}
|
||||
}
|
||||
|
||||
// GetLogChan returns the log channel for file logging.
|
||||
func (r *Runner) GetLogChan() <-chan string {
|
||||
return r.logChan
|
||||
}
|
||||
|
||||
// Run executes the full unattended installation flow.
|
||||
func (r *Runner) Run() error {
|
||||
r.log("Starting headless installation")
|
||||
|
||||
// 1. Parse compositor and terminal selections
|
||||
wm, err := r.parseWindowManager()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
terminal, err := r.parseTerminal()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 2. Build replace-configs map
|
||||
replaceConfigs, err := r.buildReplaceConfigs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 3. Detect OS
|
||||
r.log("Detecting operating system...")
|
||||
osInfo, err := distros.GetOSInfo()
|
||||
if err != nil {
|
||||
return fmt.Errorf("OS detection failed: %w", err)
|
||||
}
|
||||
|
||||
if distros.IsUnsupportedDistro(osInfo.Distribution.ID, osInfo.VersionID) {
|
||||
return fmt.Errorf("unsupported distribution: %s %s", osInfo.PrettyName, osInfo.VersionID)
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stdout, "Detected: %s (%s)\n", osInfo.PrettyName, osInfo.Architecture)
|
||||
|
||||
// 4. Create distribution instance
|
||||
distro, err := distros.NewDistribution(osInfo.Distribution.ID, r.logChan)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize distribution: %w", err)
|
||||
}
|
||||
|
||||
// 5. Detect dependencies
|
||||
r.log("Detecting dependencies...")
|
||||
fmt.Fprintln(os.Stdout, "Detecting dependencies...")
|
||||
dependencies, err := distro.DetectDependenciesWithTerminal(context.Background(), wm, terminal)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dependency detection failed: %w", err)
|
||||
}
|
||||
|
||||
// 5. Apply include/exclude filters and build the disabled-items map.
|
||||
// Headless mode does not currently collect any explicit reinstall selections,
|
||||
// so keep reinstallItems nil instead of constructing an always-empty map.
|
||||
disabledItems, err := r.buildDisabledItems(dependencies)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var reinstallItems map[string]bool
|
||||
|
||||
// Print dependency summary
|
||||
fmt.Fprintln(os.Stdout, "\nDependencies:")
|
||||
for _, dep := range dependencies {
|
||||
marker := " "
|
||||
status := ""
|
||||
if disabledItems[dep.Name] {
|
||||
marker = " SKIP "
|
||||
status = "(disabled)"
|
||||
} else {
|
||||
switch dep.Status {
|
||||
case deps.StatusInstalled:
|
||||
marker = " OK "
|
||||
status = "(installed)"
|
||||
case deps.StatusMissing:
|
||||
marker = " NEW "
|
||||
status = "(will install)"
|
||||
case deps.StatusNeedsUpdate:
|
||||
marker = " UPD "
|
||||
status = "(will update)"
|
||||
case deps.StatusNeedsReinstall:
|
||||
marker = " RE "
|
||||
status = "(will reinstall)"
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "%s%-30s %s\n", marker, dep.Name, status)
|
||||
}
|
||||
fmt.Fprintln(os.Stdout)
|
||||
|
||||
// 6b. Require explicit confirmation unless --yes is set
|
||||
if !r.cfg.Yes {
|
||||
if replaceConfigs == nil {
|
||||
// --replace-configs-all
|
||||
fmt.Fprintln(os.Stdout, "Packages will be installed and all configurations will be replaced.")
|
||||
fmt.Fprintln(os.Stdout, "Existing config files will be backed up before replacement.")
|
||||
} else if r.anyConfigEnabled(replaceConfigs) {
|
||||
var names []string
|
||||
for _, cliName := range orderedConfigNames {
|
||||
deployerKey := validConfigNames[cliName]
|
||||
if replaceConfigs[deployerKey] {
|
||||
names = append(names, deployerKey)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "Packages will be installed. The following configurations will be replaced (with backups): %s\n", strings.Join(names, ", "))
|
||||
} else {
|
||||
fmt.Fprintln(os.Stdout, "Packages will be installed. No configurations will be deployed.")
|
||||
}
|
||||
fmt.Fprintln(os.Stdout, "Re-run with --yes (-y) to proceed.")
|
||||
r.log("Aborted: --yes not set")
|
||||
return ErrConfirmationRequired
|
||||
}
|
||||
|
||||
// 7. Authenticate sudo
|
||||
sudoPassword, err := r.resolveSudoPassword()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 8. Install packages
|
||||
fmt.Fprintln(os.Stdout, "Installing packages...")
|
||||
r.log("Starting package installation")
|
||||
|
||||
progressChan := make(chan distros.InstallProgressMsg, 100)
|
||||
|
||||
installErr := make(chan error, 1)
|
||||
go func() {
|
||||
defer close(progressChan)
|
||||
installErr <- distro.InstallPackages(
|
||||
context.Background(),
|
||||
dependencies,
|
||||
wm,
|
||||
sudoPassword,
|
||||
reinstallItems,
|
||||
disabledItems,
|
||||
false, // skipGlobalUseFlags
|
||||
progressChan,
|
||||
)
|
||||
}()
|
||||
|
||||
// Consume progress messages and print them
|
||||
for msg := range progressChan {
|
||||
if msg.Error != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", msg.Error)
|
||||
} else if msg.Step != "" {
|
||||
fmt.Fprintf(os.Stdout, " [%3.0f%%] %s\n", msg.Progress*100, msg.Step)
|
||||
}
|
||||
if msg.LogOutput != "" {
|
||||
r.log(msg.LogOutput)
|
||||
fmt.Fprintf(os.Stdout, " %s\n", msg.LogOutput)
|
||||
}
|
||||
}
|
||||
|
||||
if err := <-installErr; err != nil {
|
||||
return fmt.Errorf("package installation failed: %w", err)
|
||||
}
|
||||
|
||||
// 9. Greeter setup (if dms-greeter was included)
|
||||
if !disabledItems["dms-greeter"] && r.depExists(dependencies, "dms-greeter") {
|
||||
compositorName := "niri"
|
||||
if wm == deps.WindowManagerHyprland {
|
||||
compositorName = "Hyprland"
|
||||
}
|
||||
fmt.Fprintln(os.Stdout, "Configuring DMS greeter...")
|
||||
logFunc := func(line string) {
|
||||
r.log(line)
|
||||
fmt.Fprintf(os.Stdout, " greeter: %s\n", line)
|
||||
}
|
||||
if err := greeter.AutoSetupGreeter(compositorName, sudoPassword, logFunc); err != nil {
|
||||
// Non-fatal, matching TUI behavior
|
||||
fmt.Fprintf(os.Stderr, "Warning: greeter setup issue (non-fatal): %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 10. Deploy configurations
|
||||
fmt.Fprintln(os.Stdout, "Deploying configurations...")
|
||||
r.log("Starting configuration deployment")
|
||||
|
||||
deployer := config.NewConfigDeployer(r.logChan)
|
||||
results, err := deployer.DeployConfigurationsSelectiveWithReinstalls(
|
||||
context.Background(),
|
||||
wm,
|
||||
terminal,
|
||||
dependencies,
|
||||
replaceConfigs,
|
||||
reinstallItems,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("configuration deployment failed: %w", err)
|
||||
}
|
||||
|
||||
for _, result := range results {
|
||||
if result.Deployed {
|
||||
msg := fmt.Sprintf(" Deployed: %s", result.ConfigType)
|
||||
if result.BackupPath != "" {
|
||||
msg += fmt.Sprintf(" (backup: %s)", result.BackupPath)
|
||||
}
|
||||
fmt.Fprintln(os.Stdout, msg)
|
||||
}
|
||||
if result.Error != nil {
|
||||
fmt.Fprintf(os.Stderr, " Error deploying %s: %v\n", result.ConfigType, result.Error)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintln(os.Stdout, "\nInstallation complete!")
|
||||
r.log("Headless installation completed successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
// buildDisabledItems computes the set of dependencies that should be skipped
|
||||
// during installation, applying the --include-deps and --exclude-deps filters.
|
||||
// dms-greeter is disabled by default (opt-in), matching TUI behavior.
|
||||
func (r *Runner) buildDisabledItems(dependencies []deps.Dependency) (map[string]bool, error) {
|
||||
disabledItems := make(map[string]bool)
|
||||
|
||||
// dms-greeter is opt-in (disabled by default), matching TUI behavior
|
||||
for i := range dependencies {
|
||||
if dependencies[i].Name == "dms-greeter" {
|
||||
disabledItems["dms-greeter"] = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Process --include-deps (enable items that are disabled by default)
|
||||
for _, name := range r.cfg.IncludeDeps {
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
if !r.depExists(dependencies, name) {
|
||||
return nil, fmt.Errorf("--include-deps: unknown dependency %q", name)
|
||||
}
|
||||
delete(disabledItems, name)
|
||||
}
|
||||
|
||||
// Process --exclude-deps (disable items)
|
||||
for _, name := range r.cfg.ExcludeDeps {
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
if !r.depExists(dependencies, name) {
|
||||
return nil, fmt.Errorf("--exclude-deps: unknown dependency %q", name)
|
||||
}
|
||||
// Don't allow excluding DMS itself
|
||||
if name == "dms (DankMaterialShell)" {
|
||||
return nil, fmt.Errorf("--exclude-deps: cannot exclude required package %q", name)
|
||||
}
|
||||
disabledItems[name] = true
|
||||
}
|
||||
|
||||
return disabledItems, nil
|
||||
}
|
||||
|
||||
// buildReplaceConfigs converts the --replace-configs / --replace-configs-all
|
||||
// flags into the map[string]bool consumed by the config deployer.
|
||||
//
|
||||
// Returns:
|
||||
// - nil when --replace-configs-all is set (deployer treats nil as "replace all")
|
||||
// - a map with all known configs set to false when neither flag is set (deploy only if config file is missing on disk)
|
||||
// - a map with requested configs true, all others false for --replace-configs
|
||||
// - an error when both flags are set or an invalid config name is given
|
||||
func (r *Runner) buildReplaceConfigs() (map[string]bool, error) {
|
||||
hasSpecific := len(r.cfg.ReplaceConfigs) > 0
|
||||
if hasSpecific && r.cfg.ReplaceConfigsAll {
|
||||
return nil, fmt.Errorf("--replace-configs and --replace-configs-all are mutually exclusive")
|
||||
}
|
||||
|
||||
if r.cfg.ReplaceConfigsAll {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Build a map with all known configs explicitly set to false
|
||||
result := make(map[string]bool, len(validConfigNames))
|
||||
for _, cliName := range orderedConfigNames {
|
||||
result[validConfigNames[cliName]] = false
|
||||
}
|
||||
|
||||
// Enable only the requested configs
|
||||
for _, name := range r.cfg.ReplaceConfigs {
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
deployerKey, ok := validConfigNames[strings.ToLower(name)]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("--replace-configs: unknown config %q; valid values: niri, hyprland, ghostty, kitty, alacritty", name)
|
||||
}
|
||||
result[deployerKey] = true
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *Runner) log(message string) {
|
||||
select {
|
||||
case r.logChan <- message:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Runner) parseWindowManager() (deps.WindowManager, error) {
|
||||
switch strings.ToLower(r.cfg.Compositor) {
|
||||
case "niri":
|
||||
return deps.WindowManagerNiri, nil
|
||||
case "hyprland":
|
||||
return deps.WindowManagerHyprland, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("invalid --compositor value %q: must be 'niri' or 'hyprland'", r.cfg.Compositor)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Runner) parseTerminal() (deps.Terminal, error) {
|
||||
switch strings.ToLower(r.cfg.Terminal) {
|
||||
case "ghostty":
|
||||
return deps.TerminalGhostty, nil
|
||||
case "kitty":
|
||||
return deps.TerminalKitty, nil
|
||||
case "alacritty":
|
||||
return deps.TerminalAlacritty, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("invalid --term value %q: must be 'ghostty', 'kitty', or 'alacritty'", r.cfg.Terminal)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Runner) resolveSudoPassword() (string, error) {
|
||||
// Check if sudo credentials are cached (via sudo -v or NOPASSWD)
|
||||
cmd := exec.Command("sudo", "-n", "true")
|
||||
if err := cmd.Run(); err == nil {
|
||||
r.log("sudo cache is valid, no password needed")
|
||||
fmt.Fprintln(os.Stdout, "sudo: using cached credentials")
|
||||
return "", nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf(
|
||||
"sudo authentication required but no cached credentials found\n" +
|
||||
"Options:\n" +
|
||||
" 1. Run 'sudo -v' before dankinstall to cache credentials\n" +
|
||||
" 2. Configure passwordless sudo for your user",
|
||||
)
|
||||
}
|
||||
|
||||
func (r *Runner) anyConfigEnabled(m map[string]bool) bool {
|
||||
for _, v := range m {
|
||||
if v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *Runner) depExists(dependencies []deps.Dependency, name string) bool {
|
||||
for _, dep := range dependencies {
|
||||
if dep.Name == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
459
core/internal/headless/runner_test.go
Normal file
459
core/internal/headless/runner_test.go
Normal file
@@ -0,0 +1,459 @@
|
||||
package headless
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/deps"
|
||||
)
|
||||
|
||||
func TestParseWindowManager(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want deps.WindowManager
|
||||
wantErr bool
|
||||
}{
|
||||
{"niri lowercase", "niri", deps.WindowManagerNiri, false},
|
||||
{"niri mixed case", "Niri", deps.WindowManagerNiri, false},
|
||||
{"hyprland lowercase", "hyprland", deps.WindowManagerHyprland, false},
|
||||
{"hyprland mixed case", "Hyprland", deps.WindowManagerHyprland, false},
|
||||
{"invalid", "sway", 0, true},
|
||||
{"empty", "", 0, true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := NewRunner(Config{Compositor: tt.input})
|
||||
got, err := r.parseWindowManager()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("parseWindowManager() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !tt.wantErr && got != tt.want {
|
||||
t.Errorf("parseWindowManager() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseTerminal(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want deps.Terminal
|
||||
wantErr bool
|
||||
}{
|
||||
{"ghostty lowercase", "ghostty", deps.TerminalGhostty, false},
|
||||
{"ghostty mixed case", "Ghostty", deps.TerminalGhostty, false},
|
||||
{"kitty lowercase", "kitty", deps.TerminalKitty, false},
|
||||
{"alacritty lowercase", "alacritty", deps.TerminalAlacritty, false},
|
||||
{"alacritty uppercase", "ALACRITTY", deps.TerminalAlacritty, false},
|
||||
{"invalid", "wezterm", 0, true},
|
||||
{"empty", "", 0, true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := NewRunner(Config{Terminal: tt.input})
|
||||
got, err := r.parseTerminal()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("parseTerminal() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !tt.wantErr && got != tt.want {
|
||||
t.Errorf("parseTerminal() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDepExists(t *testing.T) {
|
||||
dependencies := []deps.Dependency{
|
||||
{Name: "niri", Status: deps.StatusInstalled},
|
||||
{Name: "ghostty", Status: deps.StatusMissing},
|
||||
{Name: "dms (DankMaterialShell)", Status: deps.StatusInstalled},
|
||||
{Name: "dms-greeter", Status: deps.StatusMissing},
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
dep string
|
||||
want bool
|
||||
}{
|
||||
{"existing dep", "niri", true},
|
||||
{"existing dep with special chars", "dms (DankMaterialShell)", true},
|
||||
{"existing optional dep", "dms-greeter", true},
|
||||
{"non-existing dep", "firefox", false},
|
||||
{"empty name", "", false},
|
||||
}
|
||||
|
||||
r := NewRunner(Config{})
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := r.depExists(dependencies, tt.dep); got != tt.want {
|
||||
t.Errorf("depExists(%q) = %v, want %v", tt.dep, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRunner(t *testing.T) {
|
||||
cfg := Config{
|
||||
Compositor: "niri",
|
||||
Terminal: "ghostty",
|
||||
IncludeDeps: []string{"dms-greeter"},
|
||||
ExcludeDeps: []string{"some-pkg"},
|
||||
Yes: true,
|
||||
}
|
||||
r := NewRunner(cfg)
|
||||
|
||||
if r == nil {
|
||||
t.Fatal("NewRunner returned nil")
|
||||
}
|
||||
if r.cfg.Compositor != "niri" {
|
||||
t.Errorf("cfg.Compositor = %q, want %q", r.cfg.Compositor, "niri")
|
||||
}
|
||||
if r.cfg.Terminal != "ghostty" {
|
||||
t.Errorf("cfg.Terminal = %q, want %q", r.cfg.Terminal, "ghostty")
|
||||
}
|
||||
if !r.cfg.Yes {
|
||||
t.Error("cfg.Yes = false, want true")
|
||||
}
|
||||
if r.logChan == nil {
|
||||
t.Error("logChan is nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetLogChan(t *testing.T) {
|
||||
r := NewRunner(Config{})
|
||||
ch := r.GetLogChan()
|
||||
if ch == nil {
|
||||
t.Fatal("GetLogChan returned nil")
|
||||
}
|
||||
|
||||
// Verify the channel is readable by sending a message
|
||||
go func() {
|
||||
r.logChan <- "test message"
|
||||
}()
|
||||
msg := <-ch
|
||||
if msg != "test message" {
|
||||
t.Errorf("received %q, want %q", msg, "test message")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLog(t *testing.T) {
|
||||
r := NewRunner(Config{})
|
||||
|
||||
// log should not block even if channel is full
|
||||
for i := 0; i < 1100; i++ {
|
||||
r.log("message")
|
||||
}
|
||||
// If we reach here without hanging, the non-blocking send works
|
||||
}
|
||||
|
||||
func TestRunRequiresYes(t *testing.T) {
|
||||
// Verify that ErrConfirmationRequired is a distinct sentinel error
|
||||
if ErrConfirmationRequired == nil {
|
||||
t.Fatal("ErrConfirmationRequired should not be nil")
|
||||
}
|
||||
expected := "confirmation required: pass --yes to proceed"
|
||||
if ErrConfirmationRequired.Error() != expected {
|
||||
t.Errorf("ErrConfirmationRequired = %q, want %q", ErrConfirmationRequired.Error(), expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigYesStoredCorrectly(t *testing.T) {
|
||||
// Yes=false (default) should be stored
|
||||
rNo := NewRunner(Config{Compositor: "niri", Terminal: "ghostty", Yes: false})
|
||||
if rNo.cfg.Yes {
|
||||
t.Error("cfg.Yes = true, want false")
|
||||
}
|
||||
|
||||
// Yes=true should be stored
|
||||
rYes := NewRunner(Config{Compositor: "niri", Terminal: "ghostty", Yes: true})
|
||||
if !rYes.cfg.Yes {
|
||||
t.Error("cfg.Yes = false, want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidConfigNamesCompleteness(t *testing.T) {
|
||||
// orderedConfigNames and validConfigNames must stay in sync.
|
||||
if len(orderedConfigNames) != len(validConfigNames) {
|
||||
t.Fatalf("orderedConfigNames has %d entries but validConfigNames has %d",
|
||||
len(orderedConfigNames), len(validConfigNames))
|
||||
}
|
||||
|
||||
// Every entry in orderedConfigNames must exist in validConfigNames.
|
||||
for _, name := range orderedConfigNames {
|
||||
if _, ok := validConfigNames[name]; !ok {
|
||||
t.Errorf("orderedConfigNames contains %q which is missing from validConfigNames", name)
|
||||
}
|
||||
}
|
||||
|
||||
// validConfigNames must have no extra keys not in orderedConfigNames.
|
||||
ordered := make(map[string]bool, len(orderedConfigNames))
|
||||
for _, name := range orderedConfigNames {
|
||||
ordered[name] = true
|
||||
}
|
||||
for key := range validConfigNames {
|
||||
if !ordered[key] {
|
||||
t.Errorf("validConfigNames contains %q which is missing from orderedConfigNames", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildReplaceConfigs(t *testing.T) {
|
||||
allDeployerKeys := []string{"Niri", "Hyprland", "Ghostty", "Kitty", "Alacritty"}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
replaceConfigs []string
|
||||
replaceAll bool
|
||||
wantNil bool // expect nil (replace all)
|
||||
wantEnabled []string // deployer keys that should be true
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "neither flag set",
|
||||
wantNil: false,
|
||||
wantEnabled: nil, // all should be false
|
||||
},
|
||||
{
|
||||
name: "replace-configs-all",
|
||||
replaceAll: true,
|
||||
wantNil: true,
|
||||
},
|
||||
{
|
||||
name: "specific configs",
|
||||
replaceConfigs: []string{"niri", "ghostty"},
|
||||
wantNil: false,
|
||||
wantEnabled: []string{"Niri", "Ghostty"},
|
||||
},
|
||||
{
|
||||
name: "both flags set",
|
||||
replaceConfigs: []string{"niri"},
|
||||
replaceAll: true,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid config name",
|
||||
replaceConfigs: []string{"foo"},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "case insensitive",
|
||||
replaceConfigs: []string{"NIRI", "Ghostty"},
|
||||
wantNil: false,
|
||||
wantEnabled: []string{"Niri", "Ghostty"},
|
||||
},
|
||||
{
|
||||
name: "single config",
|
||||
replaceConfigs: []string{"kitty"},
|
||||
wantNil: false,
|
||||
wantEnabled: []string{"Kitty"},
|
||||
},
|
||||
{
|
||||
name: "whitespace entry",
|
||||
replaceConfigs: []string{" ", "niri"},
|
||||
wantNil: false,
|
||||
wantEnabled: []string{"Niri"},
|
||||
},
|
||||
{
|
||||
name: "duplicate entry",
|
||||
replaceConfigs: []string{"niri", "niri"},
|
||||
wantNil: false,
|
||||
wantEnabled: []string{"Niri"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := NewRunner(Config{
|
||||
ReplaceConfigs: tt.replaceConfigs,
|
||||
ReplaceConfigsAll: tt.replaceAll,
|
||||
})
|
||||
got, err := r.buildReplaceConfigs()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Fatalf("buildReplaceConfigs() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
if tt.wantErr {
|
||||
return
|
||||
}
|
||||
if tt.wantNil {
|
||||
if got != nil {
|
||||
t.Fatalf("buildReplaceConfigs() = %v, want nil", got)
|
||||
}
|
||||
return
|
||||
}
|
||||
if got == nil {
|
||||
t.Fatal("buildReplaceConfigs() = nil, want non-nil map")
|
||||
}
|
||||
|
||||
// All known deployer keys must be present
|
||||
for _, key := range allDeployerKeys {
|
||||
if _, exists := got[key]; !exists {
|
||||
t.Errorf("missing deployer key %q in result map", key)
|
||||
}
|
||||
}
|
||||
|
||||
// Build enabled set for easy lookup
|
||||
enabledSet := make(map[string]bool)
|
||||
for _, k := range tt.wantEnabled {
|
||||
enabledSet[k] = true
|
||||
}
|
||||
|
||||
for _, key := range allDeployerKeys {
|
||||
want := enabledSet[key]
|
||||
if got[key] != want {
|
||||
t.Errorf("replaceConfigs[%q] = %v, want %v", key, got[key], want)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigReplaceConfigsStoredCorrectly(t *testing.T) {
|
||||
r := NewRunner(Config{
|
||||
Compositor: "niri",
|
||||
Terminal: "ghostty",
|
||||
ReplaceConfigs: []string{"niri", "ghostty"},
|
||||
ReplaceConfigsAll: false,
|
||||
})
|
||||
if len(r.cfg.ReplaceConfigs) != 2 {
|
||||
t.Errorf("len(ReplaceConfigs) = %d, want 2", len(r.cfg.ReplaceConfigs))
|
||||
}
|
||||
if r.cfg.ReplaceConfigsAll {
|
||||
t.Error("ReplaceConfigsAll = true, want false")
|
||||
}
|
||||
|
||||
r2 := NewRunner(Config{
|
||||
Compositor: "niri",
|
||||
Terminal: "ghostty",
|
||||
ReplaceConfigsAll: true,
|
||||
})
|
||||
if !r2.cfg.ReplaceConfigsAll {
|
||||
t.Error("ReplaceConfigsAll = false, want true")
|
||||
}
|
||||
if len(r2.cfg.ReplaceConfigs) != 0 {
|
||||
t.Errorf("len(ReplaceConfigs) = %d, want 0", len(r2.cfg.ReplaceConfigs))
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDisabledItems(t *testing.T) {
|
||||
dependencies := []deps.Dependency{
|
||||
{Name: "niri", Status: deps.StatusInstalled},
|
||||
{Name: "ghostty", Status: deps.StatusMissing},
|
||||
{Name: "dms (DankMaterialShell)", Status: deps.StatusInstalled},
|
||||
{Name: "dms-greeter", Status: deps.StatusMissing},
|
||||
{Name: "waybar", Status: deps.StatusMissing},
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
includeDeps []string
|
||||
excludeDeps []string
|
||||
deps []deps.Dependency // nil means use the shared fixture
|
||||
wantErr bool
|
||||
errContains string // substring expected in error message
|
||||
wantDisabled []string // dep names that should be in disabledItems
|
||||
wantEnabled []string // dep names that should NOT be in disabledItems (extra check)
|
||||
}{
|
||||
{
|
||||
name: "no flags set, dms-greeter disabled by default",
|
||||
wantDisabled: []string{"dms-greeter"},
|
||||
wantEnabled: []string{"niri", "ghostty", "waybar"},
|
||||
},
|
||||
{
|
||||
name: "include dms-greeter enables it",
|
||||
includeDeps: []string{"dms-greeter"},
|
||||
wantEnabled: []string{"dms-greeter"},
|
||||
},
|
||||
{
|
||||
name: "exclude a regular dep",
|
||||
excludeDeps: []string{"waybar"},
|
||||
wantDisabled: []string{"dms-greeter", "waybar"},
|
||||
},
|
||||
{
|
||||
name: "include unknown dep returns error",
|
||||
includeDeps: []string{"nonexistent"},
|
||||
wantErr: true,
|
||||
errContains: "--include-deps",
|
||||
},
|
||||
{
|
||||
name: "exclude unknown dep returns error",
|
||||
excludeDeps: []string{"nonexistent"},
|
||||
wantErr: true,
|
||||
errContains: "--exclude-deps",
|
||||
},
|
||||
{
|
||||
name: "exclude DMS itself is forbidden",
|
||||
excludeDeps: []string{"dms (DankMaterialShell)"},
|
||||
wantErr: true,
|
||||
errContains: "cannot exclude required package",
|
||||
},
|
||||
{
|
||||
name: "include and exclude same dep",
|
||||
includeDeps: []string{"dms-greeter"},
|
||||
excludeDeps: []string{"dms-greeter"},
|
||||
wantDisabled: []string{"dms-greeter"},
|
||||
},
|
||||
{
|
||||
name: "whitespace entries are skipped",
|
||||
includeDeps: []string{" ", "dms-greeter"},
|
||||
wantEnabled: []string{"dms-greeter"},
|
||||
},
|
||||
{
|
||||
name: "no dms-greeter in deps, nothing disabled by default",
|
||||
deps: []deps.Dependency{
|
||||
{Name: "niri", Status: deps.StatusInstalled},
|
||||
},
|
||||
wantEnabled: []string{"niri"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := NewRunner(Config{
|
||||
IncludeDeps: tt.includeDeps,
|
||||
ExcludeDeps: tt.excludeDeps,
|
||||
})
|
||||
d := tt.deps
|
||||
if d == nil {
|
||||
d = dependencies
|
||||
}
|
||||
got, err := r.buildDisabledItems(d)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Fatalf("buildDisabledItems() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
if tt.wantErr {
|
||||
if tt.errContains != "" && !strings.Contains(err.Error(), tt.errContains) {
|
||||
t.Errorf("error %q does not contain %q", err.Error(), tt.errContains)
|
||||
}
|
||||
return
|
||||
}
|
||||
if got == nil {
|
||||
t.Fatal("buildDisabledItems() returned nil map, want non-nil")
|
||||
}
|
||||
|
||||
// Check expected disabled items
|
||||
for _, name := range tt.wantDisabled {
|
||||
if !got[name] {
|
||||
t.Errorf("expected %q to be disabled, but it is not", name)
|
||||
}
|
||||
}
|
||||
|
||||
// Check expected enabled items (should not be in the map or be false)
|
||||
for _, name := range tt.wantEnabled {
|
||||
if got[name] {
|
||||
t.Errorf("expected %q to NOT be disabled, but it is", name)
|
||||
}
|
||||
}
|
||||
|
||||
// If wantDisabled is empty, the map should have length 0
|
||||
if len(tt.wantDisabled) == 0 && len(got) != 0 {
|
||||
t.Errorf("expected empty disabledItems map, got %v", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -21,7 +22,16 @@ type FileLogger struct {
|
||||
|
||||
func NewFileLogger() (*FileLogger, error) {
|
||||
timestamp := time.Now().Unix()
|
||||
logPath := fmt.Sprintf("/tmp/dankinstall-%d.log", timestamp)
|
||||
|
||||
// Use DANKINSTALL_LOG_DIR if set, otherwise fall back to /tmp.
|
||||
logDir := os.Getenv("DANKINSTALL_LOG_DIR")
|
||||
if logDir == "" {
|
||||
logDir = "/tmp"
|
||||
}
|
||||
if err := os.MkdirAll(logDir, 0o755); err != nil {
|
||||
return nil, fmt.Errorf("failed to create log directory: %w", err)
|
||||
}
|
||||
logPath := filepath.Join(logDir, fmt.Sprintf("dankinstall-%d.log", timestamp))
|
||||
|
||||
file, err := os.Create(logPath)
|
||||
if err != nil {
|
||||
|
||||
@@ -218,7 +218,9 @@ func (b *DDCBackend) SetBrightnessWithExponent(id string, value int, exponential
|
||||
if timer, exists := b.debounceTimers[id]; exists {
|
||||
timer.Reset(200 * time.Millisecond)
|
||||
} else {
|
||||
b.debounceWg.Add(1)
|
||||
b.debounceTimers[id] = time.AfterFunc(200*time.Millisecond, func() {
|
||||
defer b.debounceWg.Done()
|
||||
b.debounceMutex.Lock()
|
||||
pending, exists := b.debouncePending[id]
|
||||
if exists {
|
||||
@@ -490,5 +492,19 @@ func (b *DDCBackend) valueToPercent(value int, max int, exponential bool) int {
|
||||
return percent
|
||||
}
|
||||
|
||||
func (b *DDCBackend) WaitPending() {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
b.debounceWg.Wait()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(5 * time.Second):
|
||||
log.Debug("WaitPending timed out waiting for DDC writes")
|
||||
}
|
||||
}
|
||||
|
||||
func (b *DDCBackend) Close() {
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ type DDCBackend struct {
|
||||
debounceMutex sync.Mutex
|
||||
debounceTimers map[string]*time.Timer
|
||||
debouncePending map[string]ddcPendingSet
|
||||
debounceWg sync.WaitGroup
|
||||
}
|
||||
|
||||
type ddcPendingSet struct {
|
||||
|
||||
@@ -158,18 +158,26 @@ func (b *NetworkManagerBackend) GetWiFiNetworkDetails(ssid string) (*NetworkInfo
|
||||
|
||||
channel := frequencyToChannel(freq)
|
||||
|
||||
isConnected := ssid == currentSSID && bssid == currentBSSID
|
||||
rate := maxBitrate / 1000
|
||||
if isConnected {
|
||||
if devBitrate, err := w.GetPropertyBitrate(); err == nil && devBitrate > 0 {
|
||||
rate = devBitrate / 1000
|
||||
}
|
||||
}
|
||||
|
||||
network := WiFiNetwork{
|
||||
SSID: ssid,
|
||||
BSSID: bssid,
|
||||
Signal: strength,
|
||||
Secured: secured,
|
||||
Enterprise: enterprise,
|
||||
Connected: ssid == currentSSID && bssid == currentBSSID,
|
||||
Connected: isConnected,
|
||||
Saved: savedSSIDs[ssid],
|
||||
Autoconnect: autoconnectMap[ssid],
|
||||
Frequency: freq,
|
||||
Mode: modeStr,
|
||||
Rate: maxBitrate / 1000,
|
||||
Rate: rate,
|
||||
Channel: channel,
|
||||
}
|
||||
|
||||
@@ -514,19 +522,27 @@ func (b *NetworkManagerBackend) updateWiFiNetworks() ([]WiFiNetwork, error) {
|
||||
|
||||
channel := frequencyToChannel(freq)
|
||||
|
||||
isConnected := ssid == currentSSID
|
||||
rate := maxBitrate / 1000
|
||||
if isConnected {
|
||||
if devBitrate, err := w.GetPropertyBitrate(); err == nil && devBitrate > 0 {
|
||||
rate = devBitrate / 1000
|
||||
}
|
||||
}
|
||||
|
||||
network := WiFiNetwork{
|
||||
SSID: ssid,
|
||||
BSSID: bssid,
|
||||
Signal: strength,
|
||||
Secured: secured,
|
||||
Enterprise: enterprise,
|
||||
Connected: ssid == currentSSID,
|
||||
Connected: isConnected,
|
||||
Saved: savedSSIDs[ssid],
|
||||
Autoconnect: autoconnectMap[ssid],
|
||||
Hidden: hiddenSSIDs[ssid],
|
||||
Frequency: freq,
|
||||
Mode: modeStr,
|
||||
Rate: maxBitrate / 1000,
|
||||
Rate: rate,
|
||||
Channel: channel,
|
||||
}
|
||||
|
||||
@@ -1062,19 +1078,27 @@ func (b *NetworkManagerBackend) updateAllWiFiDevices() {
|
||||
|
||||
channel := frequencyToChannel(freq)
|
||||
|
||||
isConnected := connected && apSSID == ssid
|
||||
rate := maxBitrate / 1000
|
||||
if isConnected {
|
||||
if devBitrate, err := devInfo.wireless.GetPropertyBitrate(); err == nil && devBitrate > 0 {
|
||||
rate = devBitrate / 1000
|
||||
}
|
||||
}
|
||||
|
||||
network := WiFiNetwork{
|
||||
SSID: apSSID,
|
||||
BSSID: apBSSID,
|
||||
Signal: strength,
|
||||
Secured: secured,
|
||||
Enterprise: enterprise,
|
||||
Connected: connected && apSSID == ssid,
|
||||
Connected: isConnected,
|
||||
Saved: savedSSIDs[apSSID],
|
||||
Autoconnect: autoconnectMap[apSSID],
|
||||
Hidden: hiddenSSIDs[apSSID],
|
||||
Frequency: freq,
|
||||
Mode: modeStr,
|
||||
Rate: maxBitrate / 1000,
|
||||
Rate: rate,
|
||||
Channel: channel,
|
||||
Device: name,
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/models"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/network"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/thememode"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/trayrecovery"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/wayland"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/wlcontext"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/wlroutput"
|
||||
@@ -72,6 +73,7 @@ var clipboardManager *clipboard.Manager
|
||||
var dbusManager *serverDbus.Manager
|
||||
var wlContext *wlcontext.SharedContext
|
||||
var themeModeManager *thememode.Manager
|
||||
var trayRecoveryManager *trayrecovery.Manager
|
||||
var locationManager *location.Manager
|
||||
var geoClientInstance geolocation.Client
|
||||
|
||||
@@ -394,6 +396,18 @@ func InitializeThemeModeManager() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func InitializeTrayRecoveryManager() error {
|
||||
manager, err := trayrecovery.NewManager()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
trayRecoveryManager = manager
|
||||
|
||||
log.Info("TrayRecovery manager initialized")
|
||||
return nil
|
||||
}
|
||||
|
||||
func InitializeLocationManager(geoClient geolocation.Client) error {
|
||||
manager, err := location.NewManager(geoClient)
|
||||
if err != nil {
|
||||
@@ -1325,6 +1339,9 @@ func cleanupManagers() {
|
||||
if themeModeManager != nil {
|
||||
themeModeManager.Close()
|
||||
}
|
||||
if trayRecoveryManager != nil {
|
||||
trayRecoveryManager.Close()
|
||||
}
|
||||
if wlContext != nil {
|
||||
wlContext.Close()
|
||||
}
|
||||
@@ -1610,6 +1627,18 @@ func Start(printDocs bool) error {
|
||||
}()
|
||||
}
|
||||
|
||||
go func() {
|
||||
<-loginctlReady
|
||||
if loginctlManager == nil {
|
||||
return
|
||||
}
|
||||
if err := InitializeTrayRecoveryManager(); err != nil {
|
||||
log.Warnf("TrayRecovery manager unavailable: %v", err)
|
||||
} else {
|
||||
trayRecoveryManager.WatchLoginctl(loginctlManager)
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
geoClient := geolocation.NewClient()
|
||||
geoClientInstance = geoClient
|
||||
|
||||
93
core/internal/server/trayrecovery/manager.go
Normal file
93
core/internal/server/trayrecovery/manager.go
Normal file
@@ -0,0 +1,93 @@
|
||||
package trayrecovery
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/loginctl"
|
||||
"github.com/godbus/dbus/v5"
|
||||
)
|
||||
|
||||
const resumeDelay = 3 * time.Second
|
||||
|
||||
type Manager struct {
|
||||
conn *dbus.Conn
|
||||
stopChan chan struct{}
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
func NewManager() (*Manager, error) {
|
||||
conn, err := dbus.ConnectSessionBus()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to session bus: %w", err)
|
||||
}
|
||||
|
||||
m := &Manager{
|
||||
conn: conn,
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
|
||||
// Run a startup scan after a delay — covers the case where the process
|
||||
// was killed during suspend and restarted by systemd (Type=dbus).
|
||||
// The fresh process never sees the PrepareForSleep true→false transition,
|
||||
// so the loginctl watcher alone is not enough.
|
||||
go m.scheduleRecovery()
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// WatchLoginctl subscribes to loginctl session state changes and triggers
|
||||
// tray recovery after resume from suspend (PrepareForSleep false transition).
|
||||
// This handles the case where the process survives suspend.
|
||||
func (m *Manager) WatchLoginctl(lm *loginctl.Manager) {
|
||||
ch := lm.Subscribe("tray-recovery")
|
||||
m.wg.Add(1)
|
||||
go func() {
|
||||
defer m.wg.Done()
|
||||
defer lm.Unsubscribe("tray-recovery")
|
||||
|
||||
wasSleeping := false
|
||||
for {
|
||||
select {
|
||||
case <-m.stopChan:
|
||||
return
|
||||
case state, ok := <-ch:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if state.PreparingForSleep {
|
||||
wasSleeping = true
|
||||
continue
|
||||
}
|
||||
if wasSleeping {
|
||||
wasSleeping = false
|
||||
go m.scheduleRecovery()
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (m *Manager) scheduleRecovery() {
|
||||
select {
|
||||
case <-time.After(resumeDelay):
|
||||
m.recoverTrayItems()
|
||||
case <-m.stopChan:
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) Close() {
|
||||
select {
|
||||
case <-m.stopChan:
|
||||
return
|
||||
default:
|
||||
close(m.stopChan)
|
||||
}
|
||||
m.wg.Wait()
|
||||
if m.conn != nil {
|
||||
m.conn.Close()
|
||||
}
|
||||
log.Info("TrayRecovery manager closed")
|
||||
}
|
||||
262
core/internal/server/trayrecovery/recovery.go
Normal file
262
core/internal/server/trayrecovery/recovery.go
Normal file
@@ -0,0 +1,262 @@
|
||||
package trayrecovery
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
"github.com/godbus/dbus/v5"
|
||||
)
|
||||
|
||||
const (
|
||||
sniWatcherDest = "org.kde.StatusNotifierWatcher"
|
||||
sniWatcherPath = "/StatusNotifierWatcher"
|
||||
sniWatcherIface = "org.kde.StatusNotifierWatcher"
|
||||
sniItemIface = "org.kde.StatusNotifierItem"
|
||||
dbusIface = "org.freedesktop.DBus"
|
||||
propsIface = "org.freedesktop.DBus.Properties"
|
||||
probeTimeout = 300 * time.Millisecond
|
||||
connProbeTimeout = 150 * time.Millisecond
|
||||
batchSize = 30
|
||||
)
|
||||
|
||||
var excludedPrefixes = []string{
|
||||
"org.freedesktop.",
|
||||
"org.gnome.",
|
||||
"org.kde.StatusNotifier",
|
||||
"com.canonical.AppMenu",
|
||||
"org.mpris.",
|
||||
"org.pipewire.",
|
||||
"org.pulseaudio",
|
||||
"fi.epitaph",
|
||||
"quickshell",
|
||||
"org.kde.quickshell",
|
||||
}
|
||||
|
||||
func (m *Manager) recoverTrayItems() {
|
||||
registeredItems := m.getRegisteredItems()
|
||||
allNames := m.getDBusNames()
|
||||
if allNames == nil {
|
||||
return
|
||||
}
|
||||
|
||||
registeredConnIDs := m.buildRegisteredConnIDs(registeredItems)
|
||||
|
||||
count := len(registeredItems)
|
||||
log.Infof("TrayRecoveryService: scanning DBus for unregistered SNI items (%d already registered)...", count)
|
||||
|
||||
m.scanWellKnownNames(allNames, registeredItems, registeredConnIDs)
|
||||
m.scanConnectionIDs(allNames, registeredItems, registeredConnIDs)
|
||||
}
|
||||
|
||||
func (m *Manager) getRegisteredItems() []string {
|
||||
obj := m.conn.Object(sniWatcherDest, sniWatcherPath)
|
||||
variant, err := obj.GetProperty(sniWatcherIface + ".RegisteredStatusNotifierItems")
|
||||
if err != nil {
|
||||
log.Warnf("TrayRecoveryService: failed to get registered items: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
switch v := variant.Value().(type) {
|
||||
case []string:
|
||||
return v
|
||||
case []any:
|
||||
items := make([]string, 0, len(v))
|
||||
for _, elem := range v {
|
||||
if s, ok := elem.(string); ok {
|
||||
items = append(items, s)
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) getDBusNames() []string {
|
||||
var names []string
|
||||
err := m.conn.BusObject().Call(dbusIface+".ListNames", 0).Store(&names)
|
||||
if err != nil {
|
||||
log.Warnf("TrayRecoveryService: failed to list bus names: %v", err)
|
||||
return nil
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
func (m *Manager) getNameOwner(name string) string {
|
||||
var owner string
|
||||
err := m.conn.BusObject().Call(dbusIface+".GetNameOwner", 0, name).Store(&owner)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return owner
|
||||
}
|
||||
|
||||
// buildRegisteredConnIDs resolves every registered SNI item (well-known name
|
||||
// or :1.xxx connection ID) to a canonical connection ID. This prevents
|
||||
// duplicates in both directions.
|
||||
func (m *Manager) buildRegisteredConnIDs(registeredItems []string) map[string]bool {
|
||||
connIDs := make(map[string]bool, len(registeredItems))
|
||||
for _, item := range registeredItems {
|
||||
name := extractName(item)
|
||||
if strings.HasPrefix(name, ":1.") {
|
||||
connIDs[name] = true
|
||||
} else {
|
||||
owner := m.getNameOwner(name)
|
||||
if owner != "" {
|
||||
connIDs[owner] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return connIDs
|
||||
}
|
||||
|
||||
// scanWellKnownNames probes well-known names (e.g. DinoX, nm-applet) for
|
||||
// unregistered SNI items and re-registers them.
|
||||
func (m *Manager) scanWellKnownNames(allNames []string, registeredItems []string, registeredConnIDs map[string]bool) {
|
||||
registeredRaw := strings.Join(registeredItems, "\n")
|
||||
|
||||
for _, name := range allNames {
|
||||
if strings.HasPrefix(name, ":") {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(registeredRaw, name) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Skip if this name's connection ID is already in the registered set
|
||||
// (handles the case where the app registered via connection ID instead)
|
||||
connForName := m.getNameOwner(name)
|
||||
if connForName != "" && registeredConnIDs[connForName] {
|
||||
continue
|
||||
}
|
||||
|
||||
if isExcludedName(name) {
|
||||
continue
|
||||
}
|
||||
|
||||
short := shortName(name)
|
||||
objectPaths := []string{
|
||||
"/StatusNotifierItem",
|
||||
"/org/ayatana/NotificationItem/" + short,
|
||||
}
|
||||
|
||||
for _, objPath := range objectPaths {
|
||||
if m.probeSNI(name, objPath, probeTimeout) {
|
||||
m.registerSNI(name)
|
||||
// Update set so the connection-ID section won't double-register this app
|
||||
if connForName != "" {
|
||||
registeredConnIDs[connForName] = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// scanConnectionIDs probes all :1.xxx connections in parallel for unregistered
|
||||
// SNI items (e.g. Vesktop, Electron apps). Most non-SNI connections return an
|
||||
// error instantly, so this is fast.
|
||||
func (m *Manager) scanConnectionIDs(allNames []string, registeredItems []string, registeredConnIDs map[string]bool) {
|
||||
registeredRaw := strings.Join(registeredItems, "\n")
|
||||
registeredLower := strings.ToLower(registeredRaw)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
sem := make(chan struct{}, batchSize)
|
||||
|
||||
for _, name := range allNames {
|
||||
if !strings.HasPrefix(name, ":1.") {
|
||||
continue
|
||||
}
|
||||
if registeredConnIDs[name] {
|
||||
continue
|
||||
}
|
||||
|
||||
sem <- struct{}{}
|
||||
wg.Add(1)
|
||||
go func(conn string) {
|
||||
defer wg.Done()
|
||||
defer func() { <-sem }()
|
||||
|
||||
sniID := m.getSNIId(conn, connProbeTimeout)
|
||||
if sniID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// Skip if an item with the same Id is already registered (case-insensitive)
|
||||
if strings.Contains(registeredLower, strings.ToLower(sniID)) {
|
||||
return
|
||||
}
|
||||
|
||||
m.registerSNI(conn)
|
||||
log.Infof("TrayRecovery: re-registered %s (Id: %s)", conn, sniID)
|
||||
}(name)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (m *Manager) probeSNI(dest, path string, timeout time.Duration) bool {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
obj := m.conn.Object(dest, dbus.ObjectPath(path))
|
||||
var props map[string]dbus.Variant
|
||||
err := obj.CallWithContext(ctx, propsIface+".GetAll", 0, sniItemIface).Store(&props)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
_, hasID := props["Id"]
|
||||
return hasID
|
||||
}
|
||||
|
||||
func (m *Manager) getSNIId(dest string, timeout time.Duration) string {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
obj := m.conn.Object(dest, "/StatusNotifierItem")
|
||||
var variant dbus.Variant
|
||||
err := obj.CallWithContext(ctx, propsIface+".Get", 0, sniItemIface, "Id").Store(&variant)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
id, _ := variant.Value().(string)
|
||||
return id
|
||||
}
|
||||
|
||||
func (m *Manager) registerSNI(name string) {
|
||||
obj := m.conn.Object(sniWatcherDest, sniWatcherPath)
|
||||
call := obj.Call(sniWatcherIface+".RegisterStatusNotifierItem", 0, name)
|
||||
if call.Err != nil {
|
||||
log.Warnf("TrayRecovery: failed to register %s: %v", name, call.Err)
|
||||
return
|
||||
}
|
||||
log.Infof("TrayRecovery: re-registered %s", name)
|
||||
}
|
||||
|
||||
func extractName(item string) string {
|
||||
if idx := strings.IndexByte(item, '/'); idx != -1 {
|
||||
return item[:idx]
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
func shortName(name string) string {
|
||||
parts := strings.Split(name, ".")
|
||||
if len(parts) > 0 {
|
||||
return parts[len(parts)-1]
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func isExcludedName(name string) bool {
|
||||
for _, prefix := range excludedPrefixes {
|
||||
if strings.HasPrefix(name, prefix) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -3,8 +3,11 @@ package wayland
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"slices"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -73,7 +76,10 @@ func NewManager(display wlclient.WaylandDisplay, config Config) (*Manager, error
|
||||
m.post(func() {
|
||||
log.Info("Gamma control enabled at startup")
|
||||
gammaMgr := m.gammaControl.(*wlr_gamma_control.ZwlrGammaControlManagerV1)
|
||||
if err := m.setupOutputControls(m.availableOutputs, gammaMgr); err != nil {
|
||||
m.availOutputsMu.RLock()
|
||||
outs := slices.Clone(m.availableOutputs)
|
||||
m.availOutputsMu.RUnlock()
|
||||
if err := m.setupOutputControls(outs, gammaMgr); err != nil {
|
||||
log.Errorf("Failed to initialize gamma controls: %v", err)
|
||||
return
|
||||
}
|
||||
@@ -170,6 +176,7 @@ func (m *Manager) setupRegistry() error {
|
||||
})
|
||||
if gammaMgr != nil {
|
||||
outputs = append(outputs, output)
|
||||
m.addAvailableOutput(output)
|
||||
}
|
||||
m.outputRegNames.Store(outputID, e.Name)
|
||||
|
||||
@@ -204,6 +211,11 @@ func (m *Manager) setupRegistry() error {
|
||||
}
|
||||
if foundOut.gammaControl != nil {
|
||||
foundOut.gammaControl.(*wlr_gamma_control.ZwlrGammaControlV1).Destroy()
|
||||
foundOut.gammaControl = nil
|
||||
}
|
||||
m.removeAvailableOutput(foundOut.output)
|
||||
if foundOut.output != nil && !foundOut.output.IsZombie() {
|
||||
_ = foundOut.output.Release()
|
||||
}
|
||||
m.outputs.Delete(foundID)
|
||||
|
||||
@@ -288,14 +300,28 @@ func (m *Manager) setupControlHandlers(state *outputState, control *wlr_gamma_co
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if ctrl, ok := out.gammaControl.(*wlr_gamma_control.ZwlrGammaControlV1); ok && ctrl != nil && !ctrl.IsZombie() {
|
||||
ctrl.Destroy()
|
||||
}
|
||||
out.gammaControl = nil
|
||||
out.failed = true
|
||||
out.rampSize = 0
|
||||
out.retryCount++
|
||||
out.lastFailTime = time.Now()
|
||||
|
||||
if !m.outputStillValid(out) {
|
||||
return
|
||||
}
|
||||
|
||||
backoff := time.Duration(300<<uint(min(out.retryCount-1, 4))) * time.Millisecond
|
||||
time.AfterFunc(backoff, func() {
|
||||
m.post(func() {
|
||||
if !m.outputStillValid(out) {
|
||||
return
|
||||
}
|
||||
if _, stillTracked := m.outputs.Load(outputID); !stillTracked {
|
||||
return
|
||||
}
|
||||
m.recreateOutputControl(out)
|
||||
})
|
||||
})
|
||||
@@ -303,12 +329,75 @@ func (m *Manager) setupControlHandlers(state *outputState, control *wlr_gamma_co
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Manager) addAvailableOutput(o *wlclient.Output) {
|
||||
if o == nil {
|
||||
return
|
||||
}
|
||||
m.availOutputsMu.Lock()
|
||||
defer m.availOutputsMu.Unlock()
|
||||
if slices.Contains(m.availableOutputs, o) {
|
||||
return
|
||||
}
|
||||
m.availableOutputs = append(m.availableOutputs, o)
|
||||
}
|
||||
|
||||
func (m *Manager) removeAvailableOutput(o *wlclient.Output) {
|
||||
if o == nil {
|
||||
return
|
||||
}
|
||||
m.availOutputsMu.Lock()
|
||||
defer m.availOutputsMu.Unlock()
|
||||
m.availableOutputs = slices.DeleteFunc(m.availableOutputs, func(existing *wlclient.Output) bool {
|
||||
return existing == o
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Manager) outputStillValid(out *outputState) bool {
|
||||
switch {
|
||||
case out == nil:
|
||||
return false
|
||||
case out.output == nil:
|
||||
return false
|
||||
case out.output.IsZombie():
|
||||
return false
|
||||
}
|
||||
m.availOutputsMu.RLock()
|
||||
defer m.availOutputsMu.RUnlock()
|
||||
return slices.Contains(m.availableOutputs, out.output)
|
||||
}
|
||||
|
||||
func isConnectionDeadErr(err error) bool {
|
||||
switch {
|
||||
case err == nil:
|
||||
return false
|
||||
case errors.Is(err, syscall.EPIPE):
|
||||
return true
|
||||
case errors.Is(err, syscall.ECONNRESET):
|
||||
return true
|
||||
case errors.Is(err, syscall.EBADF):
|
||||
return true
|
||||
case errors.Is(err, io.EOF):
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *Manager) addOutputControl(output *wlclient.Output) error {
|
||||
switch {
|
||||
case m.connectionDead.Load():
|
||||
return nil
|
||||
case output == nil || output.IsZombie():
|
||||
return nil
|
||||
}
|
||||
|
||||
outputID := output.ID()
|
||||
gammaMgr := m.gammaControl.(*wlr_gamma_control.ZwlrGammaControlManagerV1)
|
||||
|
||||
control, err := gammaMgr.GetGammaControl(output)
|
||||
if err != nil {
|
||||
if isConnectionDeadErr(err) {
|
||||
m.markConnectionDead(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -329,26 +418,37 @@ func (m *Manager) recreateOutputControl(out *outputState) error {
|
||||
enabled := m.config.Enabled
|
||||
m.configMutex.RUnlock()
|
||||
|
||||
if !enabled || !m.controlsInitialized {
|
||||
switch {
|
||||
case m.connectionDead.Load():
|
||||
return nil
|
||||
case !enabled || !m.controlsInitialized:
|
||||
return nil
|
||||
case out.isVirtual:
|
||||
return nil
|
||||
case out.retryCount >= 10:
|
||||
return nil
|
||||
case !m.outputStillValid(out):
|
||||
return nil
|
||||
}
|
||||
if _, ok := m.outputs.Load(out.id); !ok {
|
||||
return nil
|
||||
}
|
||||
if out.isVirtual {
|
||||
return nil
|
||||
}
|
||||
if out.retryCount >= 10 {
|
||||
return nil
|
||||
}
|
||||
|
||||
gammaMgr, ok := m.gammaControl.(*wlr_gamma_control.ZwlrGammaControlManagerV1)
|
||||
if !ok {
|
||||
return fmt.Errorf("no gamma manager")
|
||||
}
|
||||
|
||||
if existing, ok := out.gammaControl.(*wlr_gamma_control.ZwlrGammaControlV1); ok && existing != nil && !existing.IsZombie() {
|
||||
existing.Destroy()
|
||||
out.gammaControl = nil
|
||||
}
|
||||
|
||||
control, err := gammaMgr.GetGammaControl(out.output)
|
||||
if err != nil {
|
||||
if isConnectionDeadErr(err) {
|
||||
m.markConnectionDead(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -358,6 +458,13 @@ func (m *Manager) recreateOutputControl(out *outputState) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) markConnectionDead(err error) {
|
||||
if m.connectionDead.Swap(true) {
|
||||
return
|
||||
}
|
||||
log.Errorf("gamma: wayland connection appears dead (%v); pausing gamma operations", err)
|
||||
}
|
||||
|
||||
func (m *Manager) recalcSchedule(now time.Time) {
|
||||
m.configMutex.RLock()
|
||||
config := m.config
|
||||
@@ -690,11 +797,12 @@ func (m *Manager) applyGamma(temp int) {
|
||||
gamma := m.config.Gamma
|
||||
m.configMutex.RUnlock()
|
||||
|
||||
if !m.controlsInitialized {
|
||||
switch {
|
||||
case m.connectionDead.Load():
|
||||
return
|
||||
}
|
||||
|
||||
if m.lastAppliedTemp == temp && m.lastAppliedGamma == gamma {
|
||||
case !m.controlsInitialized:
|
||||
return
|
||||
case m.lastAppliedTemp == temp && m.lastAppliedGamma == gamma:
|
||||
return
|
||||
}
|
||||
|
||||
@@ -714,7 +822,14 @@ func (m *Manager) applyGamma(temp int) {
|
||||
var jobs []job
|
||||
|
||||
for _, out := range outs {
|
||||
if out.failed || out.rampSize == 0 {
|
||||
switch {
|
||||
case out.failed:
|
||||
continue
|
||||
case out.rampSize == 0:
|
||||
continue
|
||||
case out.gammaControl == nil:
|
||||
continue
|
||||
case !m.outputStillValid(out):
|
||||
continue
|
||||
}
|
||||
ramp := GenerateGammaRamp(out.rampSize, temp, gamma)
|
||||
@@ -732,18 +847,16 @@ func (m *Manager) applyGamma(temp int) {
|
||||
}
|
||||
|
||||
for _, j := range jobs {
|
||||
if err := m.setGammaBytes(j.out, j.data); err != nil {
|
||||
log.Warnf("gamma: failed to set output %d: %v", j.out.id, err)
|
||||
j.out.failed = true
|
||||
j.out.rampSize = 0
|
||||
outID := j.out.id
|
||||
time.AfterFunc(300*time.Millisecond, func() {
|
||||
m.post(func() {
|
||||
if out, ok := m.outputs.Load(outID); ok && out.failed {
|
||||
m.recreateOutputControl(out)
|
||||
}
|
||||
})
|
||||
})
|
||||
err := m.setGammaBytes(j.out, j.data)
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
log.Warnf("gamma: failed to set output %d: %v", j.out.id, err)
|
||||
j.out.failed = true
|
||||
j.out.rampSize = 0
|
||||
if isConnectionDeadErr(err) {
|
||||
m.markConnectionDead(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -752,6 +865,14 @@ func (m *Manager) applyGamma(temp int) {
|
||||
}
|
||||
|
||||
func (m *Manager) setGammaBytes(out *outputState, data []byte) error {
|
||||
if out.gammaControl == nil {
|
||||
return fmt.Errorf("no gamma control")
|
||||
}
|
||||
ctrl, ok := out.gammaControl.(*wlr_gamma_control.ZwlrGammaControlV1)
|
||||
if !ok || ctrl == nil || ctrl.IsZombie() {
|
||||
return fmt.Errorf("gamma control invalid")
|
||||
}
|
||||
|
||||
fd, err := MemfdCreate("gamma-ramp", 0)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -774,7 +895,6 @@ func (m *Manager) setGammaBytes(out *outputState, data []byte) error {
|
||||
}
|
||||
syscall.Seek(fd, 0, 0)
|
||||
|
||||
ctrl := out.gammaControl.(*wlr_gamma_control.ZwlrGammaControlV1)
|
||||
return ctrl.SetGamma(fd)
|
||||
}
|
||||
|
||||
@@ -882,10 +1002,10 @@ func (m *Manager) dbusMonitor() {
|
||||
}
|
||||
|
||||
func (m *Manager) handleDBusSignal(sig *dbus.Signal) {
|
||||
if sig.Name != "org.freedesktop.login1.Manager.PrepareForSleep" {
|
||||
switch {
|
||||
case sig.Name != "org.freedesktop.login1.Manager.PrepareForSleep":
|
||||
return
|
||||
}
|
||||
if len(sig.Body) == 0 {
|
||||
case len(sig.Body) == 0:
|
||||
return
|
||||
}
|
||||
preparing, ok := sig.Body[0].(bool)
|
||||
@@ -899,27 +1019,34 @@ func (m *Manager) handleDBusSignal(sig *dbus.Signal) {
|
||||
return
|
||||
}
|
||||
time.AfterFunc(500*time.Millisecond, func() {
|
||||
m.post(func() {
|
||||
m.configMutex.RLock()
|
||||
stillEnabled := m.config.Enabled
|
||||
m.configMutex.RUnlock()
|
||||
if !stillEnabled || !m.controlsInitialized {
|
||||
return
|
||||
}
|
||||
m.outputs.Range(func(_ uint32, out *outputState) bool {
|
||||
if out.gammaControl != nil {
|
||||
out.gammaControl.(*wlr_gamma_control.ZwlrGammaControlV1).Destroy()
|
||||
out.gammaControl = nil
|
||||
}
|
||||
out.retryCount = 0
|
||||
out.failed = false
|
||||
m.recreateOutputControl(out)
|
||||
return true
|
||||
})
|
||||
})
|
||||
m.post(m.handleResume)
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Manager) handleResume() {
|
||||
m.configMutex.RLock()
|
||||
stillEnabled := m.config.Enabled
|
||||
m.configMutex.RUnlock()
|
||||
|
||||
switch {
|
||||
case !stillEnabled:
|
||||
return
|
||||
case !m.controlsInitialized:
|
||||
return
|
||||
case m.connectionDead.Load():
|
||||
return
|
||||
}
|
||||
|
||||
// Compositors (Niri, Hyprland, wlroots-based) re-apply the cached gamma
|
||||
// ramp to DRM on resume; gamma_control objects stay valid. We just need
|
||||
// to force a resend so the schedule catches up with the current time of
|
||||
// day — the original #1235 regression was caused by lastAppliedTemp
|
||||
// matching and the send being skipped.
|
||||
m.recalcSchedule(time.Now())
|
||||
m.lastAppliedTemp = 0
|
||||
m.applyCurrentTemp("resume")
|
||||
}
|
||||
|
||||
func (m *Manager) triggerUpdate() {
|
||||
select {
|
||||
case m.updateTrigger <- struct{}{}:
|
||||
@@ -1058,7 +1185,10 @@ func (m *Manager) SetEnabled(enabled bool) {
|
||||
case enabled && !m.controlsInitialized:
|
||||
m.post(func() {
|
||||
gammaMgr := m.gammaControl.(*wlr_gamma_control.ZwlrGammaControlManagerV1)
|
||||
if err := m.setupOutputControls(m.availableOutputs, gammaMgr); err != nil {
|
||||
m.availOutputsMu.RLock()
|
||||
outs := slices.Clone(m.availableOutputs)
|
||||
m.availOutputsMu.RUnlock()
|
||||
if err := m.setupOutputControls(outs, gammaMgr); err != nil {
|
||||
log.Errorf("gamma: failed to create controls: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package wayland
|
||||
import (
|
||||
"math"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/errdefs"
|
||||
@@ -71,9 +72,11 @@ type Manager struct {
|
||||
registry *wlclient.Registry
|
||||
gammaControl any
|
||||
availableOutputs []*wlclient.Output
|
||||
availOutputsMu sync.RWMutex
|
||||
outputRegNames syncmap.Map[uint32, uint32]
|
||||
outputs syncmap.Map[uint32, *outputState]
|
||||
controlsInitialized bool
|
||||
connectionDead atomic.Bool
|
||||
|
||||
cmdq chan cmd
|
||||
alive bool
|
||||
|
||||
@@ -139,7 +139,7 @@ func dmsPackageName(distroID string, dependencies []deps.Dependency) string {
|
||||
if isGit {
|
||||
return "dms-shell-git"
|
||||
}
|
||||
return "dms-shell-bin"
|
||||
return "dms-shell"
|
||||
case distros.FamilyFedora, distros.FamilyUbuntu, distros.FamilyDebian, distros.FamilySUSE:
|
||||
if isGit {
|
||||
return "dms-git"
|
||||
|
||||
@@ -124,6 +124,8 @@ Singleton {
|
||||
|
||||
property string vpnLastConnected: ""
|
||||
|
||||
property string lastPlayerIdentity: ""
|
||||
|
||||
property var deviceMaxVolumes: ({})
|
||||
property var hiddenOutputDeviceNames: []
|
||||
property var hiddenInputDeviceNames: []
|
||||
|
||||
@@ -301,6 +301,7 @@ Singleton {
|
||||
property var workspaceNameIcons: ({})
|
||||
property bool waveProgressEnabled: true
|
||||
property bool scrollTitleEnabled: true
|
||||
property bool mediaAdaptiveWidthEnabled: true
|
||||
property bool audioVisualizerEnabled: true
|
||||
property string audioScrollMode: "volume"
|
||||
property int audioWheelScrollAmount: 5
|
||||
@@ -358,6 +359,8 @@ Singleton {
|
||||
property string dankLauncherV2BorderColor: "primary"
|
||||
property bool dankLauncherV2ShowFooter: true
|
||||
property bool dankLauncherV2UnloadOnClose: false
|
||||
property bool dankLauncherV2IncludeFilesInAll: false
|
||||
property bool dankLauncherV2IncludeFoldersInAll: false
|
||||
|
||||
property string _legacyWeatherLocation: "New York, NY"
|
||||
property string _legacyWeatherCoordinates: "40.7128,-74.0060"
|
||||
@@ -434,17 +437,20 @@ Singleton {
|
||||
property bool soundNewNotification: true
|
||||
property bool soundVolumeChanged: true
|
||||
property bool soundPluggedIn: true
|
||||
property bool soundLogin: false
|
||||
|
||||
property int acMonitorTimeout: 0
|
||||
property int acLockTimeout: 0
|
||||
property int acSuspendTimeout: 0
|
||||
property int acSuspendBehavior: SettingsData.SuspendBehavior.Suspend
|
||||
property string acProfileName: ""
|
||||
property int acPostLockMonitorTimeout: 0
|
||||
property int batteryMonitorTimeout: 0
|
||||
property int batteryLockTimeout: 0
|
||||
property int batterySuspendTimeout: 0
|
||||
property int batterySuspendBehavior: SettingsData.SuspendBehavior.Suspend
|
||||
property string batteryProfileName: ""
|
||||
property int batteryPostLockMonitorTimeout: 0
|
||||
property int batteryChargeLimit: 100
|
||||
property bool lockBeforeSuspend: false
|
||||
property bool loginctlLockIntegration: true
|
||||
@@ -554,24 +560,24 @@ Singleton {
|
||||
|
||||
property bool enableFprint: false
|
||||
property int maxFprintTries: 15
|
||||
property bool fprintdAvailable: false
|
||||
property bool lockFingerprintCanEnable: false
|
||||
property bool lockFingerprintReady: false
|
||||
property string lockFingerprintReason: "probe_failed"
|
||||
property bool greeterFingerprintCanEnable: false
|
||||
property bool greeterFingerprintReady: false
|
||||
property string greeterFingerprintReason: "probe_failed"
|
||||
property string greeterFingerprintSource: "none"
|
||||
readonly property bool fprintdAvailable: Processes.fprintdAvailable
|
||||
readonly property bool lockFingerprintCanEnable: Processes.lockFingerprintCanEnable
|
||||
readonly property bool lockFingerprintReady: Processes.lockFingerprintReady
|
||||
readonly property string lockFingerprintReason: Processes.lockFingerprintReason
|
||||
readonly property bool greeterFingerprintCanEnable: Processes.greeterFingerprintCanEnable
|
||||
readonly property bool greeterFingerprintReady: Processes.greeterFingerprintReady
|
||||
readonly property string greeterFingerprintReason: Processes.greeterFingerprintReason
|
||||
readonly property string greeterFingerprintSource: Processes.greeterFingerprintSource
|
||||
property bool enableU2f: false
|
||||
property string u2fMode: "or"
|
||||
property bool u2fAvailable: false
|
||||
property bool lockU2fCanEnable: false
|
||||
property bool lockU2fReady: false
|
||||
property string lockU2fReason: "probe_failed"
|
||||
property bool greeterU2fCanEnable: false
|
||||
property bool greeterU2fReady: false
|
||||
property string greeterU2fReason: "probe_failed"
|
||||
property string greeterU2fSource: "none"
|
||||
readonly property bool u2fAvailable: Processes.u2fAvailable
|
||||
readonly property bool lockU2fCanEnable: Processes.lockU2fCanEnable
|
||||
readonly property bool lockU2fReady: Processes.lockU2fReady
|
||||
readonly property string lockU2fReason: Processes.lockU2fReason
|
||||
readonly property bool greeterU2fCanEnable: Processes.greeterU2fCanEnable
|
||||
readonly property bool greeterU2fReady: Processes.greeterU2fReady
|
||||
readonly property string greeterU2fReason: Processes.greeterU2fReason
|
||||
readonly property string greeterU2fSource: Processes.greeterU2fSource
|
||||
property string lockScreenActiveMonitor: "all"
|
||||
property string lockScreenInactiveColor: "#000000"
|
||||
property int lockScreenNotificationMode: 0
|
||||
@@ -1061,7 +1067,6 @@ Singleton {
|
||||
function refreshAuthAvailability() {
|
||||
if (isGreeterMode)
|
||||
return;
|
||||
Processes.settingsRoot = root;
|
||||
Processes.detectAuthCapabilities();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,16 +25,10 @@ Singleton {
|
||||
|
||||
property string fingerprintProbeOutput: ""
|
||||
property int fingerprintProbeExitCode: 0
|
||||
property bool fingerprintProbeStreamFinished: false
|
||||
property bool fingerprintProbeExited: false
|
||||
property string fingerprintProbeState: "probe_failed"
|
||||
property bool fingerprintProbeFinalized: false
|
||||
|
||||
property string pamSupportProbeOutput: ""
|
||||
property bool pamSupportProbeStreamFinished: false
|
||||
property bool pamSupportProbeExited: false
|
||||
property int pamSupportProbeExitCode: 0
|
||||
property bool pamFprintSupportDetected: false
|
||||
property bool pamU2fSupportDetected: false
|
||||
property string pamProbeOutput: ""
|
||||
property bool pamProbeFinalized: false
|
||||
|
||||
readonly property string homeDir: Quickshell.env("HOME") || ""
|
||||
readonly property string u2fKeysPath: homeDir ? homeDir + "/.config/Yubico/u2f_keys" : ""
|
||||
@@ -54,40 +48,189 @@ Singleton {
|
||||
|
||||
readonly property var forcedFprintAvailable: envFlag("DMS_FORCE_FPRINT_AVAILABLE")
|
||||
readonly property var forcedU2fAvailable: envFlag("DMS_FORCE_U2F_AVAILABLE")
|
||||
property bool authApplyRunning: false
|
||||
property bool authApplyQueued: false
|
||||
property bool authApplyRerunRequested: false
|
||||
property bool authApplyTerminalFallbackFromPrecheck: false
|
||||
property string authApplyStdout: ""
|
||||
property string authApplyStderr: ""
|
||||
property string authApplySudoProbeStderr: ""
|
||||
property string authApplyTerminalFallbackStderr: ""
|
||||
|
||||
function detectQtTools() {
|
||||
qtToolsDetectionProcess.running = true;
|
||||
// --- Derived auth probe state ---
|
||||
|
||||
readonly property bool pamFprintSupportDetected: pamProbeFinalized && pamProbeOutput.includes("pam_fprintd.so:true")
|
||||
readonly property bool pamU2fSupportDetected: pamProbeFinalized && pamProbeOutput.includes("pam_u2f.so:true")
|
||||
|
||||
readonly property string fingerprintProbeState: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable ? "ready" : "probe_failed";
|
||||
if (!fingerprintProbeFinalized)
|
||||
return "probe_failed";
|
||||
return parseFingerprintProbe(fingerprintProbeExitCode, fingerprintProbeOutput, pamFprintSupportDetected);
|
||||
}
|
||||
|
||||
function detectAuthCapabilities() {
|
||||
if (!settingsRoot)
|
||||
return;
|
||||
// --- Lock fingerprint capabilities ---
|
||||
|
||||
readonly property bool lockFingerprintCanEnable: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable;
|
||||
switch (fingerprintProbeState) {
|
||||
case "ready":
|
||||
case "missing_enrollment":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
readonly property bool lockFingerprintReady: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable;
|
||||
return fingerprintProbeState === "ready";
|
||||
}
|
||||
|
||||
readonly property string lockFingerprintReason: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable ? "ready" : "probe_failed";
|
||||
return fingerprintProbeState;
|
||||
}
|
||||
|
||||
// --- Greeter fingerprint capabilities ---
|
||||
|
||||
readonly property bool greeterFingerprintCanEnable: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable;
|
||||
if (greeterPamHasFprint)
|
||||
return fingerprintProbeState !== "missing_reader";
|
||||
switch (fingerprintProbeState) {
|
||||
case "ready":
|
||||
case "missing_enrollment":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
readonly property bool greeterFingerprintReady: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable;
|
||||
return fingerprintProbeState === "ready";
|
||||
}
|
||||
|
||||
readonly property string greeterFingerprintReason: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable ? "ready" : "probe_failed";
|
||||
if (greeterPamHasFprint) {
|
||||
switch (fingerprintProbeState) {
|
||||
case "ready":
|
||||
return "configured_externally";
|
||||
case "missing_enrollment":
|
||||
return "missing_enrollment";
|
||||
case "missing_reader":
|
||||
return "missing_reader";
|
||||
default:
|
||||
return "probe_failed";
|
||||
}
|
||||
}
|
||||
return fingerprintProbeState;
|
||||
}
|
||||
|
||||
readonly property string greeterFingerprintSource: {
|
||||
if (forcedFprintAvailable !== null)
|
||||
return forcedFprintAvailable ? "dms" : "none";
|
||||
if (greeterPamHasFprint)
|
||||
return "pam";
|
||||
switch (fingerprintProbeState) {
|
||||
case "ready":
|
||||
case "missing_enrollment":
|
||||
return "dms";
|
||||
default:
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
// --- Lock U2F capabilities ---
|
||||
|
||||
readonly property bool lockU2fReady: {
|
||||
if (forcedU2fAvailable !== null)
|
||||
return forcedU2fAvailable;
|
||||
return lockU2fCustomConfigDetected || homeU2fKeysDetected;
|
||||
}
|
||||
|
||||
readonly property bool lockU2fCanEnable: {
|
||||
if (forcedU2fAvailable !== null)
|
||||
return forcedU2fAvailable;
|
||||
return lockU2fReady || pamU2fSupportDetected;
|
||||
}
|
||||
|
||||
readonly property string lockU2fReason: {
|
||||
if (forcedU2fAvailable !== null)
|
||||
return forcedU2fAvailable ? "ready" : "probe_failed";
|
||||
if (lockU2fReady)
|
||||
return "ready";
|
||||
if (lockU2fCanEnable)
|
||||
return "missing_key_registration";
|
||||
return "missing_pam_support";
|
||||
}
|
||||
|
||||
// --- Greeter U2F capabilities ---
|
||||
|
||||
readonly property bool greeterU2fReady: {
|
||||
if (forcedU2fAvailable !== null)
|
||||
return forcedU2fAvailable;
|
||||
if (greeterPamHasU2f)
|
||||
return true;
|
||||
return homeU2fKeysDetected;
|
||||
}
|
||||
|
||||
readonly property bool greeterU2fCanEnable: {
|
||||
if (forcedU2fAvailable !== null)
|
||||
return forcedU2fAvailable;
|
||||
if (greeterPamHasU2f)
|
||||
return true;
|
||||
return greeterU2fReady || pamU2fSupportDetected;
|
||||
}
|
||||
|
||||
readonly property string greeterU2fReason: {
|
||||
if (forcedU2fAvailable !== null)
|
||||
return forcedU2fAvailable ? "ready" : "probe_failed";
|
||||
if (greeterPamHasU2f)
|
||||
return "configured_externally";
|
||||
if (greeterU2fReady)
|
||||
return "ready";
|
||||
if (greeterU2fCanEnable)
|
||||
return "missing_key_registration";
|
||||
return "missing_pam_support";
|
||||
}
|
||||
|
||||
readonly property string greeterU2fSource: {
|
||||
if (forcedU2fAvailable !== null)
|
||||
return forcedU2fAvailable ? "dms" : "none";
|
||||
if (greeterPamHasU2f)
|
||||
return "pam";
|
||||
if (greeterU2fCanEnable)
|
||||
return "dms";
|
||||
return "none";
|
||||
}
|
||||
|
||||
// --- Aggregates ---
|
||||
|
||||
readonly property bool fprintdAvailable: lockFingerprintReady || greeterFingerprintReady
|
||||
readonly property bool u2fAvailable: lockU2fReady || greeterU2fReady
|
||||
|
||||
// --- Auth detection ---
|
||||
|
||||
readonly property var _fprintProbeCommand: ["sh", "-c", "if command -v fprintd-list >/dev/null 2>&1; then fprintd-list \"${USER:-$(id -un)}\" 2>&1; else printf '__missing_command__\\n'; exit 127; fi"]
|
||||
readonly property var _pamProbeCommand: ["sh", "-c", "for module in pam_fprintd.so pam_u2f.so; do found=false; for dir in /usr/lib64/security /usr/lib/security /lib/security /lib/x86_64-linux-gnu/security /usr/lib/x86_64-linux-gnu/security /usr/lib/aarch64-linux-gnu/security /run/current-system/sw/lib/security; do if [ -f \"$dir/$module\" ]; then found=true; break; fi; done; printf '%s:%s\\n' \"$module\" \"$found\"; done"]
|
||||
|
||||
function detectAuthCapabilities() {
|
||||
if (forcedFprintAvailable === null) {
|
||||
fingerprintProbeOutput = "";
|
||||
fingerprintProbeStreamFinished = false;
|
||||
fingerprintProbeExited = false;
|
||||
fingerprintProbeProcess.running = true;
|
||||
} else {
|
||||
fingerprintProbeState = forcedFprintAvailable ? "ready" : "probe_failed";
|
||||
fingerprintProbeFinalized = false;
|
||||
Proc.runCommand("fprint-probe", _fprintProbeCommand, (output, exitCode) => {
|
||||
fingerprintProbeOutput = output || "";
|
||||
fingerprintProbeExitCode = exitCode;
|
||||
fingerprintProbeFinalized = true;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
pamFprintSupportDetected = false;
|
||||
pamU2fSupportDetected = false;
|
||||
pamSupportProbeOutput = "";
|
||||
pamSupportProbeStreamFinished = false;
|
||||
pamSupportProbeExited = false;
|
||||
pamSupportDetectionProcess.running = true;
|
||||
|
||||
recomputeAuthCapabilities();
|
||||
pamProbeFinalized = false;
|
||||
Proc.runCommand("pam-probe", _pamProbeCommand, (output, _exitCode) => {
|
||||
pamProbeOutput = output || "";
|
||||
pamProbeFinalized = true;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function detectFprintd() {
|
||||
@@ -98,9 +241,16 @@ Singleton {
|
||||
detectAuthCapabilities();
|
||||
}
|
||||
|
||||
function checkPluginSettings() {
|
||||
pluginSettingsCheckProcess.running = true;
|
||||
}
|
||||
// --- Auth apply pipeline ---
|
||||
|
||||
property bool authApplyRunning: false
|
||||
property bool authApplyQueued: false
|
||||
property bool authApplyRerunRequested: false
|
||||
property bool authApplyTerminalFallbackFromPrecheck: false
|
||||
property string authApplyStdout: ""
|
||||
property string authApplyStderr: ""
|
||||
property string authApplySudoProbeStderr: ""
|
||||
property string authApplyTerminalFallbackStderr: ""
|
||||
|
||||
function scheduleAuthApply() {
|
||||
if (!settingsRoot || settingsRoot.isGreeterMode)
|
||||
@@ -146,6 +296,8 @@ Singleton {
|
||||
authApplyDebounce.restart();
|
||||
}
|
||||
|
||||
// --- PAM parsing helpers ---
|
||||
|
||||
function stripPamComment(line) {
|
||||
if (!line)
|
||||
return "";
|
||||
@@ -189,15 +341,7 @@ Singleton {
|
||||
function greeterPamStackHasModule(moduleName) {
|
||||
if (pamModuleEnabled(greetdPamText, moduleName))
|
||||
return true;
|
||||
const includedPamStacks = [
|
||||
["system-auth", systemAuthPamText],
|
||||
["common-auth", commonAuthPamText],
|
||||
["password-auth", passwordAuthPamText],
|
||||
["system-login", systemLoginPamText],
|
||||
["system-local-login", systemLocalLoginPamText],
|
||||
["common-auth-pc", commonAuthPcPamText],
|
||||
["login", loginPamText]
|
||||
];
|
||||
const includedPamStacks = [["system-auth", systemAuthPamText], ["common-auth", commonAuthPamText], ["password-auth", passwordAuthPamText], ["system-login", systemLoginPamText], ["system-local-login", systemLocalLoginPamText], ["common-auth-pc", commonAuthPcPamText], ["login", loginPamText]];
|
||||
for (let i = 0; i < includedPamStacks.length; i++) {
|
||||
const stack = includedPamStacks[i];
|
||||
if (pamTextIncludesFile(greetdPamText, stack[0]) && pamModuleEnabled(stack[1], moduleName))
|
||||
@@ -206,6 +350,8 @@ Singleton {
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- Fingerprint probe output parsing ---
|
||||
|
||||
function hasEnrolledFingerprintOutput(output) {
|
||||
const lower = (output || "").toLowerCase();
|
||||
if (lower.includes("has fingers enrolled") || lower.includes("has fingerprints enrolled"))
|
||||
@@ -223,21 +369,15 @@ Singleton {
|
||||
|
||||
function hasMissingFingerprintEnrollmentOutput(output) {
|
||||
const lower = (output || "").toLowerCase();
|
||||
return lower.includes("no fingers enrolled")
|
||||
|| lower.includes("no fingerprints enrolled")
|
||||
|| lower.includes("no prints enrolled");
|
||||
return lower.includes("no fingers enrolled") || lower.includes("no fingerprints enrolled") || lower.includes("no prints enrolled");
|
||||
}
|
||||
|
||||
function hasMissingFingerprintReaderOutput(output) {
|
||||
const lower = (output || "").toLowerCase();
|
||||
return lower.includes("no devices available")
|
||||
|| lower.includes("no device available")
|
||||
|| lower.includes("no devices found")
|
||||
|| lower.includes("list_devices failed")
|
||||
|| lower.includes("no device");
|
||||
return lower.includes("no devices available") || lower.includes("no device available") || lower.includes("no devices found") || lower.includes("list_devices failed") || lower.includes("no device");
|
||||
}
|
||||
|
||||
function parseFingerprintProbe(exitCode, output) {
|
||||
function parseFingerprintProbe(exitCode, output, pamFprintDetected) {
|
||||
if (hasEnrolledFingerprintOutput(output))
|
||||
return "ready";
|
||||
if (hasMissingFingerprintEnrollmentOutput(output))
|
||||
@@ -248,164 +388,17 @@ Singleton {
|
||||
return "missing_enrollment";
|
||||
if (exitCode === 127 || (output || "").includes("__missing_command__"))
|
||||
return "probe_failed";
|
||||
return pamFprintSupportDetected ? "probe_failed" : "missing_pam_support";
|
||||
return pamFprintDetected ? "probe_failed" : "missing_pam_support";
|
||||
}
|
||||
|
||||
function setLockFingerprintCapability(canEnable, ready, reason) {
|
||||
settingsRoot.lockFingerprintCanEnable = canEnable;
|
||||
settingsRoot.lockFingerprintReady = ready;
|
||||
settingsRoot.lockFingerprintReason = reason;
|
||||
// --- Qt tools detection ---
|
||||
|
||||
function detectQtTools() {
|
||||
qtToolsDetectionProcess.running = true;
|
||||
}
|
||||
|
||||
function setLockU2fCapability(canEnable, ready, reason) {
|
||||
settingsRoot.lockU2fCanEnable = canEnable;
|
||||
settingsRoot.lockU2fReady = ready;
|
||||
settingsRoot.lockU2fReason = reason;
|
||||
}
|
||||
|
||||
function setGreeterFingerprintCapability(canEnable, ready, reason, source) {
|
||||
settingsRoot.greeterFingerprintCanEnable = canEnable;
|
||||
settingsRoot.greeterFingerprintReady = ready;
|
||||
settingsRoot.greeterFingerprintReason = reason;
|
||||
settingsRoot.greeterFingerprintSource = source;
|
||||
}
|
||||
|
||||
function setGreeterU2fCapability(canEnable, ready, reason, source) {
|
||||
settingsRoot.greeterU2fCanEnable = canEnable;
|
||||
settingsRoot.greeterU2fReady = ready;
|
||||
settingsRoot.greeterU2fReason = reason;
|
||||
settingsRoot.greeterU2fSource = source;
|
||||
}
|
||||
|
||||
function recomputeFingerprintCapabilities() {
|
||||
if (forcedFprintAvailable !== null) {
|
||||
const reason = forcedFprintAvailable ? "ready" : "probe_failed";
|
||||
const source = forcedFprintAvailable ? "dms" : "none";
|
||||
setLockFingerprintCapability(forcedFprintAvailable, forcedFprintAvailable, reason);
|
||||
setGreeterFingerprintCapability(forcedFprintAvailable, forcedFprintAvailable, reason, source);
|
||||
return;
|
||||
}
|
||||
|
||||
const state = fingerprintProbeState;
|
||||
|
||||
switch (state) {
|
||||
case "ready":
|
||||
setLockFingerprintCapability(true, true, "ready");
|
||||
break;
|
||||
case "missing_enrollment":
|
||||
setLockFingerprintCapability(true, false, "missing_enrollment");
|
||||
break;
|
||||
case "missing_reader":
|
||||
setLockFingerprintCapability(false, false, "missing_reader");
|
||||
break;
|
||||
case "missing_pam_support":
|
||||
setLockFingerprintCapability(false, false, "missing_pam_support");
|
||||
break;
|
||||
default:
|
||||
setLockFingerprintCapability(false, false, "probe_failed");
|
||||
break;
|
||||
}
|
||||
|
||||
if (greeterPamHasFprint) {
|
||||
switch (state) {
|
||||
case "ready":
|
||||
setGreeterFingerprintCapability(true, true, "configured_externally", "pam");
|
||||
break;
|
||||
case "missing_enrollment":
|
||||
setGreeterFingerprintCapability(true, false, "missing_enrollment", "pam");
|
||||
break;
|
||||
case "missing_reader":
|
||||
setGreeterFingerprintCapability(false, false, "missing_reader", "pam");
|
||||
break;
|
||||
default:
|
||||
setGreeterFingerprintCapability(true, false, "probe_failed", "pam");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case "ready":
|
||||
setGreeterFingerprintCapability(true, true, "ready", "dms");
|
||||
break;
|
||||
case "missing_enrollment":
|
||||
setGreeterFingerprintCapability(true, false, "missing_enrollment", "dms");
|
||||
break;
|
||||
case "missing_reader":
|
||||
setGreeterFingerprintCapability(false, false, "missing_reader", "none");
|
||||
break;
|
||||
case "missing_pam_support":
|
||||
setGreeterFingerprintCapability(false, false, "missing_pam_support", "none");
|
||||
break;
|
||||
default:
|
||||
setGreeterFingerprintCapability(false, false, "probe_failed", "none");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function recomputeU2fCapabilities() {
|
||||
if (forcedU2fAvailable !== null) {
|
||||
const reason = forcedU2fAvailable ? "ready" : "probe_failed";
|
||||
const source = forcedU2fAvailable ? "dms" : "none";
|
||||
setLockU2fCapability(forcedU2fAvailable, forcedU2fAvailable, reason);
|
||||
setGreeterU2fCapability(forcedU2fAvailable, forcedU2fAvailable, reason, source);
|
||||
return;
|
||||
}
|
||||
|
||||
const lockReady = lockU2fCustomConfigDetected || homeU2fKeysDetected;
|
||||
const lockCanEnable = lockReady || pamU2fSupportDetected;
|
||||
const lockReason = lockReady ? "ready" : (lockCanEnable ? "missing_key_registration" : "missing_pam_support");
|
||||
setLockU2fCapability(lockCanEnable, lockReady, lockReason);
|
||||
|
||||
if (greeterPamHasU2f) {
|
||||
setGreeterU2fCapability(true, true, "configured_externally", "pam");
|
||||
return;
|
||||
}
|
||||
|
||||
const greeterReady = homeU2fKeysDetected;
|
||||
const greeterCanEnable = greeterReady || pamU2fSupportDetected;
|
||||
const greeterReason = greeterReady ? "ready" : (greeterCanEnable ? "missing_key_registration" : "missing_pam_support");
|
||||
setGreeterU2fCapability(greeterCanEnable, greeterReady, greeterReason, greeterCanEnable ? "dms" : "none");
|
||||
}
|
||||
|
||||
function recomputeAuthCapabilities() {
|
||||
if (!settingsRoot)
|
||||
return;
|
||||
recomputeFingerprintCapabilities();
|
||||
recomputeU2fCapabilities();
|
||||
settingsRoot.fprintdAvailable = settingsRoot.lockFingerprintReady || settingsRoot.greeterFingerprintReady;
|
||||
settingsRoot.u2fAvailable = settingsRoot.lockU2fReady || settingsRoot.greeterU2fReady;
|
||||
}
|
||||
|
||||
function finalizeFingerprintProbe() {
|
||||
if (!fingerprintProbeStreamFinished || !fingerprintProbeExited)
|
||||
return;
|
||||
fingerprintProbeState = parseFingerprintProbe(fingerprintProbeExitCode, fingerprintProbeOutput);
|
||||
recomputeAuthCapabilities();
|
||||
}
|
||||
|
||||
function finalizePamSupportProbe() {
|
||||
if (!pamSupportProbeStreamFinished || !pamSupportProbeExited)
|
||||
return;
|
||||
|
||||
pamFprintSupportDetected = false;
|
||||
pamU2fSupportDetected = false;
|
||||
|
||||
const lines = (pamSupportProbeOutput || "").trim().split(/\r?\n/);
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const parts = lines[i].split(":");
|
||||
if (parts.length !== 2)
|
||||
continue;
|
||||
if (parts[0] === "pam_fprintd.so")
|
||||
pamFprintSupportDetected = parts[1] === "true";
|
||||
else if (parts[0] === "pam_u2f.so")
|
||||
pamU2fSupportDetected = parts[1] === "true";
|
||||
}
|
||||
|
||||
if (forcedFprintAvailable === null && fingerprintProbeState === "missing_pam_support")
|
||||
fingerprintProbeState = parseFingerprintProbe(fingerprintProbeExitCode, fingerprintProbeOutput);
|
||||
|
||||
recomputeAuthCapabilities();
|
||||
function checkPluginSettings() {
|
||||
pluginSettingsCheckProcess.running = true;
|
||||
}
|
||||
|
||||
property var qtToolsDetectionProcess: Process {
|
||||
@@ -433,44 +426,6 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
property var fingerprintProbeProcess: Process {
|
||||
command: ["sh", "-c", "if command -v fprintd-list >/dev/null 2>&1; then fprintd-list \"${USER:-$(id -un)}\" 2>&1; else printf '__missing_command__\\n'; exit 127; fi"]
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
root.fingerprintProbeOutput = text || "";
|
||||
root.fingerprintProbeStreamFinished = true;
|
||||
root.finalizeFingerprintProbe();
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
root.fingerprintProbeExitCode = exitCode;
|
||||
root.fingerprintProbeExited = true;
|
||||
root.finalizeFingerprintProbe();
|
||||
}
|
||||
}
|
||||
|
||||
property var pamSupportDetectionProcess: Process {
|
||||
command: ["sh", "-c", "for module in pam_fprintd.so pam_u2f.so; do found=false; for dir in /usr/lib64/security /usr/lib/security /lib/security /lib/x86_64-linux-gnu/security /usr/lib/x86_64-linux-gnu/security /usr/lib/aarch64-linux-gnu/security /run/current-system/sw/lib/security; do if [ -f \"$dir/$module\" ]; then found=true; break; fi; done; printf '%s:%s\\n' \"$module\" \"$found\"; done"]
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
root.pamSupportProbeOutput = text || "";
|
||||
root.pamSupportProbeStreamFinished = true;
|
||||
root.finalizePamSupportProbe();
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
root.pamSupportProbeExitCode = exitCode;
|
||||
root.pamSupportProbeExited = true;
|
||||
root.finalizePamSupportProbe();
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: authApplyDebounce
|
||||
interval: 300
|
||||
@@ -544,9 +499,7 @@ Singleton {
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode === 0) {
|
||||
const message = root.authApplyTerminalFallbackFromPrecheck
|
||||
? I18n.tr("Terminal opened. Complete authentication setup there; it will close automatically when done.")
|
||||
: I18n.tr("Terminal fallback opened. Complete authentication setup there; it will close automatically when done.");
|
||||
const message = root.authApplyTerminalFallbackFromPrecheck ? I18n.tr("Terminal opened. Complete authentication setup there; it will close automatically when done.") : I18n.tr("Terminal fallback opened. Complete authentication setup there; it will close automatically when done.");
|
||||
ToastService.showInfo(message, "", "", "auth-sync");
|
||||
} else {
|
||||
let details = (root.authApplyTerminalFallbackStderr || "").trim();
|
||||
@@ -560,140 +513,80 @@ Singleton {
|
||||
id: greetdPamWatcher
|
||||
path: "/etc/pam.d/greetd"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.greetdPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.greetdPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.greetdPamText = text()
|
||||
onLoadFailed: root.greetdPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: systemAuthPamWatcher
|
||||
path: "/etc/pam.d/system-auth"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.systemAuthPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.systemAuthPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.systemAuthPamText = text()
|
||||
onLoadFailed: root.systemAuthPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: commonAuthPamWatcher
|
||||
path: "/etc/pam.d/common-auth"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.commonAuthPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.commonAuthPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.commonAuthPamText = text()
|
||||
onLoadFailed: root.commonAuthPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: passwordAuthPamWatcher
|
||||
path: "/etc/pam.d/password-auth"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.passwordAuthPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.passwordAuthPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.passwordAuthPamText = text()
|
||||
onLoadFailed: root.passwordAuthPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: systemLoginPamWatcher
|
||||
path: "/etc/pam.d/system-login"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.systemLoginPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.systemLoginPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.systemLoginPamText = text()
|
||||
onLoadFailed: root.systemLoginPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: systemLocalLoginPamWatcher
|
||||
path: "/etc/pam.d/system-local-login"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.systemLocalLoginPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.systemLocalLoginPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.systemLocalLoginPamText = text()
|
||||
onLoadFailed: root.systemLocalLoginPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: commonAuthPcPamWatcher
|
||||
path: "/etc/pam.d/common-auth-pc"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.commonAuthPcPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.commonAuthPcPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.commonAuthPcPamText = text()
|
||||
onLoadFailed: root.commonAuthPcPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: loginPamWatcher
|
||||
path: "/etc/pam.d/login"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.loginPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.loginPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.loginPamText = text()
|
||||
onLoadFailed: root.loginPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: dankshellU2fPamWatcher
|
||||
path: "/etc/pam.d/dankshell-u2f"
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.dankshellU2fPamText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.dankshellU2fPamText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.dankshellU2fPamText = text()
|
||||
onLoadFailed: root.dankshellU2fPamText = ""
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: u2fKeysWatcher
|
||||
path: root.u2fKeysPath
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
root.u2fKeysText = text();
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoadFailed: {
|
||||
root.u2fKeysText = "";
|
||||
root.recomputeAuthCapabilities();
|
||||
}
|
||||
onLoaded: root.u2fKeysText = text()
|
||||
onLoadFailed: root.u2fKeysText = ""
|
||||
}
|
||||
|
||||
property var pluginSettingsCheckProcess: Process {
|
||||
|
||||
@@ -75,6 +75,8 @@ var SPEC = {
|
||||
|
||||
vpnLastConnected: { def: "" },
|
||||
|
||||
lastPlayerIdentity: { def: "" },
|
||||
|
||||
deviceMaxVolumes: { def: {} },
|
||||
hiddenOutputDeviceNames: { def: [] },
|
||||
hiddenInputDeviceNames: { def: [] },
|
||||
|
||||
@@ -140,6 +140,7 @@ var SPEC = {
|
||||
workspaceNameIcons: { def: {} },
|
||||
waveProgressEnabled: { def: true },
|
||||
scrollTitleEnabled: { def: true },
|
||||
mediaAdaptiveWidthEnabled: { def: true },
|
||||
audioVisualizerEnabled: { def: true },
|
||||
audioScrollMode: { def: "volume" },
|
||||
audioWheelScrollAmount: { def: 5 },
|
||||
@@ -203,6 +204,8 @@ var SPEC = {
|
||||
dankLauncherV2BorderColor: { def: "primary" },
|
||||
dankLauncherV2ShowFooter: { def: true },
|
||||
dankLauncherV2UnloadOnClose: { def: false },
|
||||
dankLauncherV2IncludeFilesInAll: { def: false },
|
||||
dankLauncherV2IncludeFoldersInAll: { def: false },
|
||||
|
||||
useAutoLocation: { def: false },
|
||||
weatherEnabled: { def: true },
|
||||
@@ -242,6 +245,7 @@ var SPEC = {
|
||||
|
||||
soundsEnabled: { def: true },
|
||||
useSystemSoundTheme: { def: false },
|
||||
soundLogin: { def: false },
|
||||
soundNewNotification: { def: true },
|
||||
soundVolumeChanged: { def: true },
|
||||
soundPluggedIn: { def: true },
|
||||
@@ -251,11 +255,13 @@ var SPEC = {
|
||||
acSuspendTimeout: { def: 0 },
|
||||
acSuspendBehavior: { def: 0 },
|
||||
acProfileName: { def: "" },
|
||||
acPostLockMonitorTimeout: { def: 0 },
|
||||
batteryMonitorTimeout: { def: 0 },
|
||||
batteryLockTimeout: { def: 0 },
|
||||
batterySuspendTimeout: { def: 0 },
|
||||
batterySuspendBehavior: { def: 0 },
|
||||
batteryProfileName: { def: "" },
|
||||
batteryPostLockMonitorTimeout: { def: 0 },
|
||||
batteryChargeLimit: { def: 100 },
|
||||
lockBeforeSuspend: { def: false },
|
||||
loginctlLockIntegration: { def: true },
|
||||
@@ -358,26 +364,10 @@ var SPEC = {
|
||||
lockScreenShowMediaPlayer: { def: true },
|
||||
lockScreenPowerOffMonitorsOnLock: { def: false },
|
||||
lockAtStartup: { def: false },
|
||||
enableFprint: { def: false, onChange: "scheduleAuthApply" },
|
||||
enableFprint: { def: false },
|
||||
maxFprintTries: { def: 15 },
|
||||
fprintdAvailable: { def: false, persist: false },
|
||||
lockFingerprintCanEnable: { def: false, persist: false },
|
||||
lockFingerprintReady: { def: false, persist: false },
|
||||
lockFingerprintReason: { def: "probe_failed", persist: false },
|
||||
greeterFingerprintCanEnable: { def: false, persist: false },
|
||||
greeterFingerprintReady: { def: false, persist: false },
|
||||
greeterFingerprintReason: { def: "probe_failed", persist: false },
|
||||
greeterFingerprintSource: { def: "none", persist: false },
|
||||
enableU2f: { def: false, onChange: "scheduleAuthApply" },
|
||||
u2fMode: { def: "or" },
|
||||
u2fAvailable: { def: false, persist: false },
|
||||
lockU2fCanEnable: { def: false, persist: false },
|
||||
lockU2fReady: { def: false, persist: false },
|
||||
lockU2fReason: { def: "probe_failed", persist: false },
|
||||
greeterU2fCanEnable: { def: false, persist: false },
|
||||
greeterU2fReady: { def: false, persist: false },
|
||||
greeterU2fReason: { def: "probe_failed", persist: false },
|
||||
greeterU2fSource: { def: "none", persist: false },
|
||||
lockScreenActiveMonitor: { def: "all" },
|
||||
lockScreenInactiveColor: { def: "#000000" },
|
||||
lockScreenNotificationMode: { def: 0 },
|
||||
|
||||
@@ -221,10 +221,22 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: loginSoundTimer
|
||||
// Half a second delay before playing login sound, otherwise the sound may be cut off
|
||||
// 50 is the minimum that seems to work, but 500 is safer
|
||||
interval: 500
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
AudioService.playLoginSoundIfApplicable();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
dockRecreateDebounce.start();
|
||||
// Force PolkitService singleton to initialize
|
||||
PolkitService.polkitAvailable;
|
||||
loginSoundTimer.start();
|
||||
}
|
||||
|
||||
Loader {
|
||||
|
||||
@@ -369,9 +369,7 @@ Item {
|
||||
}
|
||||
|
||||
function previous(): void {
|
||||
if (MprisController.activePlayer && MprisController.activePlayer.canGoPrevious) {
|
||||
MprisController.activePlayer.previous();
|
||||
}
|
||||
MprisController.previousOrRewind();
|
||||
}
|
||||
|
||||
function next(): void {
|
||||
|
||||
@@ -122,7 +122,7 @@ Item {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("No recent clipboard entries found")
|
||||
text: clipboardContent.modal.clipboardAvailable ? I18n.tr("No recent clipboard entries found") : I18n.tr("Connecting to clipboard service…")
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
@@ -181,7 +181,7 @@ Item {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("No saved clipboard entries")
|
||||
text: clipboardContent.modal.clipboardAvailable ? I18n.tr("No saved clipboard entries") : I18n.tr("Connecting to clipboard service…")
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
|
||||
@@ -60,15 +60,12 @@ DankModal {
|
||||
}
|
||||
|
||||
function show() {
|
||||
if (!clipboardAvailable) {
|
||||
ToastService.showError(I18n.tr("Clipboard service not available"));
|
||||
return;
|
||||
}
|
||||
open();
|
||||
activeImageLoads = 0;
|
||||
shouldHaveFocus = true;
|
||||
ClipboardService.reset();
|
||||
ClipboardService.refresh();
|
||||
if (clipboardAvailable)
|
||||
ClipboardService.refresh();
|
||||
keyboardController.reset();
|
||||
|
||||
Qt.callLater(function () {
|
||||
|
||||
@@ -50,14 +50,11 @@ DankPopout {
|
||||
}
|
||||
|
||||
function show() {
|
||||
if (!clipboardAvailable) {
|
||||
ToastService.showError(I18n.tr("Clipboard service not available"));
|
||||
return;
|
||||
}
|
||||
open();
|
||||
activeImageLoads = 0;
|
||||
ClipboardService.reset();
|
||||
ClipboardService.refresh();
|
||||
if (clipboardAvailable)
|
||||
ClipboardService.refresh();
|
||||
keyboardController.reset();
|
||||
|
||||
Qt.callLater(function () {
|
||||
@@ -122,10 +119,10 @@ DankPopout {
|
||||
onBackgroundClicked: hide()
|
||||
|
||||
onShouldBeVisibleChanged: {
|
||||
if (!shouldBeVisible) {
|
||||
if (!shouldBeVisible)
|
||||
return;
|
||||
}
|
||||
ClipboardService.refresh();
|
||||
if (clipboardAvailable)
|
||||
ClipboardService.refresh();
|
||||
keyboardController.reset();
|
||||
Qt.callLater(function () {
|
||||
if (contentLoader.item?.searchField) {
|
||||
|
||||
@@ -352,7 +352,8 @@ Item {
|
||||
searchQuery = query;
|
||||
searchDebounce.restart();
|
||||
|
||||
if (searchMode !== "plugins" && (searchMode === "files" || query.startsWith("/")) && query.length > 0) {
|
||||
var filesInAll = searchMode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll);
|
||||
if (searchMode !== "plugins" && (searchMode === "files" || query.startsWith("/") || filesInAll) && query.length > 0) {
|
||||
fileSearchDebounce.restart();
|
||||
}
|
||||
}
|
||||
@@ -369,7 +370,8 @@ Item {
|
||||
searchMode = mode;
|
||||
modeChanged(mode);
|
||||
performSearch();
|
||||
if (mode === "files") {
|
||||
var filesInAll = mode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll) && searchQuery.length > 0;
|
||||
if (mode === "files" || filesInAll) {
|
||||
fileSearchDebounce.restart();
|
||||
}
|
||||
}
|
||||
@@ -927,10 +929,22 @@ Item {
|
||||
if (!DSearchService.dsearchAvailable)
|
||||
return;
|
||||
var fileQuery = "";
|
||||
var effectiveType = fileSearchType || "all";
|
||||
var includeFiles = SettingsData.dankLauncherV2IncludeFilesInAll;
|
||||
var includeFolders = SettingsData.dankLauncherV2IncludeFoldersInAll;
|
||||
|
||||
if (searchQuery.startsWith("/")) {
|
||||
fileQuery = searchQuery.substring(1).trim();
|
||||
} else if (searchMode === "files") {
|
||||
fileQuery = searchQuery.trim();
|
||||
} else if (searchMode === "all" && (includeFiles || includeFolders)) {
|
||||
fileQuery = searchQuery.trim();
|
||||
if (includeFiles && !includeFolders)
|
||||
effectiveType = "file";
|
||||
else if (!includeFiles && includeFolders)
|
||||
effectiveType = "dir";
|
||||
else
|
||||
effectiveType = "all";
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -941,109 +955,129 @@ Item {
|
||||
}
|
||||
|
||||
isFileSearching = true;
|
||||
var params = {
|
||||
limit: 20,
|
||||
fuzzy: true,
|
||||
sort: fileSearchSort || "score",
|
||||
desc: true
|
||||
};
|
||||
|
||||
if (DSearchService.supportsTypeFilter) {
|
||||
params.type = (fileSearchType && fileSearchType !== "all") ? fileSearchType : "all";
|
||||
}
|
||||
if (fileSearchExt) {
|
||||
params.ext = fileSearchExt;
|
||||
}
|
||||
if (fileSearchFolder) {
|
||||
params.folder = fileSearchFolder;
|
||||
}
|
||||
var splitBothTypes = searchMode === "all" && includeFiles && includeFolders && DSearchService.supportsTypeFilter;
|
||||
var queryTypes = splitBothTypes ? ["file", "dir"] : [effectiveType];
|
||||
var pending = queryTypes.length;
|
||||
var aggregatedItems = [];
|
||||
|
||||
DSearchService.search(fileQuery, params, function (response) {
|
||||
isFileSearching = false;
|
||||
if (response.error)
|
||||
return;
|
||||
var fileItems = [];
|
||||
var hits = response.result?.hits || [];
|
||||
for (var t = 0; t < queryTypes.length; t++) {
|
||||
var queryType = queryTypes[t];
|
||||
var params = {
|
||||
limit: 20,
|
||||
fuzzy: true,
|
||||
sort: fileSearchSort || "score",
|
||||
desc: true
|
||||
};
|
||||
|
||||
for (var i = 0; i < hits.length; i++) {
|
||||
var hit = hits[i];
|
||||
var docTypes = hit.locations?.doc_type;
|
||||
var isDir = docTypes ? !!docTypes["dir"] : false;
|
||||
fileItems.push(transformFileResult({
|
||||
path: hit.id || "",
|
||||
score: hit.score || 0,
|
||||
is_dir: isDir
|
||||
}));
|
||||
if (DSearchService.supportsTypeFilter) {
|
||||
params.type = (queryType && queryType !== "all") ? queryType : "all";
|
||||
}
|
||||
if (fileSearchExt) {
|
||||
params.ext = fileSearchExt;
|
||||
}
|
||||
if (fileSearchFolder) {
|
||||
params.folder = fileSearchFolder;
|
||||
}
|
||||
|
||||
var fileSections = [];
|
||||
var showType = fileSearchType || "all";
|
||||
DSearchService.search(fileQuery, params, function (response) {
|
||||
pending--;
|
||||
if (!response.error) {
|
||||
var hits = response.result?.hits || [];
|
||||
for (var i = 0; i < hits.length; i++) {
|
||||
var hit = hits[i];
|
||||
var docTypes = hit.locations?.doc_type;
|
||||
var isDir = docTypes ? !!docTypes["dir"] : false;
|
||||
aggregatedItems.push(transformFileResult({
|
||||
path: hit.id || "",
|
||||
score: hit.score || 0,
|
||||
is_dir: isDir
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (pending > 0)
|
||||
return;
|
||||
|
||||
if (showType === "all" && DSearchService.supportsTypeFilter) {
|
||||
var onlyFiles = [];
|
||||
var onlyDirs = [];
|
||||
for (var j = 0; j < fileItems.length; j++) {
|
||||
if (fileItems[j].data?.is_dir)
|
||||
onlyDirs.push(fileItems[j]);
|
||||
else
|
||||
onlyFiles.push(fileItems[j]);
|
||||
}
|
||||
if (onlyFiles.length > 0) {
|
||||
fileSections.push({
|
||||
id: "files",
|
||||
title: I18n.tr("Files"),
|
||||
icon: "insert_drive_file",
|
||||
priority: 4,
|
||||
items: onlyFiles,
|
||||
collapsed: collapsedSections["files"] || false,
|
||||
flatStartIndex: 0
|
||||
});
|
||||
}
|
||||
if (onlyDirs.length > 0) {
|
||||
fileSections.push({
|
||||
id: "folders",
|
||||
title: I18n.tr("Folders"),
|
||||
icon: "folder",
|
||||
priority: 4.1,
|
||||
items: onlyDirs,
|
||||
collapsed: collapsedSections["folders"] || false,
|
||||
flatStartIndex: 0
|
||||
});
|
||||
}
|
||||
} else {
|
||||
var filesIcon = showType === "dir" ? "folder" : showType === "file" ? "insert_drive_file" : "folder";
|
||||
var filesTitle = showType === "dir" ? I18n.tr("Folders") : I18n.tr("Files");
|
||||
if (fileItems.length > 0) {
|
||||
fileSections.push({
|
||||
id: "files",
|
||||
title: filesTitle,
|
||||
icon: filesIcon,
|
||||
priority: 4,
|
||||
items: fileItems,
|
||||
collapsed: collapsedSections["files"] || false,
|
||||
flatStartIndex: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var newSections;
|
||||
if (searchMode === "files") {
|
||||
newSections = fileSections;
|
||||
} else {
|
||||
var existingNonFile = sections.filter(function (s) {
|
||||
return s.id !== "files" && s.id !== "folders";
|
||||
});
|
||||
newSections = existingNonFile.concat(fileSections);
|
||||
}
|
||||
newSections.sort(function (a, b) {
|
||||
return a.priority - b.priority;
|
||||
isFileSearching = false;
|
||||
_applyFileSearchResults(aggregatedItems, effectiveType);
|
||||
});
|
||||
_applyHighlights(newSections, searchQuery);
|
||||
flatModel = Scorer.flattenSections(newSections);
|
||||
sections = newSections;
|
||||
selectedFlatIndex = getFirstItemIndex();
|
||||
updateSelectedItem();
|
||||
}
|
||||
}
|
||||
|
||||
function _applyFileSearchResults(fileItems, effectiveType) {
|
||||
var fileSections = [];
|
||||
var showType = effectiveType;
|
||||
var order = SettingsData.launcherPluginOrder || [];
|
||||
var filesOrderIdx = order.indexOf("__files");
|
||||
var foldersOrderIdx = order.indexOf("__folders");
|
||||
var filesPriority = filesOrderIdx !== -1 ? 2.6 + filesOrderIdx * 0.01 : 4;
|
||||
var foldersPriority = foldersOrderIdx !== -1 ? 2.6 + foldersOrderIdx * 0.01 : 4.1;
|
||||
|
||||
if (showType === "all" && DSearchService.supportsTypeFilter) {
|
||||
var onlyFiles = [];
|
||||
var onlyDirs = [];
|
||||
for (var j = 0; j < fileItems.length; j++) {
|
||||
if (fileItems[j].data?.is_dir)
|
||||
onlyDirs.push(fileItems[j]);
|
||||
else
|
||||
onlyFiles.push(fileItems[j]);
|
||||
}
|
||||
if (onlyFiles.length > 0) {
|
||||
fileSections.push({
|
||||
id: "files",
|
||||
title: I18n.tr("Files"),
|
||||
icon: "insert_drive_file",
|
||||
priority: filesPriority,
|
||||
items: onlyFiles,
|
||||
collapsed: collapsedSections["files"] || false,
|
||||
flatStartIndex: 0
|
||||
});
|
||||
}
|
||||
if (onlyDirs.length > 0) {
|
||||
fileSections.push({
|
||||
id: "folders",
|
||||
title: I18n.tr("Folders"),
|
||||
icon: "folder",
|
||||
priority: foldersPriority,
|
||||
items: onlyDirs,
|
||||
collapsed: collapsedSections["folders"] || false,
|
||||
flatStartIndex: 0
|
||||
});
|
||||
}
|
||||
} else {
|
||||
var filesIcon = showType === "dir" ? "folder" : showType === "file" ? "insert_drive_file" : "folder";
|
||||
var filesTitle = showType === "dir" ? I18n.tr("Folders") : I18n.tr("Files");
|
||||
var singlePriority = showType === "dir" ? foldersPriority : filesPriority;
|
||||
if (fileItems.length > 0) {
|
||||
fileSections.push({
|
||||
id: "files",
|
||||
title: filesTitle,
|
||||
icon: filesIcon,
|
||||
priority: singlePriority,
|
||||
items: fileItems,
|
||||
collapsed: collapsedSections["files"] || false,
|
||||
flatStartIndex: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var newSections;
|
||||
if (searchMode === "files") {
|
||||
newSections = fileSections;
|
||||
} else {
|
||||
var existingNonFile = sections.filter(function (s) {
|
||||
return s.id !== "files" && s.id !== "folders";
|
||||
});
|
||||
newSections = existingNonFile.concat(fileSections);
|
||||
}
|
||||
newSections.sort(function (a, b) {
|
||||
return a.priority - b.priority;
|
||||
});
|
||||
_applyHighlights(newSections, searchQuery);
|
||||
flatModel = Scorer.flattenSections(newSections);
|
||||
sections = newSections;
|
||||
selectedFlatIndex = getFirstItemIndex();
|
||||
updateSelectedItem();
|
||||
}
|
||||
|
||||
function searchApps(query) {
|
||||
@@ -1276,7 +1310,11 @@ Item {
|
||||
function buildDynamicSectionDefs(items) {
|
||||
var baseDefs = sectionDefinitions.slice();
|
||||
var pluginSections = {};
|
||||
var basePriority = 2.6;
|
||||
var order = SettingsData.launcherPluginOrder || [];
|
||||
var orderMap = {};
|
||||
for (var k = 0; k < order.length; k++)
|
||||
orderMap[order[k]] = k;
|
||||
var unorderedPriority = 2.6 + order.length * 0.01;
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var section = items[i].section;
|
||||
@@ -1287,19 +1325,25 @@ Item {
|
||||
var pluginId = section.substring(7);
|
||||
var meta = getPluginMetadata(pluginId);
|
||||
var viewPref = getPluginViewPref(pluginId);
|
||||
var orderIdx = orderMap[pluginId];
|
||||
var priority;
|
||||
if (orderIdx !== undefined) {
|
||||
priority = 2.6 + orderIdx * 0.01;
|
||||
} else {
|
||||
priority = unorderedPriority;
|
||||
unorderedPriority += 0.01;
|
||||
}
|
||||
|
||||
pluginSections[section] = {
|
||||
id: section,
|
||||
title: meta.name,
|
||||
icon: meta.icon,
|
||||
priority: basePriority,
|
||||
priority: priority,
|
||||
defaultViewMode: viewPref.mode || "list"
|
||||
};
|
||||
|
||||
if (viewPref.mode)
|
||||
setPluginViewPreference(section, viewPref.mode, viewPref.enforced);
|
||||
|
||||
basePriority += 0.01;
|
||||
}
|
||||
|
||||
for (var sectionId in pluginSections) {
|
||||
|
||||
@@ -58,7 +58,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
property bool enabled: isInstance ? (instanceData?.enabled ?? true) : SettingsData.desktopClockEnabled
|
||||
enabled: isInstance ? (instanceData?.enabled ?? true) : SettingsData.desktopClockEnabled
|
||||
property real transparency: isInstance ? (cfg.transparency ?? 0.8) : SettingsData.desktopClockTransparency
|
||||
property string colorMode: isInstance ? (cfg.colorMode ?? "primary") : SettingsData.desktopClockColorMode
|
||||
property color customColor: isInstance ? (cfg.customColor ?? "#ffffff") : SettingsData.desktopClockCustomColor
|
||||
|
||||
@@ -37,7 +37,7 @@ Item {
|
||||
readonly property var cfg: instanceData?.config ?? null
|
||||
readonly property bool isInstance: instanceId !== "" && cfg !== null
|
||||
|
||||
property bool enabled: isInstance ? (instanceData?.enabled ?? true) : SettingsData.systemMonitorEnabled
|
||||
enabled: isInstance ? (instanceData?.enabled ?? true) : SettingsData.systemMonitorEnabled
|
||||
property bool showHeader: isInstance ? (cfg.showHeader ?? true) : SettingsData.systemMonitorShowHeader
|
||||
property real transparency: isInstance ? (cfg.transparency ?? 0.8) : SettingsData.systemMonitorTransparency
|
||||
property string colorMode: isInstance ? (cfg.colorMode ?? "primary") : SettingsData.systemMonitorColorMode
|
||||
|
||||
@@ -12,7 +12,6 @@ Rectangle {
|
||||
property string text: ""
|
||||
property string secondaryText: ""
|
||||
property bool isActive: false
|
||||
property bool enabled: true
|
||||
property int widgetIndex: 0
|
||||
property var widgetData: null
|
||||
property bool editMode: false
|
||||
|
||||
@@ -14,7 +14,6 @@ Rectangle {
|
||||
property real value: 0.0
|
||||
property real maximumValue: 1.0
|
||||
property real minimumValue: 0.0
|
||||
property bool enabled: true
|
||||
|
||||
signal sliderValueChanged(real value)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Rectangle {
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
property bool isActive: BatteryService.batteryAvailable && (BatteryService.isCharging || BatteryService.isPluggedIn)
|
||||
property bool enabled: BatteryService.batteryAvailable
|
||||
enabled: BatteryService.batteryAvailable
|
||||
|
||||
signal clicked
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ Rectangle {
|
||||
return parseFloat(selectedMount.percent.replace("%", "")) || 0;
|
||||
}
|
||||
|
||||
property bool enabled: DgopService.dgopAvailable
|
||||
enabled: DgopService.dgopAvailable
|
||||
|
||||
signal clicked
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ Rectangle {
|
||||
|
||||
property string iconName: ""
|
||||
property bool isActive: false
|
||||
property bool enabled: true
|
||||
property real iconRotation: 0
|
||||
|
||||
signal clicked
|
||||
|
||||
@@ -11,7 +11,6 @@ Rectangle {
|
||||
property string iconName: ""
|
||||
property string text: ""
|
||||
property bool isActive: false
|
||||
property bool enabled: true
|
||||
property string secondaryText: ""
|
||||
property real iconRotation: 0
|
||||
|
||||
|
||||
@@ -969,6 +969,7 @@ Item {
|
||||
axis: barWindow.axis
|
||||
barSpacing: barConfig?.spacing ?? 4
|
||||
barConfig: topBarContent.barConfig
|
||||
widgetData: parent.widgetData
|
||||
isAutoHideBar: topBarContent.barConfig?.autoHide ?? false
|
||||
isAtBottom: barWindow.axis?.edge === "bottom"
|
||||
visible: SettingsData.getFilteredScreens("systemTray").includes(barWindow.screen) && SystemTray.items.values.length > 0
|
||||
@@ -1437,12 +1438,21 @@ Item {
|
||||
parentScreen: barWindow.screen
|
||||
onClicked: {
|
||||
systemUpdateLoader.active = true;
|
||||
if (!systemUpdateLoader.item)
|
||||
return;
|
||||
const popout = systemUpdateLoader.item;
|
||||
const effectiveBarConfig = topBarContent.barConfig;
|
||||
const barPosition = barWindow.axis?.edge === "left" ? 2 : (barWindow.axis?.edge === "right" ? 3 : (barWindow.axis?.edge === "top" ? 0 : 1));
|
||||
if (systemUpdateLoader.item && systemUpdateLoader.item.setBarContext) {
|
||||
systemUpdateLoader.item.setBarContext(barPosition, effectiveBarConfig?.bottomGap ?? 0);
|
||||
if (popout.setBarContext) {
|
||||
popout.setBarContext(barPosition, effectiveBarConfig?.bottomGap ?? 0);
|
||||
}
|
||||
systemUpdateLoader.item?.toggle();
|
||||
if (popout.setTriggerPosition) {
|
||||
const globalPos = visualContent.mapToItem(null, 0, 0);
|
||||
const currentScreen = parentScreen || Screen;
|
||||
const pos = SettingsData.getPopupTriggerPosition(globalPos, currentScreen, barWindow.effectiveBarThickness, visualWidth, effectiveBarConfig?.spacing ?? 4, barPosition, effectiveBarConfig);
|
||||
popout.setTriggerPosition(pos.x, pos.y, pos.width, section, currentScreen, barPosition, barWindow.effectiveBarThickness, effectiveBarConfig?.spacing ?? 4, effectiveBarConfig);
|
||||
}
|
||||
PopoutManager.requestPopout(popout, undefined, "systemUpdate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import Quickshell.Services.UPower
|
||||
import qs.Common
|
||||
import qs.Modules.Plugins
|
||||
import qs.Services
|
||||
@@ -10,6 +11,8 @@ BasePill {
|
||||
property bool batteryPopupVisible: false
|
||||
property var popoutTarget: null
|
||||
|
||||
property real touchpadAccumulator: 0
|
||||
|
||||
readonly property int barPosition: {
|
||||
switch (axis?.edge) {
|
||||
case "top":
|
||||
@@ -119,5 +122,44 @@ BasePill {
|
||||
battery.triggerRipple(this, mouse.x, mouse.y);
|
||||
toggleBatteryPopup();
|
||||
}
|
||||
onWheel: wheel => {
|
||||
var delta = wheel.angleDelta.y;
|
||||
if (delta === 0)
|
||||
return;
|
||||
|
||||
// Check if this is a touchpad
|
||||
if (delta !== 120 && delta !== -120) {
|
||||
touchpadAccumulator += delta;
|
||||
console.info("Acc: "+touchpadAccumulator);
|
||||
if (Math.abs(touchpadAccumulator) < 500)
|
||||
return;
|
||||
delta = touchpadAccumulator;
|
||||
touchpadAccumulator = 0;
|
||||
}
|
||||
console.info("Trigger! Delta: "+delta)
|
||||
|
||||
// This is after the other delta checks so it only shows on valid Y scroll
|
||||
if (typeof PowerProfiles === "undefined") {
|
||||
ToastService.showError("power-profiles-daemon not available");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get list of profiles, and current index
|
||||
const profiles = [PowerProfile.PowerSaver, PowerProfile.Balanced].concat(PowerProfiles.hasPerformanceProfile ? [PowerProfile.Performance] : []);
|
||||
var index = profiles.findIndex(profile => PowerProfiles.profile === profile);
|
||||
|
||||
// Step once based on mouse wheel direction
|
||||
if (delta > 0) index += 1;
|
||||
else index -= 1;
|
||||
|
||||
// Already at end of list, can't go further
|
||||
if (index < 0 || index >= profiles.length) return;
|
||||
|
||||
// Set new profile
|
||||
PowerProfiles.profile = profiles[index];
|
||||
if (PowerProfiles.profile !== profiles[index]) {
|
||||
ToastService.showError("Failed to set power profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ BasePill {
|
||||
StyledTextMetrics {
|
||||
id: cpuBaseline
|
||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText)
|
||||
text: "88%"
|
||||
text: "100%"
|
||||
}
|
||||
|
||||
StyledTextMetrics {
|
||||
|
||||
@@ -17,7 +17,7 @@ BasePill {
|
||||
property int availableWidth: 400
|
||||
readonly property int maxNormalWidth: 456
|
||||
readonly property int maxCompactWidth: 288
|
||||
readonly property Toplevel activeWindow: ToplevelManager.activeToplevel
|
||||
property Toplevel activeWindow: null
|
||||
property var activeDesktopEntry: null
|
||||
property bool isHovered: mouseArea.containsMouse
|
||||
property bool isAutoHideBar: false
|
||||
@@ -38,10 +38,44 @@ BasePill {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function updateActiveWindow() {
|
||||
const active = ToplevelManager.activeToplevel;
|
||||
|
||||
if (!active) {
|
||||
// Only clear if our tracked window is no longer alive
|
||||
if (activeWindow) {
|
||||
const alive = ToplevelManager.toplevels?.values;
|
||||
if (alive && !Array.from(alive).some(t => t === activeWindow))
|
||||
activeWindow = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parentScreen || CompositorService.filterCurrentDisplay([active], parentScreen?.name)?.length > 0) {
|
||||
activeWindow = active;
|
||||
}
|
||||
// else: active window is on a different screen so keep the previous value
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
updateActiveWindow();
|
||||
updateDesktopEntry();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ToplevelManager
|
||||
function onActiveToplevelChanged() {
|
||||
root.updateActiveWindow();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: CompositorService
|
||||
function onToplevelsChanged() {
|
||||
root.updateActiveWindow();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: DesktopEntries
|
||||
function onApplicationsChanged() {
|
||||
|
||||
@@ -19,7 +19,8 @@ BasePill {
|
||||
readonly property bool usePlayerVolume: activePlayer && activePlayer.volumeSupported && !__isChromeBrowser
|
||||
property bool compactMode: false
|
||||
property var widgetData: null
|
||||
readonly property int textWidth: {
|
||||
readonly property bool adaptiveWidthEnabled: SettingsData.mediaAdaptiveWidthEnabled
|
||||
readonly property int maxTextWidth: {
|
||||
const size = widgetData?.mediaSize !== undefined ? widgetData.mediaSize : SettingsData.mediaSize;
|
||||
switch (size) {
|
||||
case 0:
|
||||
@@ -36,10 +37,7 @@ BasePill {
|
||||
if (isVerticalOrientation) {
|
||||
return widgetThickness - horizontalPadding * 2;
|
||||
}
|
||||
const controlsWidth = 20 + Theme.spacingXS + 24 + Theme.spacingXS + 20;
|
||||
const audioVizWidth = 20;
|
||||
const contentWidth = audioVizWidth + Theme.spacingXS + controlsWidth;
|
||||
return contentWidth + (textWidth > 0 ? textWidth + Theme.spacingXS : 0);
|
||||
return 0;
|
||||
}
|
||||
readonly property int currentContentHeight: {
|
||||
if (!isVerticalOrientation) {
|
||||
@@ -99,7 +97,7 @@ BasePill {
|
||||
|
||||
if (isMouseWheelY) {
|
||||
if (deltaY > 0) {
|
||||
activePlayer.previous();
|
||||
MprisController.previousOrRewind();
|
||||
} else {
|
||||
activePlayer.next();
|
||||
}
|
||||
@@ -107,7 +105,7 @@ BasePill {
|
||||
scrollAccumulatorY += deltaY;
|
||||
if (Math.abs(scrollAccumulatorY) >= touchpadThreshold) {
|
||||
if (scrollAccumulatorY > 0) {
|
||||
activePlayer.previous();
|
||||
MprisController.previousOrRewind();
|
||||
} else {
|
||||
activePlayer.next();
|
||||
}
|
||||
@@ -119,7 +117,28 @@ BasePill {
|
||||
|
||||
content: Component {
|
||||
Item {
|
||||
implicitWidth: root.playerAvailable ? root.currentContentWidth : 0
|
||||
id: contentRoot
|
||||
readonly property real measuredTextWidth: {
|
||||
if (!root.playerAvailable || root.maxTextWidth <= 0 || !textContainer.visible)
|
||||
return 0;
|
||||
// Preserve the fixed-width text slot even if metadata is briefly empty.
|
||||
if (!root.adaptiveWidthEnabled)
|
||||
return root.maxTextWidth;
|
||||
if (textContainer.displayText.length === 0)
|
||||
return 0;
|
||||
const rawWidth = mediaText.contentWidth;
|
||||
if (!isFinite(rawWidth) || rawWidth <= 0)
|
||||
return 0;
|
||||
return Math.min(root.maxTextWidth, Math.ceil(rawWidth));
|
||||
}
|
||||
readonly property int horizontalContentWidth: {
|
||||
const controlsWidth = 20 + Theme.spacingXS + 24 + Theme.spacingXS + 20;
|
||||
const audioVizWidth = 20;
|
||||
const baseWidth = audioVizWidth + Theme.spacingXS + controlsWidth;
|
||||
return baseWidth + (measuredTextWidth > 0 ? measuredTextWidth + Theme.spacingXS : 0);
|
||||
}
|
||||
|
||||
implicitWidth: root.playerAvailable ? (root.isVerticalOrientation ? root.currentContentWidth : horizontalContentWidth) : 0
|
||||
implicitHeight: root.playerAvailable ? root.currentContentHeight : 0
|
||||
opacity: root.playerAvailable ? 1 : 0
|
||||
|
||||
@@ -132,8 +151,9 @@ BasePill {
|
||||
|
||||
Behavior on implicitWidth {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
duration: Theme.mediumDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasizedDecel
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +234,7 @@ BasePill {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
activePlayer.togglePlaying();
|
||||
} else if (mouse.button === Qt.MiddleButton) {
|
||||
activePlayer.previous();
|
||||
MprisController.previousOrRewind();
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
activePlayer.next();
|
||||
}
|
||||
@@ -269,7 +289,7 @@ BasePill {
|
||||
}
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: textWidth
|
||||
width: contentRoot.measuredTextWidth
|
||||
height: root.widgetThickness
|
||||
visible: {
|
||||
const size = widgetData?.mediaSize !== undefined ? widgetData.mediaSize : SettingsData.mediaSize;
|
||||
@@ -278,50 +298,95 @@ BasePill {
|
||||
clip: true
|
||||
color: "transparent"
|
||||
|
||||
StyledText {
|
||||
id: mediaText
|
||||
property bool needsScrolling: implicitWidth > textContainer.width && SettingsData.scrollTitleEnabled
|
||||
property real scrollOffset: 0
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: textContainer.displayText
|
||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText)
|
||||
color: Theme.widgetTextColor
|
||||
wrapMode: Text.NoWrap
|
||||
x: needsScrolling ? -scrollOffset : 0
|
||||
onTextChanged: {
|
||||
scrollOffset = 0;
|
||||
scrollAnimation.restart();
|
||||
Behavior on width {
|
||||
NumberAnimation {
|
||||
duration: Theme.mediumDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasizedDecel
|
||||
}
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
id: scrollAnimation
|
||||
running: mediaText.needsScrolling && textContainer.visible
|
||||
loops: Animation.Infinite
|
||||
Item {
|
||||
id: textClip
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
|
||||
PauseAnimation {
|
||||
duration: 2000
|
||||
StyledText {
|
||||
id: mediaText
|
||||
property bool needsScrolling: implicitWidth > textContainer.width && SettingsData.scrollTitleEnabled
|
||||
property real scrollOffset: 0
|
||||
property real textShift: 0
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: textContainer.displayText
|
||||
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText)
|
||||
color: Theme.widgetTextColor
|
||||
wrapMode: Text.NoWrap
|
||||
x: (needsScrolling ? -scrollOffset : 0) + textShift
|
||||
opacity: 1
|
||||
|
||||
onTextChanged: {
|
||||
scrollOffset = 0;
|
||||
textShift = 0;
|
||||
scrollAnimation.restart();
|
||||
textChangeAnimation.restart();
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: mediaText
|
||||
property: "scrollOffset"
|
||||
from: 0
|
||||
to: mediaText.implicitWidth - textContainer.width + 5
|
||||
duration: Math.max(1000, (mediaText.implicitWidth - textContainer.width + 5) * 60)
|
||||
easing.type: Easing.Linear
|
||||
SequentialAnimation {
|
||||
id: scrollAnimation
|
||||
running: mediaText.needsScrolling && textContainer.visible
|
||||
loops: Animation.Infinite
|
||||
|
||||
PauseAnimation {
|
||||
duration: 2000
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: mediaText
|
||||
property: "scrollOffset"
|
||||
from: 0
|
||||
to: mediaText.implicitWidth - textContainer.width + 5
|
||||
duration: Math.max(1000, (mediaText.implicitWidth - textContainer.width + 5) * 60)
|
||||
easing.type: Easing.Linear
|
||||
}
|
||||
|
||||
PauseAnimation {
|
||||
duration: 2000
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: mediaText
|
||||
property: "scrollOffset"
|
||||
to: 0
|
||||
duration: Math.max(1000, (mediaText.implicitWidth - textContainer.width + 5) * 60)
|
||||
easing.type: Easing.Linear
|
||||
}
|
||||
}
|
||||
|
||||
PauseAnimation {
|
||||
duration: 2000
|
||||
}
|
||||
SequentialAnimation {
|
||||
id: textChangeAnimation
|
||||
|
||||
NumberAnimation {
|
||||
target: mediaText
|
||||
property: "scrollOffset"
|
||||
to: 0
|
||||
duration: Math.max(1000, (mediaText.implicitWidth - textContainer.width + 5) * 60)
|
||||
easing.type: Easing.Linear
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: mediaText
|
||||
property: "opacity"
|
||||
from: 0.7
|
||||
to: 1
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasizedDecel
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: mediaText
|
||||
property: "textShift"
|
||||
from: 4
|
||||
to: 0
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasizedDecel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,11 +435,7 @@ BasePill {
|
||||
anchors.fill: parent
|
||||
enabled: root.playerAvailable
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (activePlayer) {
|
||||
activePlayer.previous();
|
||||
}
|
||||
}
|
||||
onClicked: MprisController.previousOrRewind()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ BasePill {
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (isFocused) {
|
||||
return mouseArea.containsMouse ? Theme.primarySelected : Theme.withAlpha(Theme.primary, 0.2);
|
||||
return mouseArea.containsMouse ? Theme.primarySelected : Theme.withAlpha(Theme.primary, 0.45);
|
||||
}
|
||||
return mouseArea.containsMouse ? BlurService.hoverColor(Theme.widgetBaseHoverColor) : "transparent";
|
||||
}
|
||||
@@ -526,7 +526,7 @@ BasePill {
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (isFocused) {
|
||||
return mouseArea.containsMouse ? Theme.primarySelected : Theme.withAlpha(Theme.primary, 0.2);
|
||||
return mouseArea.containsMouse ? Theme.primarySelected : Theme.withAlpha(Theme.primary, 0.45);
|
||||
}
|
||||
return mouseArea.containsMouse ? BlurService.hoverColor(Theme.widgetBaseHoverColor) : "transparent";
|
||||
}
|
||||
|
||||
@@ -16,8 +16,11 @@ BasePill {
|
||||
enableCursor: false
|
||||
|
||||
property var parentWindow: null
|
||||
property var widgetData: null
|
||||
property string section: "right"
|
||||
property bool isAtBottom: false
|
||||
property bool isAutoHideBar: false
|
||||
property bool useOverflowPopup: !widgetData?.trayUseInlineExpansion
|
||||
readonly property var hiddenTrayIds: {
|
||||
const envValue = Quickshell.env("DMS_HIDE_TRAYIDS") || "";
|
||||
return envValue ? envValue.split(",").map(id => id.trim().toLowerCase()) : [];
|
||||
@@ -40,6 +43,76 @@ BasePill {
|
||||
return `${id}::${tooltipTitle}`;
|
||||
}
|
||||
|
||||
function trayIconSourceFor(trayItem) {
|
||||
let icon = trayItem && trayItem.icon;
|
||||
if (typeof icon === 'string' || icon instanceof String) {
|
||||
if (icon === "")
|
||||
return "";
|
||||
if (icon.includes("?path=")) {
|
||||
const split = icon.split("?path=");
|
||||
if (split.length !== 2)
|
||||
return icon;
|
||||
const name = split[0];
|
||||
const path = split[1];
|
||||
let fileName = name.substring(name.lastIndexOf("/") + 1);
|
||||
if (fileName.startsWith("dropboxstatus")) {
|
||||
fileName = `hicolor/16x16/status/${fileName}`;
|
||||
}
|
||||
return `file://${path}/${fileName}`;
|
||||
}
|
||||
if (icon.startsWith("/") && !icon.startsWith("file://"))
|
||||
return `file://${icon}`;
|
||||
return icon;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function activateInlineTrayItem(trayItem, anchorItem) {
|
||||
if (!trayItem)
|
||||
return;
|
||||
if (!trayItem.onlyMenu) {
|
||||
trayItem.activate();
|
||||
return;
|
||||
}
|
||||
if (!trayItem.hasMenu)
|
||||
return;
|
||||
root.showForTrayItem(trayItem, anchorItem, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
|
||||
}
|
||||
|
||||
function openInlineTrayContextMenu(trayItem, areaItem, mouse, anchorItem) {
|
||||
if (!trayItem) {
|
||||
return;
|
||||
}
|
||||
if (!trayItem.hasMenu) {
|
||||
const gp = areaItem.mapToGlobal(mouse.x, mouse.y);
|
||||
root.callContextMenuFallback(trayItem.id, Math.round(gp.x), Math.round(gp.y));
|
||||
return;
|
||||
}
|
||||
root.showForTrayItem(trayItem, anchorItem, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
|
||||
}
|
||||
|
||||
function toggleIconName() {
|
||||
const edge = root.axis?.edge;
|
||||
if (root.useOverflowPopup) {
|
||||
switch (edge) {
|
||||
case "left":
|
||||
return root.menuOpen ? "keyboard_arrow_left" : "keyboard_arrow_right";
|
||||
case "right":
|
||||
return root.menuOpen ? "keyboard_arrow_right" : "keyboard_arrow_left";
|
||||
case "bottom":
|
||||
return root.menuOpen ? "keyboard_arrow_down" : "keyboard_arrow_up";
|
||||
case "top":
|
||||
return root.menuOpen ? "keyboard_arrow_up" : "keyboard_arrow_down";
|
||||
}
|
||||
}
|
||||
|
||||
if (edge === "left" || edge === "right") {
|
||||
return root.menuOpen == (root.section !== "right") ? "keyboard_arrow_up" : "keyboard_arrow_down";
|
||||
}
|
||||
|
||||
return root.menuOpen != (root.section === "right") ? "keyboard_arrow_left" : "keyboard_arrow_right";
|
||||
}
|
||||
|
||||
// ! TODO - replace with either native dbus client (like plugins use) or just a DMS cli or something
|
||||
function callContextMenuFallback(trayItemId, globalX, globalY) {
|
||||
const script = ['ITEMS=$(dbus-send --session --print-reply --dest=org.kde.StatusNotifierWatcher /StatusNotifierWatcher org.freedesktop.DBus.Properties.Get string:org.kde.StatusNotifierWatcher string:RegisteredStatusNotifierItems 2>/dev/null)', 'while IFS= read -r line; do', ' line="${line#*\\\"}"', ' line="${line%\\\"*}"', ' [ -z "$line" ] && continue', ' BUS="${line%%/*}"', ' OBJ="/${line#*/}"', ' ID=$(dbus-send --session --print-reply --dest="$BUS" "$OBJ" org.freedesktop.DBus.Properties.Get string:org.kde.StatusNotifierItem string:Id 2>/dev/null | grep -oP "(?<=\\\")(.*?)(?=\\\")" | tail -1)', ' if [ "$ID" = "$1" ]; then', ' dbus-send --session --type=method_call --dest="$BUS" "$OBJ" org.kde.StatusNotifierItem.ContextMenu int32:"$2" int32:"$3"', ' exit 0', ' fi', 'done <<< "$ITEMS"',].join("\n");
|
||||
@@ -78,6 +151,13 @@ BasePill {
|
||||
item: item
|
||||
}))
|
||||
readonly property var hiddenBarItems: allSortedTrayItems.filter(item => SessionData.isHiddenTrayId(root.getTrayItemKey(item)))
|
||||
readonly property bool reverseInlineHorizontal: !useOverflowPopup && !isVerticalOrientation && section === "right"
|
||||
readonly property bool reverseInlineVertical: !useOverflowPopup && isVerticalOrientation && section === "right"
|
||||
readonly property var displayedMainBarItems: reverseInlineHorizontal ? [...mainBarItems].reverse() : mainBarItems
|
||||
readonly property var displayedInlineExpandedItems: (reverseInlineHorizontal ? [...hiddenBarItems].reverse() : hiddenBarItems).map(item => ({
|
||||
key: getTrayItemKey(item),
|
||||
item: item
|
||||
}))
|
||||
|
||||
function moveTrayItemInFullOrder(visibleFromIndex, visibleToIndex) {
|
||||
if (visibleFromIndex === visibleToIndex || visibleFromIndex < 0 || visibleToIndex < 0)
|
||||
@@ -103,6 +183,7 @@ BasePill {
|
||||
property int dropTargetIndex: -1
|
||||
property bool suppressShiftAnimation: false
|
||||
readonly property bool hasHiddenItems: allTrayItems.length > mainBarItems.length
|
||||
readonly property bool inlineExpanded: hasHiddenItems && !useOverflowPopup && menuOpen
|
||||
visible: allTrayItems.length > 0
|
||||
opacity: allTrayItems.length > 0 ? 1 : 0
|
||||
|
||||
@@ -198,10 +279,11 @@ BasePill {
|
||||
id: rowComp
|
||||
Row {
|
||||
spacing: 0
|
||||
layoutDirection: root.reverseInlineHorizontal ? Qt.RightToLeft : Qt.LeftToRight
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: root.mainBarItems
|
||||
values: root.displayedMainBarItems
|
||||
objectProp: "key"
|
||||
}
|
||||
|
||||
@@ -209,29 +291,7 @@ BasePill {
|
||||
id: delegateRoot
|
||||
property var trayItem: modelData.item
|
||||
property string itemKey: modelData.key
|
||||
property string iconSource: {
|
||||
let icon = trayItem && trayItem.icon;
|
||||
if (typeof icon === 'string' || icon instanceof String) {
|
||||
if (icon === "")
|
||||
return "";
|
||||
if (icon.includes("?path=")) {
|
||||
const split = icon.split("?path=");
|
||||
if (split.length !== 2)
|
||||
return icon;
|
||||
const name = split[0];
|
||||
const path = split[1];
|
||||
let fileName = name.substring(name.lastIndexOf("/") + 1);
|
||||
if (fileName.startsWith("dropboxstatus")) {
|
||||
fileName = `hicolor/16x16/status/${fileName}`;
|
||||
}
|
||||
return `file://${path}/${fileName}`;
|
||||
}
|
||||
if (icon.startsWith("/") && !icon.startsWith("file://"))
|
||||
return `file://${icon}`;
|
||||
return icon;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
property string iconSource: root.trayIconSourceFor(trayItem)
|
||||
|
||||
width: root.trayItemSize
|
||||
height: root.barThickness
|
||||
@@ -371,7 +431,8 @@ BasePill {
|
||||
}
|
||||
if (!delegateRoot.trayItem.hasMenu)
|
||||
return;
|
||||
root.menuOpen = false;
|
||||
if (root.useOverflowPopup)
|
||||
root.menuOpen = false;
|
||||
root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
|
||||
}
|
||||
|
||||
@@ -380,8 +441,8 @@ BasePill {
|
||||
const distance = Math.abs(mouse.x - dragHandler.dragStartPos.x);
|
||||
if (distance > 5) {
|
||||
dragHandler.dragging = true;
|
||||
root.draggedIndex = index;
|
||||
root.dropTargetIndex = index;
|
||||
root.draggedIndex = root.reverseInlineHorizontal ? (root.mainBarItems.length - 1 - index) : index;
|
||||
root.dropTargetIndex = root.draggedIndex;
|
||||
}
|
||||
}
|
||||
if (!dragHandler.dragging)
|
||||
@@ -391,7 +452,8 @@ BasePill {
|
||||
dragHandler.dragAxisOffset = axisOffset;
|
||||
const itemSize = root.trayItemSize;
|
||||
const slotOffset = Math.round(axisOffset / itemSize);
|
||||
const newTargetIndex = Math.max(0, Math.min(root.mainBarItems.length - 1, index + slotOffset));
|
||||
const visualTargetIndex = Math.max(0, Math.min(root.mainBarItems.length - 1, index + slotOffset));
|
||||
const newTargetIndex = root.reverseInlineHorizontal ? (root.mainBarItems.length - 1 - visualTargetIndex) : visualTargetIndex;
|
||||
if (newTargetIndex !== root.dropTargetIndex) {
|
||||
root.dropTargetIndex = newTargetIndex;
|
||||
}
|
||||
@@ -407,7 +469,8 @@ BasePill {
|
||||
root.callContextMenuFallback(delegateRoot.trayItem.id, Math.round(gp.x), Math.round(gp.y));
|
||||
return;
|
||||
}
|
||||
root.menuOpen = false;
|
||||
if (root.useOverflowPopup)
|
||||
root.menuOpen = false;
|
||||
root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
|
||||
}
|
||||
}
|
||||
@@ -429,7 +492,7 @@ BasePill {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: root.menuOpen ? "expand_less" : "expand_more"
|
||||
name: root.toggleIconName()
|
||||
size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
color: Theme.widgetTextColor
|
||||
}
|
||||
@@ -451,6 +514,301 @@ BasePill {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: root.displayedInlineExpandedItems
|
||||
objectProp: "key"
|
||||
}
|
||||
|
||||
delegate: inlineExpandedTrayItemDelegate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: inlineExpandedTrayItemDelegate
|
||||
|
||||
Item {
|
||||
property var trayItem: modelData.item
|
||||
property string itemKey: modelData.key
|
||||
property string iconSource: root.trayIconSourceFor(trayItem)
|
||||
|
||||
width: root.isVerticalOrientation ? root.barThickness : (root.inlineExpanded ? root.trayItemSize : 0)
|
||||
height: root.isVerticalOrientation ? (root.inlineExpanded ? root.trayItemSize : 0) : root.barThickness
|
||||
visible: width > 0 || height > 0
|
||||
|
||||
Behavior on width {
|
||||
enabled: !root.isVerticalOrientation
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on height {
|
||||
enabled: root.isVerticalOrientation
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: inlineVisualContent
|
||||
width: root.trayItemSize
|
||||
height: root.trayItemSize
|
||||
x: root.isVerticalOrientation ? Math.round((parent.width - width) / 2) : (root.reverseInlineHorizontal ? parent.width - width : 0)
|
||||
y: root.isVerticalOrientation ? (root.reverseInlineVertical ? parent.height - height : 0) : Math.round((parent.height - height) / 2)
|
||||
radius: Theme.cornerRadius
|
||||
color: inlineTrayItemArea.containsMouse ? BlurService.hoverColor(Theme.widgetBaseHoverColor) : "transparent"
|
||||
opacity: root.inlineExpanded ? 1 : 0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: inlineIconImg
|
||||
anchors.centerIn: parent
|
||||
width: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
height: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
source: iconSource
|
||||
asynchronous: true
|
||||
smooth: true
|
||||
mipmap: true
|
||||
visible: status === Image.Ready
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: !inlineIconImg.visible
|
||||
text: {
|
||||
const itemId = trayItem?.id || "";
|
||||
if (!itemId)
|
||||
return "?";
|
||||
return itemId.charAt(0).toUpperCase();
|
||||
}
|
||||
font.pixelSize: 10
|
||||
color: Theme.widgetTextColor
|
||||
}
|
||||
|
||||
DankRipple {
|
||||
id: inlineItemRipple
|
||||
cornerRadius: Theme.cornerRadius
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: inlineTrayItemArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: root.inlineExpanded
|
||||
|
||||
onPressed: mouse => {
|
||||
const pos = mapToItem(inlineVisualContent, mouse.x, mouse.y);
|
||||
inlineItemRipple.trigger(pos.x, pos.y);
|
||||
}
|
||||
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
root.activateInlineTrayItem(trayItem, inlineVisualContent);
|
||||
return;
|
||||
}
|
||||
if (mouse.button !== Qt.RightButton)
|
||||
return;
|
||||
root.openInlineTrayContextMenu(trayItem, inlineTrayItemArea, mouse, inlineVisualContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: verticalMainTrayItemDelegate
|
||||
|
||||
Item {
|
||||
property var trayItem: modelData.item
|
||||
property string itemKey: modelData.key
|
||||
property string iconSource: root.trayIconSourceFor(trayItem)
|
||||
|
||||
width: root.barThickness
|
||||
height: root.trayItemSize
|
||||
z: dragHandler.dragging ? 100 : 0
|
||||
|
||||
property real shiftOffset: {
|
||||
if (root.draggedIndex < 0)
|
||||
return 0;
|
||||
if (index === root.draggedIndex)
|
||||
return 0;
|
||||
const dragIdx = root.draggedIndex;
|
||||
const dropIdx = root.dropTargetIndex;
|
||||
const shiftAmount = root.trayItemSize;
|
||||
if (dropIdx < 0)
|
||||
return 0;
|
||||
if (dragIdx < dropIdx && index > dragIdx && index <= dropIdx)
|
||||
return -shiftAmount;
|
||||
if (dragIdx > dropIdx && index >= dropIdx && index < dragIdx)
|
||||
return shiftAmount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
transform: Translate {
|
||||
y: shiftOffset
|
||||
Behavior on y {
|
||||
enabled: !root.suppressShiftAnimation
|
||||
NumberAnimation {
|
||||
duration: 150
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: dragHandler
|
||||
anchors.fill: parent
|
||||
property bool dragging: false
|
||||
property point dragStartPos: Qt.point(0, 0)
|
||||
property real dragAxisOffset: 0
|
||||
property bool longPressing: false
|
||||
|
||||
Timer {
|
||||
id: longPressTimer
|
||||
interval: 400
|
||||
repeat: false
|
||||
onTriggered: dragHandler.longPressing = true
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: visualContent
|
||||
width: root.trayItemSize
|
||||
height: root.trayItemSize
|
||||
anchors.centerIn: parent
|
||||
radius: Theme.cornerRadius
|
||||
color: trayItemArea.containsMouse ? BlurService.hoverColor(Theme.widgetBaseHoverColor) : "transparent"
|
||||
border.width: dragHandler.dragging ? 2 : 0
|
||||
border.color: Theme.primary
|
||||
opacity: dragHandler.dragging ? 0.8 : 1.0
|
||||
|
||||
transform: Translate {
|
||||
y: dragHandler.dragging ? dragHandler.dragAxisOffset : 0
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: iconImg
|
||||
anchors.centerIn: parent
|
||||
width: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
height: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
source: iconSource
|
||||
asynchronous: true
|
||||
smooth: true
|
||||
mipmap: true
|
||||
visible: status === Image.Ready
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: !iconImg.visible
|
||||
text: {
|
||||
const itemId = trayItem?.id || "";
|
||||
if (!itemId)
|
||||
return "?";
|
||||
return itemId.charAt(0).toUpperCase();
|
||||
}
|
||||
font.pixelSize: 10
|
||||
color: Theme.widgetTextColor
|
||||
}
|
||||
|
||||
DankRipple {
|
||||
id: itemRipple
|
||||
cornerRadius: Theme.cornerRadius
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: trayItemArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: dragHandler.longPressing ? Qt.DragMoveCursor : Qt.PointingHandCursor
|
||||
|
||||
onPressed: mouse => {
|
||||
const pos = mapToItem(visualContent, mouse.x, mouse.y);
|
||||
itemRipple.trigger(pos.x, pos.y);
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
dragHandler.dragStartPos = Qt.point(mouse.x, mouse.y);
|
||||
longPressTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: mouse => {
|
||||
longPressTimer.stop();
|
||||
const wasDragging = dragHandler.dragging;
|
||||
const didReorder = wasDragging && root.dropTargetIndex >= 0 && root.dropTargetIndex !== root.draggedIndex;
|
||||
|
||||
if (didReorder) {
|
||||
root.suppressShiftAnimation = true;
|
||||
root.moveTrayItemInFullOrder(root.draggedIndex, root.dropTargetIndex);
|
||||
Qt.callLater(() => root.suppressShiftAnimation = false);
|
||||
}
|
||||
|
||||
dragHandler.longPressing = false;
|
||||
dragHandler.dragging = false;
|
||||
dragHandler.dragAxisOffset = 0;
|
||||
root.draggedIndex = -1;
|
||||
root.dropTargetIndex = -1;
|
||||
|
||||
if (wasDragging || mouse.button !== Qt.LeftButton)
|
||||
return;
|
||||
|
||||
if (!trayItem)
|
||||
return;
|
||||
if (!trayItem.onlyMenu) {
|
||||
trayItem.activate();
|
||||
return;
|
||||
}
|
||||
if (!trayItem.hasMenu)
|
||||
return;
|
||||
if (root.useOverflowPopup)
|
||||
root.menuOpen = false;
|
||||
root.showForTrayItem(trayItem, visualContent, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
|
||||
}
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
if (dragHandler.longPressing && !dragHandler.dragging) {
|
||||
const distance = Math.abs(mouse.y - dragHandler.dragStartPos.y);
|
||||
if (distance > 5) {
|
||||
dragHandler.dragging = true;
|
||||
root.draggedIndex = index;
|
||||
root.dropTargetIndex = root.draggedIndex;
|
||||
}
|
||||
}
|
||||
if (!dragHandler.dragging)
|
||||
return;
|
||||
|
||||
const axisOffset = mouse.y - dragHandler.dragStartPos.y;
|
||||
dragHandler.dragAxisOffset = axisOffset;
|
||||
const itemSize = root.trayItemSize;
|
||||
const slotOffset = Math.round(axisOffset / itemSize);
|
||||
const newTargetIndex = Math.max(0, Math.min(root.mainBarItems.length - 1, index + slotOffset));
|
||||
if (newTargetIndex !== root.dropTargetIndex) {
|
||||
root.dropTargetIndex = newTargetIndex;
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: mouse => {
|
||||
if (dragHandler.dragging)
|
||||
return;
|
||||
if (mouse.button !== Qt.RightButton)
|
||||
return;
|
||||
root.openInlineTrayContextMenu(trayItem, trayItemArea, mouse, visualContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,219 +817,23 @@ BasePill {
|
||||
Column {
|
||||
spacing: 0
|
||||
|
||||
// Column lacks layoutDirection, so we use four repeaters with mutually exclusive models to control whether main items or expanded items appear above/ below the toggle button.
|
||||
// When reverseInlineVertical is true the first and third repeaters are empty and the second and fourth are active, and vice-versa.
|
||||
// Because items are swapped between repeaters rather than reversed within a single list, vertical drag-and-drop indices don't need remapping (unlike the horizontal RightToLeft case).
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: root.mainBarItems
|
||||
values: root.reverseInlineVertical ? [] : root.displayedMainBarItems
|
||||
objectProp: "key"
|
||||
}
|
||||
delegate: verticalMainTrayItemDelegate
|
||||
}
|
||||
|
||||
delegate: Item {
|
||||
id: delegateRoot
|
||||
property var trayItem: modelData.item
|
||||
property string itemKey: modelData.key
|
||||
property string iconSource: {
|
||||
let icon = trayItem && trayItem.icon;
|
||||
if (typeof icon === 'string' || icon instanceof String) {
|
||||
if (icon === "")
|
||||
return "";
|
||||
if (icon.includes("?path=")) {
|
||||
const split = icon.split("?path=");
|
||||
if (split.length !== 2)
|
||||
return icon;
|
||||
const name = split[0];
|
||||
const path = split[1];
|
||||
let fileName = name.substring(name.lastIndexOf("/") + 1);
|
||||
if (fileName.startsWith("dropboxstatus")) {
|
||||
fileName = `hicolor/16x16/status/${fileName}`;
|
||||
}
|
||||
return `file://${path}/${fileName}`;
|
||||
}
|
||||
if (icon.startsWith("/") && !icon.startsWith("file://"))
|
||||
return `file://${icon}`;
|
||||
return icon;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
width: root.barThickness
|
||||
height: root.trayItemSize
|
||||
z: dragHandler.dragging ? 100 : 0
|
||||
|
||||
property real shiftOffset: {
|
||||
if (root.draggedIndex < 0)
|
||||
return 0;
|
||||
if (index === root.draggedIndex)
|
||||
return 0;
|
||||
const dragIdx = root.draggedIndex;
|
||||
const dropIdx = root.dropTargetIndex;
|
||||
const shiftAmount = root.trayItemSize;
|
||||
if (dropIdx < 0)
|
||||
return 0;
|
||||
if (dragIdx < dropIdx && index > dragIdx && index <= dropIdx)
|
||||
return -shiftAmount;
|
||||
if (dragIdx > dropIdx && index >= dropIdx && index < dragIdx)
|
||||
return shiftAmount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
transform: Translate {
|
||||
y: delegateRoot.shiftOffset
|
||||
Behavior on y {
|
||||
enabled: !root.suppressShiftAnimation
|
||||
NumberAnimation {
|
||||
duration: 150
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: dragHandler
|
||||
anchors.fill: parent
|
||||
property bool dragging: false
|
||||
property point dragStartPos: Qt.point(0, 0)
|
||||
property real dragAxisOffset: 0
|
||||
property bool longPressing: false
|
||||
|
||||
Timer {
|
||||
id: longPressTimer
|
||||
interval: 400
|
||||
repeat: false
|
||||
onTriggered: dragHandler.longPressing = true
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: visualContent
|
||||
width: root.trayItemSize
|
||||
height: root.trayItemSize
|
||||
anchors.centerIn: parent
|
||||
radius: Theme.cornerRadius
|
||||
color: trayItemArea.containsMouse ? BlurService.hoverColor(Theme.widgetBaseHoverColor) : "transparent"
|
||||
border.width: dragHandler.dragging ? 2 : 0
|
||||
border.color: Theme.primary
|
||||
opacity: dragHandler.dragging ? 0.8 : 1.0
|
||||
|
||||
transform: Translate {
|
||||
y: dragHandler.dragging ? dragHandler.dragAxisOffset : 0
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: iconImg
|
||||
anchors.centerIn: parent
|
||||
width: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
height: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
source: delegateRoot.iconSource
|
||||
asynchronous: true
|
||||
smooth: true
|
||||
mipmap: true
|
||||
visible: status === Image.Ready
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: !iconImg.visible
|
||||
text: {
|
||||
const itemId = trayItem?.id || "";
|
||||
if (!itemId)
|
||||
return "?";
|
||||
return itemId.charAt(0).toUpperCase();
|
||||
}
|
||||
font.pixelSize: 10
|
||||
color: Theme.widgetTextColor
|
||||
}
|
||||
|
||||
DankRipple {
|
||||
id: itemRipple
|
||||
cornerRadius: Theme.cornerRadius
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: trayItemArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: dragHandler.longPressing ? Qt.DragMoveCursor : Qt.PointingHandCursor
|
||||
|
||||
onPressed: mouse => {
|
||||
const pos = mapToItem(visualContent, mouse.x, mouse.y);
|
||||
itemRipple.trigger(pos.x, pos.y);
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
dragHandler.dragStartPos = Qt.point(mouse.x, mouse.y);
|
||||
longPressTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: mouse => {
|
||||
longPressTimer.stop();
|
||||
const wasDragging = dragHandler.dragging;
|
||||
const didReorder = wasDragging && root.dropTargetIndex >= 0 && root.dropTargetIndex !== root.draggedIndex;
|
||||
|
||||
if (didReorder) {
|
||||
root.suppressShiftAnimation = true;
|
||||
root.moveTrayItemInFullOrder(root.draggedIndex, root.dropTargetIndex);
|
||||
Qt.callLater(() => root.suppressShiftAnimation = false);
|
||||
}
|
||||
|
||||
dragHandler.longPressing = false;
|
||||
dragHandler.dragging = false;
|
||||
dragHandler.dragAxisOffset = 0;
|
||||
root.draggedIndex = -1;
|
||||
root.dropTargetIndex = -1;
|
||||
|
||||
if (wasDragging || mouse.button !== Qt.LeftButton)
|
||||
return;
|
||||
|
||||
if (!delegateRoot.trayItem)
|
||||
return;
|
||||
if (!delegateRoot.trayItem.onlyMenu) {
|
||||
delegateRoot.trayItem.activate();
|
||||
return;
|
||||
}
|
||||
if (!delegateRoot.trayItem.hasMenu)
|
||||
return;
|
||||
root.menuOpen = false;
|
||||
root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
|
||||
}
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
if (dragHandler.longPressing && !dragHandler.dragging) {
|
||||
const distance = Math.abs(mouse.y - dragHandler.dragStartPos.y);
|
||||
if (distance > 5) {
|
||||
dragHandler.dragging = true;
|
||||
root.draggedIndex = index;
|
||||
root.dropTargetIndex = index;
|
||||
}
|
||||
}
|
||||
if (!dragHandler.dragging)
|
||||
return;
|
||||
|
||||
const axisOffset = mouse.y - dragHandler.dragStartPos.y;
|
||||
dragHandler.dragAxisOffset = axisOffset;
|
||||
const itemSize = root.trayItemSize;
|
||||
const slotOffset = Math.round(axisOffset / itemSize);
|
||||
const newTargetIndex = Math.max(0, Math.min(root.mainBarItems.length - 1, index + slotOffset));
|
||||
if (newTargetIndex !== root.dropTargetIndex) {
|
||||
root.dropTargetIndex = newTargetIndex;
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: mouse => {
|
||||
if (dragHandler.dragging)
|
||||
return;
|
||||
if (mouse.button !== Qt.RightButton)
|
||||
return;
|
||||
if (!delegateRoot.trayItem?.hasMenu) {
|
||||
const gp = trayItemArea.mapToGlobal(mouse.x, mouse.y);
|
||||
root.callContextMenuFallback(delegateRoot.trayItem.id, Math.round(gp.x), Math.round(gp.y));
|
||||
return;
|
||||
}
|
||||
root.menuOpen = false;
|
||||
root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis);
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: root.reverseInlineVertical ? root.displayedInlineExpandedItems : []
|
||||
objectProp: "key"
|
||||
}
|
||||
delegate: inlineExpandedTrayItemDelegate
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -689,14 +851,7 @@ BasePill {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: {
|
||||
const edge = root.axis?.edge;
|
||||
if (edge === "left") {
|
||||
return root.menuOpen ? "chevron_left" : "chevron_right";
|
||||
} else {
|
||||
return root.menuOpen ? "chevron_right" : "chevron_left";
|
||||
}
|
||||
}
|
||||
name: root.toggleIconName()
|
||||
size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.maximizeWidgetIcons, root.barConfig?.iconScale)
|
||||
color: Theme.widgetTextColor
|
||||
}
|
||||
@@ -718,6 +873,22 @@ BasePill {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: root.reverseInlineVertical ? [] : root.displayedInlineExpandedItems
|
||||
objectProp: "key"
|
||||
}
|
||||
delegate: inlineExpandedTrayItemDelegate
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: root.reverseInlineVertical ? root.displayedMainBarItems : []
|
||||
objectProp: "key"
|
||||
}
|
||||
delegate: verticalMainTrayItemDelegate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,7 +904,7 @@ BasePill {
|
||||
blurRadius: Theme.cornerRadius
|
||||
}
|
||||
|
||||
visible: root.menuOpen
|
||||
visible: root.useOverflowPopup && root.menuOpen
|
||||
screen: root.parentScreen
|
||||
WlrLayershell.layer: WlrLayershell.Top
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
@@ -749,13 +920,14 @@ BasePill {
|
||||
|
||||
HyprlandFocusGrab {
|
||||
windows: [overflowMenu]
|
||||
active: CompositorService.useHyprlandFocusGrab && root.menuOpen
|
||||
active: CompositorService.useHyprlandFocusGrab && root.useOverflowPopup && root.menuOpen
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PopoutManager
|
||||
function onPopoutOpening() {
|
||||
root.menuOpen = false;
|
||||
if (root.useOverflowPopup)
|
||||
root.menuOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,30 +1193,7 @@ BasePill {
|
||||
|
||||
delegate: Rectangle {
|
||||
property var trayItem: modelData
|
||||
property string iconSource: {
|
||||
let icon = trayItem?.icon;
|
||||
if (typeof icon === 'string' || icon instanceof String) {
|
||||
if (icon === "")
|
||||
return "";
|
||||
if (icon.includes("?path=")) {
|
||||
const split = icon.split("?path=");
|
||||
if (split.length !== 2)
|
||||
return icon;
|
||||
const name = split[0];
|
||||
const path = split[1];
|
||||
let fileName = name.substring(name.lastIndexOf("/") + 1);
|
||||
if (fileName.startsWith("dropboxstatus")) {
|
||||
fileName = `hicolor/16x16/status/${fileName}`;
|
||||
}
|
||||
return `file://${path}/${fileName}`;
|
||||
}
|
||||
if (icon.startsWith("/") && !icon.startsWith("file://")) {
|
||||
return `file://${icon}`;
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
property string iconSource: root.trayIconSourceFor(trayItem)
|
||||
|
||||
width: root.trayItemSize + 4
|
||||
height: root.trayItemSize + 4
|
||||
@@ -1313,7 +1462,8 @@ BasePill {
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
updatePosition();
|
||||
root.menuOpen = false;
|
||||
if (root.useOverflowPopup)
|
||||
root.menuOpen = false;
|
||||
PopoutManager.closeAllPopouts();
|
||||
ModalManager.closeAllModalsExcept(null);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ DankPopout {
|
||||
if (currentPlayer && currentPlayer !== player && currentPlayer.canPause) {
|
||||
currentPlayer.pause();
|
||||
}
|
||||
MprisController.activePlayer = player;
|
||||
MprisController.setActivePlayer(player);
|
||||
root.__hideDropdowns();
|
||||
}
|
||||
onDeviceSelected: device => {
|
||||
|
||||
@@ -487,17 +487,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (!activePlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activePlayer.position > 8 && activePlayer.canSeek) {
|
||||
activePlayer.position = 0;
|
||||
} else {
|
||||
activePlayer.previous();
|
||||
}
|
||||
}
|
||||
onClicked: MprisController.previousOrRewind()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,14 +145,7 @@ Card {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (!activePlayer) return
|
||||
if (activePlayer.position > 8 && activePlayer.canSeek) {
|
||||
activePlayer.position = 0
|
||||
} else {
|
||||
activePlayer.previous()
|
||||
}
|
||||
}
|
||||
onClicked: MprisController.previousOrRewind()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,13 @@ Scope {
|
||||
}
|
||||
}
|
||||
|
||||
Pam {
|
||||
id: sharedPam
|
||||
lockSecured: root.shouldLock
|
||||
buffer: root.sharedPasswordBuffer
|
||||
onUnlockRequested: root.unlock()
|
||||
}
|
||||
|
||||
WlSessionLock {
|
||||
id: sessionLock
|
||||
|
||||
@@ -170,6 +177,7 @@ Scope {
|
||||
anchors.fill: parent
|
||||
visible: lockSurface.isActiveScreen
|
||||
lock: sessionLock
|
||||
pam: sharedPam
|
||||
sharedPasswordBuffer: root.sharedPasswordBuffer
|
||||
screenName: lockSurface.currentScreenName
|
||||
isLocked: shouldLock
|
||||
|
||||
@@ -23,6 +23,7 @@ Item {
|
||||
|
||||
property string passwordBuffer: ""
|
||||
property bool demoMode: false
|
||||
property var pam: demoPam
|
||||
property string screenName: ""
|
||||
property bool unlocking: false
|
||||
property string pamState: ""
|
||||
@@ -58,10 +59,8 @@ Item {
|
||||
return I18n.tr("Too many attempts - locked out");
|
||||
if (root.pamState === "fail")
|
||||
return I18n.tr("Incorrect password - try again");
|
||||
if (pam.fprintState === "error") {
|
||||
const detail = (pam.fprint.message || "").trim();
|
||||
return detail.length > 0 ? I18n.tr("Fingerprint error: %1").arg(detail) : I18n.tr("Fingerprint error");
|
||||
}
|
||||
if (pam.fprintState === "error")
|
||||
return I18n.tr("Fingerprint error");
|
||||
if (pam.fprintState === "max")
|
||||
return I18n.tr("Maximum fingerprint attempts reached. Please use password.");
|
||||
if (pam.fprintState === "fail")
|
||||
@@ -745,13 +744,6 @@ Item {
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1338,7 +1330,7 @@ Item {
|
||||
enabled: MprisController.activePlayer?.canGoPrevious ?? false
|
||||
hoverEnabled: enabled
|
||||
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: MprisController.activePlayer?.previous()
|
||||
onClicked: MprisController.previousOrRewind()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1639,49 +1631,46 @@ Item {
|
||||
}
|
||||
|
||||
Pam {
|
||||
id: pam
|
||||
lockSecured: !demoMode
|
||||
onUnlockRequested: {
|
||||
id: demoPam
|
||||
lockSecured: false
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.pam
|
||||
|
||||
function onUnlockRequested() {
|
||||
root.unlocking = true;
|
||||
lockerReadyArmed = false;
|
||||
passwordField.text = "";
|
||||
root.passwordBuffer = "";
|
||||
root.unlockRequested();
|
||||
}
|
||||
onStateChanged: {
|
||||
root.pamState = state;
|
||||
if (state !== "") {
|
||||
root.unlocking = false;
|
||||
placeholderDelay.restart();
|
||||
passwordField.text = "";
|
||||
root.passwordBuffer = "";
|
||||
}
|
||||
}
|
||||
onU2fPendingChanged: {
|
||||
if (u2fPending) {
|
||||
passwordField.text = "";
|
||||
root.passwordBuffer = "";
|
||||
if (keyboardController.isKeyboardActive)
|
||||
keyboardController.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: pam
|
||||
function onStateChanged() {
|
||||
root.pamState = root.pam.state;
|
||||
if (root.pam.state === "")
|
||||
return;
|
||||
root.unlocking = false;
|
||||
placeholderDelay.restart();
|
||||
passwordField.text = "";
|
||||
root.passwordBuffer = "";
|
||||
}
|
||||
|
||||
function onU2fPendingChanged() {
|
||||
if (!root.pam.u2fPending)
|
||||
return;
|
||||
passwordField.text = "";
|
||||
root.passwordBuffer = "";
|
||||
if (keyboardController.isKeyboardActive)
|
||||
keyboardController.hide();
|
||||
}
|
||||
|
||||
function onUnlockInProgressChanged() {
|
||||
if (!pam.unlockInProgress && root.unlocking)
|
||||
if (!root.pam.unlockInProgress && root.unlocking)
|
||||
root.unlocking = false;
|
||||
}
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: pam
|
||||
property: "buffer"
|
||||
value: root.passwordBuffer
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: placeholderDelay
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ FocusScope {
|
||||
id: root
|
||||
|
||||
required property WlSessionLock lock
|
||||
required property var pam
|
||||
required property string sharedPasswordBuffer
|
||||
required property string screenName
|
||||
required property bool isLocked
|
||||
@@ -32,6 +33,7 @@ FocusScope {
|
||||
|
||||
anchors.fill: parent
|
||||
demoMode: false
|
||||
pam: root.pam
|
||||
passwordBuffer: root.sharedPasswordBuffer
|
||||
screenName: root.screenName
|
||||
enabled: !videoScreensaver.active
|
||||
|
||||
@@ -182,6 +182,8 @@ Scope {
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
if (active)
|
||||
return;
|
||||
|
||||
tries = 0;
|
||||
errorTries = 0;
|
||||
@@ -195,22 +197,23 @@ Scope {
|
||||
if (!available)
|
||||
return;
|
||||
|
||||
if (res === PamResult.Success) {
|
||||
switch (res) {
|
||||
case PamResult.Success:
|
||||
if (!root.unlockInProgress) {
|
||||
passwd.abort();
|
||||
root.proceedAfterPrimaryAuth();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (res === PamResult.Error) {
|
||||
root.fprintState = "error";
|
||||
case PamResult.Error:
|
||||
errorTries++;
|
||||
if (errorTries < 5) {
|
||||
if (errorTries < 200) {
|
||||
abort();
|
||||
errorRetry.restart();
|
||||
return;
|
||||
}
|
||||
} else if (res === PamResult.MaxTries) {
|
||||
abort();
|
||||
return;
|
||||
case PamResult.MaxTries:
|
||||
tries++;
|
||||
if (tries < SettingsData.maxFprintTries) {
|
||||
root.fprintState = "fail";
|
||||
@@ -219,6 +222,9 @@ Scope {
|
||||
root.fprintState = "max";
|
||||
abort();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
root.flashMsg();
|
||||
@@ -297,7 +303,7 @@ Scope {
|
||||
Timer {
|
||||
id: errorRetry
|
||||
|
||||
interval: 800
|
||||
interval: 1500
|
||||
onTriggered: fprint.start()
|
||||
}
|
||||
|
||||
@@ -349,26 +355,22 @@ Scope {
|
||||
id: fprintStateReset
|
||||
|
||||
interval: 4000
|
||||
onTriggered: {
|
||||
root.fprintState = "";
|
||||
fprint.errorTries = 0;
|
||||
}
|
||||
onTriggered: root.fprintState = ""
|
||||
}
|
||||
|
||||
onLockSecuredChanged: {
|
||||
if (lockSecured) {
|
||||
SettingsData.refreshAuthAvailability();
|
||||
root.state = "";
|
||||
root.fprintState = "";
|
||||
root.u2fState = "";
|
||||
root.u2fPending = false;
|
||||
root.lockMessage = "";
|
||||
root.resetAuthFlows();
|
||||
fprint.checkAvail();
|
||||
u2f.checkAvail();
|
||||
} else {
|
||||
if (!lockSecured) {
|
||||
root.resetAuthFlows();
|
||||
return;
|
||||
}
|
||||
root.state = "";
|
||||
root.fprintState = "";
|
||||
root.u2fState = "";
|
||||
root.u2fPending = false;
|
||||
root.lockMessage = "";
|
||||
root.resetAuthFlows();
|
||||
fprint.checkAvail();
|
||||
u2f.checkAvail();
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
||||
@@ -606,6 +606,8 @@ Item {
|
||||
property var allLauncherPlugins: {
|
||||
SettingsData.launcherPluginVisibility;
|
||||
SettingsData.launcherPluginOrder;
|
||||
SettingsData.dankLauncherV2IncludeFilesInAll;
|
||||
SettingsData.dankLauncherV2IncludeFoldersInAll;
|
||||
var plugins = [];
|
||||
var builtIn = AppSearchService.getBuiltInLauncherPlugins() || {};
|
||||
for (var pluginId in builtIn) {
|
||||
@@ -616,6 +618,7 @@ Item {
|
||||
icon: plugin.cornerIcon || "extension",
|
||||
iconType: "material",
|
||||
isBuiltIn: true,
|
||||
isVirtual: false,
|
||||
trigger: AppSearchService.getBuiltInPluginTrigger(pluginId) || ""
|
||||
});
|
||||
}
|
||||
@@ -629,9 +632,32 @@ Item {
|
||||
icon: rawIcon.startsWith("material:") ? rawIcon.substring(9) : rawIcon.startsWith("unicode:") ? rawIcon.substring(8) : rawIcon,
|
||||
iconType: rawIcon.startsWith("unicode:") ? "unicode" : "material",
|
||||
isBuiltIn: false,
|
||||
isVirtual: false,
|
||||
trigger: PluginService.getPluginTrigger(pluginId) || ""
|
||||
});
|
||||
}
|
||||
if (SettingsData.dankLauncherV2IncludeFilesInAll) {
|
||||
plugins.push({
|
||||
id: "__files",
|
||||
name: I18n.tr("Files"),
|
||||
icon: "insert_drive_file",
|
||||
iconType: "material",
|
||||
isBuiltIn: false,
|
||||
isVirtual: true,
|
||||
trigger: "/"
|
||||
});
|
||||
}
|
||||
if (SettingsData.dankLauncherV2IncludeFoldersInAll) {
|
||||
plugins.push({
|
||||
id: "__folders",
|
||||
name: I18n.tr("Folders"),
|
||||
icon: "folder",
|
||||
iconType: "material",
|
||||
isBuiltIn: false,
|
||||
isVirtual: true,
|
||||
trigger: "/"
|
||||
});
|
||||
}
|
||||
return SettingsData.getOrderedLauncherPlugins(plugins);
|
||||
}
|
||||
|
||||
@@ -750,9 +776,27 @@ Item {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
checked: SettingsData.getPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id)
|
||||
checked: {
|
||||
switch (visibilityDelegateItem.modelData.id) {
|
||||
case "__files":
|
||||
return SettingsData.dankLauncherV2IncludeFilesInAll;
|
||||
case "__folders":
|
||||
return SettingsData.dankLauncherV2IncludeFoldersInAll;
|
||||
default:
|
||||
return SettingsData.getPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id);
|
||||
}
|
||||
}
|
||||
onToggled: function (isChecked) {
|
||||
SettingsData.setPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id, isChecked);
|
||||
switch (visibilityDelegateItem.modelData.id) {
|
||||
case "__files":
|
||||
SettingsData.set("dankLauncherV2IncludeFilesInAll", isChecked);
|
||||
break;
|
||||
case "__folders":
|
||||
SettingsData.set("dankLauncherV2IncludeFoldersInAll", isChecked);
|
||||
break;
|
||||
default:
|
||||
SettingsData.setPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id, isChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -840,6 +884,24 @@ Item {
|
||||
checked: SettingsData.rememberLastQuery
|
||||
onToggled: checked => SettingsData.set("rememberLastQuery", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "dankLauncherV2IncludeFilesInAll"
|
||||
tags: ["launcher", "files", "dsearch", "all", "results", "indexed"]
|
||||
text: I18n.tr("Include Files in All Tab")
|
||||
description: I18n.tr("Merge indexed file results into the All tab (requires dsearch).")
|
||||
checked: SettingsData.dankLauncherV2IncludeFilesInAll
|
||||
onToggled: checked => SettingsData.set("dankLauncherV2IncludeFilesInAll", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "dankLauncherV2IncludeFoldersInAll"
|
||||
tags: ["launcher", "folders", "dirs", "dsearch", "all", "results", "indexed"]
|
||||
text: I18n.tr("Include Folders in All Tab")
|
||||
description: I18n.tr("Merge indexed folder results into the All tab (requires dsearch).")
|
||||
checked: SettingsData.dankLauncherV2IncludeFoldersInAll
|
||||
onToggled: checked => SettingsData.set("dankLauncherV2IncludeFoldersInAll", checked)
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
|
||||
@@ -46,6 +46,13 @@ Item {
|
||||
onToggled: checked => SettingsData.set("audioVisualizerEnabled", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
text: I18n.tr("Adaptive Media Width")
|
||||
description: I18n.tr("Shrink the media widget to fit shorter song titles while still respecting the configured maximum size")
|
||||
checked: SettingsData.mediaAdaptiveWidthEnabled
|
||||
onToggled: checked => SettingsData.set("mediaAdaptiveWidthEnabled", checked)
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
property var scrollOptsInternal: ["volume", "song", "nothing"]
|
||||
property var scrollOptsDisplay: [I18n.tr("Change Volume", "media scroll wheel option"), I18n.tr("Change Song", "media scroll wheel option"), I18n.tr("Nothing", "media scroll wheel option")]
|
||||
|
||||
@@ -7,8 +7,8 @@ import qs.Modules.Settings.Widgets
|
||||
Item {
|
||||
id: root
|
||||
|
||||
readonly property var timeoutOptions: [I18n.tr("Never"), I18n.tr("1 minute"), I18n.tr("2 minutes"), I18n.tr("3 minutes"), I18n.tr("5 minutes"), I18n.tr("10 minutes"), I18n.tr("15 minutes"), I18n.tr("20 minutes"), I18n.tr("30 minutes"), I18n.tr("1 hour"), I18n.tr("1 hour 30 minutes"), I18n.tr("2 hours"), I18n.tr("3 hours")]
|
||||
readonly property var timeoutValues: [0, 60, 120, 180, 300, 600, 900, 1200, 1800, 3600, 5400, 7200, 10800]
|
||||
readonly property var timeoutOptions: [I18n.tr("Never"), I18n.tr("15 seconds"), I18n.tr("30 seconds"), I18n.tr("1 minute"), I18n.tr("2 minutes"), I18n.tr("3 minutes"), I18n.tr("5 minutes"), I18n.tr("10 minutes"), I18n.tr("15 minutes"), I18n.tr("20 minutes"), I18n.tr("30 minutes"), I18n.tr("1 hour"), I18n.tr("1 hour 30 minutes"), I18n.tr("2 hours"), I18n.tr("3 hours")]
|
||||
readonly property var timeoutValues: [0, 15, 30, 60, 120, 180, 300, 600, 900, 1200, 1800, 3600, 5400, 7200, 10800]
|
||||
|
||||
function getTimeoutIndex(timeout) {
|
||||
var idx = timeoutValues.indexOf(timeout);
|
||||
@@ -260,6 +260,39 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
id: postLockMonitorDropdown
|
||||
settingKey: "postLockMonitorTimeout"
|
||||
tags: ["monitor", "display", "screen", "timeout", "off", "lock", "after", "post"]
|
||||
text: I18n.tr("Turn off monitors after lock")
|
||||
options: root.timeoutOptions
|
||||
|
||||
Connections {
|
||||
target: powerCategory
|
||||
function onCurrentIndexChanged() {
|
||||
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acPostLockMonitorTimeout : SettingsData.batteryPostLockMonitorTimeout;
|
||||
postLockMonitorDropdown.currentValue = root.timeoutOptions[root.getTimeoutIndex(currentTimeout)];
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acPostLockMonitorTimeout : SettingsData.batteryPostLockMonitorTimeout;
|
||||
currentValue = root.timeoutOptions[root.getTimeoutIndex(currentTimeout)];
|
||||
}
|
||||
|
||||
onValueChanged: value => {
|
||||
const index = root.timeoutOptions.indexOf(value);
|
||||
if (index < 0)
|
||||
return;
|
||||
const timeout = root.timeoutValues[index];
|
||||
if (powerCategory.currentIndex === 0) {
|
||||
SettingsData.set("acPostLockMonitorTimeout", timeout);
|
||||
} else {
|
||||
SettingsData.set("batteryPostLockMonitorTimeout", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
id: suspendDropdown
|
||||
settingKey: "suspendTimeout"
|
||||
|
||||
@@ -91,6 +91,16 @@ Item {
|
||||
visible: AudioService.gsettingsAvailable
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
tab: "sounds"
|
||||
tags: ["sound", "login", "startup", "boot"]
|
||||
settingKey: "soundLogin"
|
||||
text: I18n.tr("Login")
|
||||
description: I18n.tr("Play sound after logging in")
|
||||
checked: SettingsData.soundLogin
|
||||
onToggled: checked => SettingsData.set("soundLogin", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
tab: "sounds"
|
||||
tags: ["sound", "notification", "new"]
|
||||
|
||||
@@ -17,7 +17,6 @@ StyledRect {
|
||||
property string description: ""
|
||||
property string iconName: ""
|
||||
property bool checked: false
|
||||
property bool enabled: true
|
||||
|
||||
default property alias content: expandedContent.children
|
||||
readonly property bool hasContent: expandedContent.children.length > 0
|
||||
|
||||
@@ -430,7 +430,7 @@ Item {
|
||||
"id": widget.id,
|
||||
"enabled": widget.enabled
|
||||
};
|
||||
var keys = ["size", "selectedGpuIndex", "pciId", "mountPath", "diskUsageMode", "minimumWidth", "showSwap", "showInGb", "mediaSize", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "keyboardLayoutNameCompactMode", "runningAppsGroupByApp", "runningAppsCurrentWorkspace", "runningAppsCurrentMonitor", "showNetworkIcon", "showBluetoothIcon", "showAudioIcon", "showAudioPercent", "showVpnIcon", "showBrightnessIcon", "showBrightnessPercent", "showMicIcon", "showMicPercent", "showBatteryIcon", "showPrinterIcon", "showScreenSharingIcon", "controlCenterGroupOrder", "barMaxVisibleApps", "barMaxVisibleRunningApps", "barShowOverflowBadge"];
|
||||
var keys = ["size", "selectedGpuIndex", "pciId", "mountPath", "diskUsageMode", "minimumWidth", "showSwap", "showInGb", "mediaSize", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "keyboardLayoutNameCompactMode", "runningAppsGroupByApp", "runningAppsCurrentWorkspace", "runningAppsCurrentMonitor", "showNetworkIcon", "showBluetoothIcon", "showAudioIcon", "showAudioPercent", "showVpnIcon", "showBrightnessIcon", "showBrightnessPercent", "showMicIcon", "showMicPercent", "showBatteryIcon", "showPrinterIcon", "showScreenSharingIcon", "controlCenterGroupOrder", "barMaxVisibleApps", "barMaxVisibleRunningApps", "barShowOverflowBadge", "trayUseInlineExpansion"];
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (widget[keys[i]] !== undefined)
|
||||
result[keys[i]] = widget[keys[i]];
|
||||
@@ -712,6 +712,8 @@ Item {
|
||||
item.barMaxVisibleRunningApps = widget.barMaxVisibleRunningApps;
|
||||
if (widget.barShowOverflowBadge !== undefined)
|
||||
item.barShowOverflowBadge = widget.barShowOverflowBadge;
|
||||
if (widget.trayUseInlineExpansion !== undefined)
|
||||
item.trayUseInlineExpansion = widget.trayUseInlineExpansion;
|
||||
}
|
||||
widgets.push(item);
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ Column {
|
||||
"id": widget.id,
|
||||
"enabled": widget.enabled
|
||||
};
|
||||
var keys = ["size", "selectedGpuIndex", "pciId", "mountPath", "diskUsageMode", "minimumWidth", "showSwap", "showInGb", "mediaSize", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "keyboardLayoutNameCompactMode", "runningAppsGroupByApp", "runningAppsCurrentWorkspace", "runningAppsCurrentMonitor", "showNetworkIcon", "showBluetoothIcon", "showAudioIcon", "showAudioPercent", "showVpnIcon", "showBrightnessIcon", "showBrightnessPercent", "showMicIcon", "showMicPercent", "showBatteryIcon", "showPrinterIcon", "showScreenSharingIcon", "controlCenterGroupOrder", "barMaxVisibleApps", "barMaxVisibleRunningApps", "barShowOverflowBadge"];
|
||||
var keys = ["size", "selectedGpuIndex", "pciId", "mountPath", "diskUsageMode", "minimumWidth", "showSwap", "showInGb", "mediaSize", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "keyboardLayoutNameCompactMode", "runningAppsGroupByApp", "runningAppsCurrentWorkspace", "runningAppsCurrentMonitor", "showNetworkIcon", "showBluetoothIcon", "showAudioIcon", "showAudioPercent", "showVpnIcon", "showBrightnessIcon", "showBrightnessPercent", "showMicIcon", "showMicPercent", "showBatteryIcon", "showPrinterIcon", "showScreenSharingIcon", "controlCenterGroupOrder", "barMaxVisibleApps", "barMaxVisibleRunningApps", "barShowOverflowBadge", "trayUseInlineExpansion"];
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (widget[keys[i]] !== undefined)
|
||||
result[keys[i]] = widget[keys[i]];
|
||||
@@ -437,7 +437,7 @@ Column {
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingXS
|
||||
visible: modelData.id === "clock" || modelData.id === "focusedWindow" || modelData.id === "keyboard_layout_name" || modelData.id === "appsDock"
|
||||
visible: modelData.id === "clock" || modelData.id === "focusedWindow" || modelData.id === "keyboard_layout_name" || modelData.id === "appsDock" || modelData.id === "systemTray"
|
||||
|
||||
DankActionButton {
|
||||
id: compactModeButton
|
||||
@@ -543,6 +543,39 @@ Column {
|
||||
}
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: trayMenuButton
|
||||
buttonSize: 32
|
||||
visible: modelData.id === "systemTray"
|
||||
iconName: "more_vert"
|
||||
iconSize: 18
|
||||
iconColor: Theme.outline
|
||||
onClicked: {
|
||||
trayContextMenu.widgetData = modelData;
|
||||
trayContextMenu.sectionId = root.sectionId;
|
||||
trayContextMenu.widgetIndex = index;
|
||||
|
||||
var buttonPos = trayMenuButton.mapToItem(root, 0, 0);
|
||||
var popupWidth = trayContextMenu.width;
|
||||
var popupHeight = trayContextMenu.height;
|
||||
|
||||
var xPos = buttonPos.x - popupWidth - Theme.spacingS;
|
||||
if (xPos < 0)
|
||||
xPos = buttonPos.x + trayMenuButton.width + Theme.spacingS;
|
||||
|
||||
var yPos = buttonPos.y - popupHeight / 2 + trayMenuButton.height / 2;
|
||||
if (yPos < 0) {
|
||||
yPos = Theme.spacingS;
|
||||
} else if (yPos + popupHeight > root.height) {
|
||||
yPos = root.height - popupHeight - Theme.spacingS;
|
||||
}
|
||||
|
||||
trayContextMenu.x = xPos;
|
||||
trayContextMenu.y = yPos;
|
||||
trayContextMenu.open();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: compactModeTooltip
|
||||
width: tooltipText.contentWidth + Theme.spacingM * 2
|
||||
@@ -931,6 +964,88 @@ Column {
|
||||
}
|
||||
}
|
||||
|
||||
Popup {
|
||||
id: trayContextMenu
|
||||
|
||||
property var widgetData: null
|
||||
property string sectionId: ""
|
||||
property int widgetIndex: -1
|
||||
readonly property var currentWidgetData: (widgetIndex >= 0 && widgetIndex < root.items.length) ? root.items[widgetIndex] : widgetData
|
||||
|
||||
width: 220
|
||||
height: contentColumn.implicitHeight + Theme.spacingS * 2
|
||||
padding: 0
|
||||
modal: true
|
||||
focus: true
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
background: Rectangle {
|
||||
color: Theme.surfaceContainer
|
||||
radius: Theme.cornerRadius
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
||||
border.width: 0
|
||||
}
|
||||
|
||||
contentItem: Item {
|
||||
Column {
|
||||
id: contentColumn
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingS
|
||||
spacing: 2
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 32
|
||||
radius: Theme.cornerRadius
|
||||
color: trayOverflowArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankIcon {
|
||||
name: "arrow_selector_tool"
|
||||
size: 16
|
||||
color: Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Use Inline Expansion")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Normal
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
id: trayOverflowToggle
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 40
|
||||
height: 20
|
||||
checked: trayContextMenu.currentWidgetData?.trayUseInlineExpansion ?? false
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: trayOverflowArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
const newValue = !(trayContextMenu.currentWidgetData?.trayUseInlineExpansion ?? false);
|
||||
root.overflowSettingChanged(trayContextMenu.sectionId, trayContextMenu.widgetIndex, "trayUseInlineExpansion", newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Popup {
|
||||
id: diskUsageContextMenu
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ Singleton {
|
||||
property var powerUnplugSound: null
|
||||
property var normalNotificationSound: null
|
||||
property var criticalNotificationSound: null
|
||||
property var loginSound: null
|
||||
property real notificationsVolume: 1.0
|
||||
property bool notificationsAudioMuted: false
|
||||
|
||||
@@ -67,6 +68,16 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
// Used in playLoginSoundIfApplicable()
|
||||
Process {
|
||||
id: loginSoundChecker
|
||||
onExited: (exitCode) => {
|
||||
if (exitCode === 0) {
|
||||
playLoginSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getAvailableSinks() {
|
||||
const hidden = SessionData.hiddenOutputDeviceNames ?? [];
|
||||
return Pipewire.nodes.values.filter(node => node.audio && node.isSink && !node.isStream && !hidden.includes(node.name));
|
||||
@@ -395,7 +406,7 @@ EOFCONFIG
|
||||
const themesToSearch = themeName !== "freedesktop" ? `${themeName} freedesktop` : themeName;
|
||||
|
||||
const script = `
|
||||
for event_key in audio-volume-change power-plug power-unplug message message-new-instant; do
|
||||
for event_key in audio-volume-change power-plug power-unplug message message-new-instant desktop-login; do
|
||||
found=0
|
||||
|
||||
case "$event_key" in
|
||||
@@ -457,7 +468,8 @@ EOFCONFIG
|
||||
"power-plug": "../assets/sounds/plasma/power-plug.wav",
|
||||
"power-unplug": "../assets/sounds/plasma/power-unplug.wav",
|
||||
"message": "../assets/sounds/freedesktop/message.wav",
|
||||
"message-new-instant": "../assets/sounds/freedesktop/message-new-instant.wav"
|
||||
"message-new-instant": "../assets/sounds/freedesktop/message-new-instant.wav",
|
||||
"desktop-login": "../assets/sounds/freedesktop/desktop-login.wav"
|
||||
};
|
||||
|
||||
const specialConditions = {
|
||||
@@ -551,6 +563,10 @@ EOFCONFIG
|
||||
criticalNotificationSound.destroy();
|
||||
criticalNotificationSound = null;
|
||||
}
|
||||
if (loginSound) {
|
||||
loginSound.destroy();
|
||||
loginSound = null;
|
||||
}
|
||||
}
|
||||
|
||||
function createSoundPlayers() {
|
||||
@@ -622,6 +638,19 @@ EOFCONFIG
|
||||
}
|
||||
}
|
||||
`, root, "AudioService.CriticalNotificationSound");
|
||||
|
||||
const loginPath = getSoundPath("desktop-login");
|
||||
loginSound = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import QtMultimedia
|
||||
MediaPlayer {
|
||||
source: "${loginPath}"
|
||||
audioOutput: AudioOutput {
|
||||
${deviceProperty}volume: notificationsVolume
|
||||
}
|
||||
}
|
||||
`, root, "AudioService.LoginSound");
|
||||
|
||||
} catch (e) {
|
||||
console.warn("AudioService: Error creating sound players:", e);
|
||||
}
|
||||
@@ -661,6 +690,31 @@ EOFCONFIG
|
||||
criticalNotificationSound.play();
|
||||
}
|
||||
|
||||
function playLoginSound() {
|
||||
if (!soundsAvailable || !loginSound || notificationsAudioMuted || isMediaPlaying()) {
|
||||
return;
|
||||
}
|
||||
loginSound.play();
|
||||
}
|
||||
|
||||
function playLoginSoundIfApplicable() {
|
||||
if (SettingsData.soundsEnabled && SettingsData.soundLogin && !notificationsAudioMuted) {
|
||||
// plays login sound on session start, but only if a specific file doesn't exist,
|
||||
// to prevent it from playing on every DMS restart during the session
|
||||
const runtimeDir = Quickshell.env("XDG_RUNTIME_DIR");
|
||||
const sessionId = Quickshell.env("XDG_SESSION_ID") || "0";
|
||||
|
||||
if (!runtimeDir) return;
|
||||
|
||||
const loginFile = `${runtimeDir}/danklinux.login-${sessionId}`;
|
||||
|
||||
// if file doesn't exist, touch it (0)
|
||||
// If it exists, do nothing (1)
|
||||
loginSoundChecker.command = ["sh", "-c", `[ ! -f ${loginFile} ] && touch ${loginFile}`];
|
||||
loginSoundChecker.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
function playVolumeChangeSoundIfEnabled() {
|
||||
if (SettingsData.soundsEnabled && SettingsData.soundVolumeChanged && !notificationsAudioMuted) {
|
||||
playVolumeChangeSound();
|
||||
|
||||
@@ -255,6 +255,12 @@ Singleton {
|
||||
return pinnedEntries.some(pinnedEntry => pinnedEntry.hash === entryHash);
|
||||
}
|
||||
|
||||
onClipboardAvailableChanged: {
|
||||
if (!clipboardAvailable || refCount <= 0)
|
||||
return;
|
||||
refresh();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
enabled: root.refCount > 0
|
||||
|
||||
@@ -138,7 +138,8 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
Proc.runCommand("dsearch-search", args, (stdout, exitCode) => {
|
||||
const procId = "dsearch-search-" + (params?.type || "all");
|
||||
Proc.runCommand(procId, args, (stdout, exitCode) => {
|
||||
if (exitCode === 0) {
|
||||
try {
|
||||
const response = JSON.parse(stdout);
|
||||
|
||||
@@ -819,6 +819,7 @@ Singleton {
|
||||
if (event.event === "unlock" || event.event === "resume") {
|
||||
suppressOsd = true;
|
||||
osdSuppressTimer.restart();
|
||||
evaluateNightMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1032,7 +1033,6 @@ Singleton {
|
||||
target: "brightness"
|
||||
}
|
||||
|
||||
// IPC Handler for night mode control
|
||||
IpcHandler {
|
||||
function toggle(): string {
|
||||
root.toggleNightMode();
|
||||
@@ -1050,43 +1050,119 @@ Singleton {
|
||||
}
|
||||
|
||||
function status(): string {
|
||||
return root.nightModeEnabled ? "Night mode is enabled" : "Night mode is disabled";
|
||||
if (!root.gammaControlAvailable)
|
||||
return "Night mode: unavailable (no gamma control)";
|
||||
|
||||
const parts = ["Night mode: " + (root.nightModeEnabled ? "enabled" : "disabled")];
|
||||
|
||||
if (root.gammaCurrentTemp > 0)
|
||||
parts.push("Current temperature: " + root.gammaCurrentTemp + "K");
|
||||
|
||||
parts.push("Target night temperature: " + SessionData.nightModeTemperature + "K");
|
||||
|
||||
if (SessionData.nightModeAutoEnabled) {
|
||||
parts.push("Target day temperature: " + SessionData.nightModeHighTemperature + "K");
|
||||
parts.push("Automation: " + SessionData.nightModeAutoMode);
|
||||
parts.push("Period: " + (root.gammaIsDay ? "day" : "night"));
|
||||
|
||||
if (root.gammaNextTransition)
|
||||
parts.push("Next transition: " + root.gammaNextTransition);
|
||||
if (root.gammaSunriseTime)
|
||||
parts.push("Sunrise: " + root.gammaSunriseTime);
|
||||
if (root.gammaSunsetTime)
|
||||
parts.push("Sunset: " + root.gammaSunsetTime);
|
||||
}
|
||||
|
||||
return parts.join("\n");
|
||||
}
|
||||
|
||||
function temperature(value: string): string {
|
||||
if (!value) {
|
||||
return "Current temperature: " + SessionData.nightModeTemperature + "K";
|
||||
}
|
||||
function getCurrentTemp(): string {
|
||||
if (!root.gammaControlAvailable)
|
||||
return "Gamma control not available";
|
||||
if (root.gammaCurrentTemp <= 0)
|
||||
return "No current temperature reported";
|
||||
return root.gammaCurrentTemp.toString();
|
||||
}
|
||||
|
||||
function getTargetTemp(): string {
|
||||
return SessionData.nightModeTemperature.toString();
|
||||
}
|
||||
|
||||
function getDayTemp(): string {
|
||||
return SessionData.nightModeHighTemperature.toString();
|
||||
}
|
||||
|
||||
function setTargetTemp(value: string): string {
|
||||
if (!value)
|
||||
return "Usage: night setTargetTemp <2500-6000>";
|
||||
|
||||
const temp = parseInt(value);
|
||||
if (isNaN(temp)) {
|
||||
return "Invalid temperature. Use a value between 2500 and 6000 (in steps of 500)";
|
||||
}
|
||||
|
||||
// Validate temperature is in valid range and steps
|
||||
if (temp < 2500 || temp > 6000) {
|
||||
if (isNaN(temp))
|
||||
return "Invalid temperature: " + value;
|
||||
if (temp < 2500 || temp > 6000)
|
||||
return "Temperature must be between 2500K and 6000K";
|
||||
}
|
||||
|
||||
// Round to nearest 500
|
||||
const rounded = Math.round(temp / 500) * 500;
|
||||
|
||||
SessionData.setNightModeTemperature(rounded);
|
||||
|
||||
// Restart night mode with new temperature if active
|
||||
if (root.nightModeEnabled) {
|
||||
if (SessionData.nightModeAutoEnabled) {
|
||||
switch (true) {
|
||||
case SessionData.nightModeAutoEnabled:
|
||||
root.startAutomation();
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
root.applyNightModeDirectly();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rounded !== temp) {
|
||||
return "Night mode temperature set to " + rounded + "K (rounded from " + temp + "K)";
|
||||
} else {
|
||||
return "Night mode temperature set to " + rounded + "K";
|
||||
}
|
||||
if (rounded !== temp)
|
||||
return "Night temperature set to " + rounded + "K (rounded from " + temp + "K)";
|
||||
return "Night temperature set to " + rounded + "K";
|
||||
}
|
||||
|
||||
function setDayTemp(value: string): string {
|
||||
if (!value)
|
||||
return "Usage: night setDayTemp <2500-6500>";
|
||||
|
||||
const temp = parseInt(value);
|
||||
if (isNaN(temp))
|
||||
return "Invalid temperature: " + value;
|
||||
if (temp < 2500 || temp > 6500)
|
||||
return "Temperature must be between 2500K and 6500K";
|
||||
|
||||
const rounded = Math.round(temp / 500) * 500;
|
||||
SessionData.setNightModeHighTemperature(rounded);
|
||||
|
||||
if (root.nightModeEnabled && SessionData.nightModeAutoEnabled)
|
||||
root.startAutomation();
|
||||
|
||||
if (rounded !== temp)
|
||||
return "Day temperature set to " + rounded + "K (rounded from " + temp + "K)";
|
||||
return "Day temperature set to " + rounded + "K";
|
||||
}
|
||||
|
||||
function getSchedule(): string {
|
||||
if (!SessionData.nightModeAutoEnabled)
|
||||
return "Automation disabled";
|
||||
|
||||
const parts = ["Mode: " + SessionData.nightModeAutoMode];
|
||||
parts.push("Period: " + (root.gammaIsDay ? "day" : "night"));
|
||||
|
||||
if (root.gammaDawnTime)
|
||||
parts.push("Dawn: " + root.gammaDawnTime);
|
||||
if (root.gammaSunriseTime)
|
||||
parts.push("Sunrise: " + root.gammaSunriseTime);
|
||||
if (root.gammaSunsetTime)
|
||||
parts.push("Sunset: " + root.gammaSunsetTime);
|
||||
if (root.gammaNightTime)
|
||||
parts.push("Night: " + root.gammaNightTime);
|
||||
if (root.gammaNextTransition)
|
||||
parts.push("Next transition: " + root.gammaNextTransition);
|
||||
if (root.gammaSunPosition > 0)
|
||||
parts.push("Sun position: " + root.gammaSunPosition.toFixed(2) + "°");
|
||||
|
||||
return parts.join("\n");
|
||||
}
|
||||
|
||||
target: "night"
|
||||
|
||||
@@ -36,12 +36,16 @@ Singleton {
|
||||
readonly property int lockTimeout: isOnBattery ? SettingsData.batteryLockTimeout : SettingsData.acLockTimeout
|
||||
readonly property int suspendTimeout: isOnBattery ? SettingsData.batterySuspendTimeout : SettingsData.acSuspendTimeout
|
||||
readonly property int suspendBehavior: isOnBattery ? SettingsData.batterySuspendBehavior : SettingsData.acSuspendBehavior
|
||||
readonly property int postLockMonitorTimeout: isOnBattery ? SettingsData.batteryPostLockMonitorTimeout : SettingsData.acPostLockMonitorTimeout
|
||||
readonly property bool postLockMonitorActive: isShellLocked && postLockMonitorTimeout > 0
|
||||
|
||||
readonly property bool mediaPlaying: MprisController.activePlayer !== null && MprisController.activePlayer.isPlaying
|
||||
|
||||
onMonitorTimeoutChanged: _rearmIdleMonitors()
|
||||
onLockTimeoutChanged: _rearmIdleMonitors()
|
||||
onSuspendTimeoutChanged: _rearmIdleMonitors()
|
||||
onPostLockMonitorTimeoutChanged: _rearmIdleMonitors()
|
||||
onIsShellLockedChanged: _rearmIdleMonitors()
|
||||
|
||||
function _rearmIdleMonitors() {
|
||||
_enableGate = false;
|
||||
@@ -60,6 +64,7 @@ Singleton {
|
||||
signal requestSuspend
|
||||
|
||||
property var monitorOffMonitor: null
|
||||
property var postLockMonitorOffMonitor: null
|
||||
property var lockMonitor: null
|
||||
property var suspendMonitor: null
|
||||
property var lockComponent: null
|
||||
@@ -96,7 +101,7 @@ Singleton {
|
||||
monitorOffMonitor = Qt.createQmlObject(qmlString, root, "IdleService.MonitorOffMonitor");
|
||||
monitorOffMonitor.timeout = Qt.binding(() => root.monitorTimeout > 0 ? root.monitorTimeout : 86400);
|
||||
monitorOffMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors);
|
||||
monitorOffMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.monitorTimeout > 0);
|
||||
monitorOffMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.monitorTimeout > 0 && !root.postLockMonitorActive);
|
||||
monitorOffMonitor.isIdleChanged.connect(function () {
|
||||
if (monitorOffMonitor.isIdle) {
|
||||
if (SettingsData.fadeToDpmsEnabled) {
|
||||
@@ -112,6 +117,18 @@ Singleton {
|
||||
}
|
||||
});
|
||||
|
||||
postLockMonitorOffMonitor = Qt.createQmlObject(qmlString, root, "IdleService.PostLockMonitorOffMonitor");
|
||||
postLockMonitorOffMonitor.timeout = Qt.binding(() => root.postLockMonitorTimeout > 0 ? root.postLockMonitorTimeout : 86400);
|
||||
postLockMonitorOffMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors);
|
||||
postLockMonitorOffMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.postLockMonitorActive);
|
||||
postLockMonitorOffMonitor.isIdleChanged.connect(function () {
|
||||
if (postLockMonitorOffMonitor.isIdle) {
|
||||
root.requestMonitorOff();
|
||||
} else {
|
||||
root.requestMonitorOn();
|
||||
}
|
||||
});
|
||||
|
||||
lockMonitor = Qt.createQmlObject(qmlString, root, "IdleService.LockMonitor");
|
||||
lockMonitor.timeout = Qt.binding(() => root.lockTimeout > 0 ? root.lockTimeout : 86400);
|
||||
lockMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors);
|
||||
|
||||
@@ -4,10 +4,75 @@ pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Mpris
|
||||
import qs.Common
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property list<MprisPlayer> availablePlayers: Mpris.players.values
|
||||
property MprisPlayer activePlayer: availablePlayers.find(p => p.isPlaying) ?? availablePlayers.find(p => p.canControl && p.canPlay) ?? null
|
||||
property MprisPlayer activePlayer: null
|
||||
|
||||
onAvailablePlayersChanged: _resolveActivePlayer()
|
||||
Component.onCompleted: _resolveActivePlayer()
|
||||
|
||||
Instantiator {
|
||||
model: root.availablePlayers
|
||||
delegate: Connections {
|
||||
required property MprisPlayer modelData
|
||||
target: modelData
|
||||
function onIsPlayingChanged() {
|
||||
if (modelData.isPlaying)
|
||||
root._resolveActivePlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _resolveActivePlayer(): void {
|
||||
const playing = availablePlayers.find(p => p.isPlaying);
|
||||
if (playing) {
|
||||
activePlayer = playing;
|
||||
_persistIdentity(playing.identity);
|
||||
return;
|
||||
}
|
||||
if (activePlayer && availablePlayers.indexOf(activePlayer) >= 0)
|
||||
return;
|
||||
const savedId = SessionData.lastPlayerIdentity;
|
||||
if (savedId) {
|
||||
const match = availablePlayers.find(p => p.identity === savedId);
|
||||
if (match) {
|
||||
activePlayer = match;
|
||||
return;
|
||||
}
|
||||
}
|
||||
activePlayer = availablePlayers.find(p => p.canControl && p.canPlay) ?? null;
|
||||
if (activePlayer)
|
||||
_persistIdentity(activePlayer.identity);
|
||||
}
|
||||
|
||||
function setActivePlayer(player: MprisPlayer): void {
|
||||
activePlayer = player;
|
||||
if (player)
|
||||
_persistIdentity(player.identity);
|
||||
}
|
||||
|
||||
function _persistIdentity(identity: string): void {
|
||||
if (identity && SessionData.lastPlayerIdentity !== identity)
|
||||
SessionData.set("lastPlayerIdentity", identity);
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: root.activePlayer?.playbackState === MprisPlaybackState.Playing
|
||||
repeat: true
|
||||
onTriggered: root.activePlayer?.positionChanged()
|
||||
}
|
||||
|
||||
function previousOrRewind(): void {
|
||||
if (!activePlayer)
|
||||
return;
|
||||
if (activePlayer.position > 8 && activePlayer.canSeek)
|
||||
activePlayer.position = 0;
|
||||
else if (activePlayer.canGoPrevious)
|
||||
activePlayer.previous();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Services.Pipewire
|
||||
import qs.Services
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
@@ -58,6 +59,10 @@ Singleton {
|
||||
}
|
||||
|
||||
readonly property bool screensharingActive: {
|
||||
if (CompositorService.isNiri && NiriService.hasActiveCast) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!Pipewire.ready || !Pipewire.nodes?.values) {
|
||||
return false
|
||||
}
|
||||
@@ -74,6 +79,12 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
if (node.properties && node.properties["media.class"] === "Stream/Output/Video") {
|
||||
if (looksLikeScreencast(node)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if (node.properties && node.properties["media.class"] === "Stream/Input/Audio") {
|
||||
const mediaName = (node.properties["media.name"] || "").toLowerCase()
|
||||
const appName = (node.properties["application.name"] || "").toLowerCase()
|
||||
@@ -110,8 +121,9 @@ Singleton {
|
||||
}
|
||||
const appName = (node.properties && node.properties["application.name"] || "").toLowerCase()
|
||||
const nodeName = (node.name || "").toLowerCase()
|
||||
const combined = appName + " " + nodeName
|
||||
return /xdg-desktop-portal|xdpw|screencast|screen|gnome shell|kwin|obs/.test(combined)
|
||||
const mediaName = (node.properties && node.properties["media.name"] || "").toLowerCase()
|
||||
const combined = appName + " " + nodeName + " " + mediaName
|
||||
return /xdg-desktop-portal|xdpw|screencast|screen-cast|screen|gnome shell|kwin|obs|niri/.test(combined)
|
||||
}
|
||||
|
||||
function getMicrophoneStatus() {
|
||||
|
||||
@@ -231,7 +231,10 @@ Singleton {
|
||||
return;
|
||||
isChecking = true;
|
||||
hasError = false;
|
||||
if (updChecker.length > 0) {
|
||||
if (pkgManager === "paru" || pkgManager === "yay") {
|
||||
const repoCmd = updChecker.length > 0 ? updChecker : `${pkgManager} -Qu`;
|
||||
updateChecker.command = ["sh", "-c", `(${repoCmd} 2>/dev/null; ${pkgManager} -Qua 2>/dev/null) || true`];
|
||||
} else if (updChecker.length > 0) {
|
||||
updateChecker.command = [updChecker].concat(updateCheckerParams[updChecker].listUpdatesSettings.params);
|
||||
} else {
|
||||
updateChecker.command = [pkgManager].concat(packageManagerParams[pkgManager].listUpdatesSettings.params);
|
||||
|
||||
@@ -10,7 +10,6 @@ StyledRect {
|
||||
property color iconColor: Theme.surfaceText
|
||||
property color backgroundColor: "transparent"
|
||||
property bool circular: true
|
||||
property bool enabled: true
|
||||
property int buttonSize: 32
|
||||
property var tooltipText: null
|
||||
property string tooltipSide: "bottom"
|
||||
|
||||
@@ -8,7 +8,6 @@ Rectangle {
|
||||
property string text: ""
|
||||
property string iconName: ""
|
||||
property int iconSize: Theme.iconSizeSmall
|
||||
property bool enabled: true
|
||||
property bool hovered: mouseArea.containsMouse
|
||||
property bool pressed: mouseArea.pressed
|
||||
property color backgroundColor: Theme.buttonBg
|
||||
|
||||
@@ -8,13 +8,122 @@ Item {
|
||||
id: root
|
||||
|
||||
property MprisPlayer activePlayer
|
||||
property real value: {
|
||||
if (!activePlayer || activePlayer.length <= 0) return 0
|
||||
const pos = (activePlayer.position || 0) % Math.max(1, activePlayer.length)
|
||||
const calculatedRatio = pos / activePlayer.length
|
||||
return Math.max(0, Math.min(1, calculatedRatio))
|
||||
property real seekPreviewRatio: -1
|
||||
readonly property real playerValue: {
|
||||
if (!activePlayer || activePlayer.length <= 0)
|
||||
return 0;
|
||||
const pos = (activePlayer.position || 0) % Math.max(1, activePlayer.length);
|
||||
const calculatedRatio = pos / activePlayer.length;
|
||||
return Math.max(0, Math.min(1, calculatedRatio));
|
||||
}
|
||||
property real value: seekPreviewRatio >= 0 ? seekPreviewRatio : playerValue
|
||||
property bool isSeeking: false
|
||||
property bool isDraggingSeek: false
|
||||
property real committedSeekRatio: -1
|
||||
property int previewSettleChecksRemaining: 0
|
||||
property real dragThreshold: 4
|
||||
property int holdIndicatorDelay: 180
|
||||
|
||||
function clampRatio(ratio) {
|
||||
return Math.max(0, Math.min(1, ratio));
|
||||
}
|
||||
|
||||
function ratioForPosition(position) {
|
||||
if (!activePlayer || activePlayer.length <= 0)
|
||||
return 0;
|
||||
return clampRatio(position / activePlayer.length);
|
||||
}
|
||||
|
||||
function positionForRatio(ratio) {
|
||||
if (!activePlayer || activePlayer.length <= 0)
|
||||
return 0;
|
||||
const rawPosition = clampRatio(ratio) * activePlayer.length;
|
||||
return Math.min(rawPosition, activePlayer.length * 0.99);
|
||||
}
|
||||
|
||||
function updatePreviewFromMouse(mouseX, width) {
|
||||
if (!activePlayer || activePlayer.length <= 0 || width <= 0)
|
||||
return;
|
||||
seekPreviewRatio = clampRatio(mouseX / width);
|
||||
}
|
||||
|
||||
function clearCommittedSeekPreview() {
|
||||
previewSettleTimer.stop();
|
||||
committedSeekRatio = -1;
|
||||
previewSettleChecksRemaining = 0;
|
||||
if (!isSeeking)
|
||||
seekPreviewRatio = -1;
|
||||
}
|
||||
|
||||
function beginCommittedSeekPreview(position) {
|
||||
seekPreviewRatio = ratioForPosition(position);
|
||||
committedSeekRatio = seekPreviewRatio;
|
||||
previewSettleChecksRemaining = 15;
|
||||
previewSettleTimer.restart();
|
||||
}
|
||||
|
||||
function handleSeekPressed(mouse, width, mouseArea, holdTimer) {
|
||||
isSeeking = true;
|
||||
isDraggingSeek = false;
|
||||
mouseArea.pressX = mouse.x;
|
||||
clearCommittedSeekPreview();
|
||||
holdTimer.restart();
|
||||
if (activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
updatePreviewFromMouse(mouse.x, width);
|
||||
mouseArea.pendingSeekPosition = positionForRatio(seekPreviewRatio);
|
||||
}
|
||||
}
|
||||
|
||||
function handleSeekReleased(mouseArea, holdTimer) {
|
||||
holdTimer.stop();
|
||||
isSeeking = false;
|
||||
isDraggingSeek = false;
|
||||
if (mouseArea.pendingSeekPosition >= 0 && activePlayer && activePlayer.canSeek && activePlayer.length > 0) {
|
||||
const clamped = Math.min(mouseArea.pendingSeekPosition, activePlayer.length * 0.99);
|
||||
activePlayer.position = clamped;
|
||||
mouseArea.pendingSeekPosition = -1;
|
||||
beginCommittedSeekPreview(clamped);
|
||||
} else {
|
||||
seekPreviewRatio = -1;
|
||||
}
|
||||
}
|
||||
|
||||
function handleSeekPositionChanged(mouse, width, mouseArea) {
|
||||
if (mouseArea.pressed && isSeeking && activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
if (!isDraggingSeek && Math.abs(mouse.x - mouseArea.pressX) >= dragThreshold)
|
||||
isDraggingSeek = true;
|
||||
updatePreviewFromMouse(mouse.x, width);
|
||||
mouseArea.pendingSeekPosition = positionForRatio(seekPreviewRatio);
|
||||
}
|
||||
}
|
||||
|
||||
function handleSeekCanceled(mouseArea, holdTimer) {
|
||||
holdTimer.stop();
|
||||
isSeeking = false;
|
||||
isDraggingSeek = false;
|
||||
mouseArea.pendingSeekPosition = -1;
|
||||
clearCommittedSeekPreview();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: previewSettleTimer
|
||||
interval: 80
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (root.isSeeking || root.committedSeekRatio < 0) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
const previewSettled = Math.abs(root.playerValue - root.committedSeekRatio) <= 0.0015;
|
||||
if (previewSettled || root.previewSettleChecksRemaining <= 0) {
|
||||
root.clearCommittedSeekPreview();
|
||||
return;
|
||||
}
|
||||
|
||||
root.previewSettleChecksRemaining -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
implicitHeight: 20
|
||||
|
||||
@@ -29,58 +138,35 @@ Item {
|
||||
|
||||
M3WaveProgress {
|
||||
value: root.value
|
||||
actualValue: root.playerValue
|
||||
showActualPlaybackState: root.isSeeking
|
||||
actualProgressColor: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.45)
|
||||
isPlaying: activePlayer && activePlayer.playbackState === MprisPlaybackState.Playing
|
||||
|
||||
MouseArea {
|
||||
id: waveMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: activePlayer && activePlayer.canSeek && activePlayer.length > 0
|
||||
|
||||
property real pendingSeekPosition: -1
|
||||
property real pressX: 0
|
||||
|
||||
Timer {
|
||||
id: waveSeekDebounceTimer
|
||||
interval: 150
|
||||
id: waveHoldIndicatorTimer
|
||||
interval: root.holdIndicatorDelay
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
if (parent.pendingSeekPosition >= 0 && activePlayer && activePlayer.canSeek && activePlayer.length > 0) {
|
||||
const clamped = Math.min(parent.pendingSeekPosition, activePlayer.length * 0.99)
|
||||
activePlayer.position = clamped
|
||||
parent.pendingSeekPosition = -1
|
||||
}
|
||||
if (parent.pressed && root.isSeeking)
|
||||
root.isDraggingSeek = true;
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: (mouse) => {
|
||||
root.isSeeking = true
|
||||
if (activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
const r = Math.max(0, Math.min(1, mouse.x / parent.width))
|
||||
pendingSeekPosition = r * activePlayer.length
|
||||
waveSeekDebounceTimer.restart()
|
||||
}
|
||||
}
|
||||
onReleased: {
|
||||
root.isSeeking = false
|
||||
waveSeekDebounceTimer.stop()
|
||||
if (pendingSeekPosition >= 0 && activePlayer && activePlayer.canSeek && activePlayer.length > 0) {
|
||||
const clamped = Math.min(pendingSeekPosition, activePlayer.length * 0.99)
|
||||
activePlayer.position = clamped
|
||||
pendingSeekPosition = -1
|
||||
}
|
||||
}
|
||||
onPositionChanged: (mouse) => {
|
||||
if (pressed && root.isSeeking && activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
const r = Math.max(0, Math.min(1, mouse.x / parent.width))
|
||||
pendingSeekPosition = r * activePlayer.length
|
||||
waveSeekDebounceTimer.restart()
|
||||
}
|
||||
}
|
||||
onClicked: (mouse) => {
|
||||
if (activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
const r = Math.max(0, Math.min(1, mouse.x / parent.width))
|
||||
activePlayer.position = r * activePlayer.length
|
||||
}
|
||||
}
|
||||
onPressed: mouse => root.handleSeekPressed(mouse, parent.width, waveMouseArea, waveHoldIndicatorTimer)
|
||||
onReleased: root.handleSeekReleased(waveMouseArea, waveHoldIndicatorTimer)
|
||||
onPositionChanged: mouse => root.handleSeekPositionChanged(mouse, parent.width, waveMouseArea)
|
||||
onCanceled: root.handleSeekCanceled(waveMouseArea, waveHoldIndicatorTimer)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,6 +179,7 @@ Item {
|
||||
property color trackColor: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.40)
|
||||
property color fillColor: Theme.primary
|
||||
property color playheadColor: Theme.primary
|
||||
property color actualProgressColor: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.45)
|
||||
readonly property real midY: height / 2
|
||||
|
||||
Rectangle {
|
||||
@@ -110,7 +197,22 @@ Item {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: parent.fillColor
|
||||
radius: height / 2
|
||||
Behavior on width { NumberAnimation { duration: 80 } }
|
||||
Behavior on width {
|
||||
NumberAnimation {
|
||||
duration: 80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: root.isDraggingSeek
|
||||
width: 2
|
||||
height: Math.max(parent.lineWidth + 4, 10)
|
||||
radius: width / 2
|
||||
color: parent.actualProgressColor
|
||||
x: Math.max(0, Math.min(parent.width, parent.width * root.playerValue)) - width / 2
|
||||
y: parent.midY - height / 2
|
||||
z: 2
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -122,59 +224,37 @@ Item {
|
||||
x: Math.max(0, Math.min(parent.width, parent.width * root.value)) - width / 2
|
||||
y: parent.midY - height / 2
|
||||
z: 3
|
||||
Behavior on x { NumberAnimation { duration: 80 } }
|
||||
Behavior on x {
|
||||
NumberAnimation {
|
||||
duration: 80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: flatMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: activePlayer && activePlayer.canSeek && activePlayer.length > 0
|
||||
|
||||
property real pendingSeekPosition: -1
|
||||
property real pressX: 0
|
||||
|
||||
Timer {
|
||||
id: flatSeekDebounceTimer
|
||||
interval: 150
|
||||
id: flatHoldIndicatorTimer
|
||||
interval: root.holdIndicatorDelay
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
if (parent.pendingSeekPosition >= 0 && activePlayer && activePlayer.canSeek && activePlayer.length > 0) {
|
||||
const clamped = Math.min(parent.pendingSeekPosition, activePlayer.length * 0.99)
|
||||
activePlayer.position = clamped
|
||||
parent.pendingSeekPosition = -1
|
||||
}
|
||||
if (parent.pressed && root.isSeeking)
|
||||
root.isDraggingSeek = true;
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: (mouse) => {
|
||||
root.isSeeking = true
|
||||
if (activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
const r = Math.max(0, Math.min(1, mouse.x / parent.width))
|
||||
pendingSeekPosition = r * activePlayer.length
|
||||
flatSeekDebounceTimer.restart()
|
||||
}
|
||||
}
|
||||
onReleased: {
|
||||
root.isSeeking = false
|
||||
flatSeekDebounceTimer.stop()
|
||||
if (pendingSeekPosition >= 0 && activePlayer && activePlayer.canSeek && activePlayer.length > 0) {
|
||||
const clamped = Math.min(pendingSeekPosition, activePlayer.length * 0.99)
|
||||
activePlayer.position = clamped
|
||||
pendingSeekPosition = -1
|
||||
}
|
||||
}
|
||||
onPositionChanged: (mouse) => {
|
||||
if (pressed && root.isSeeking && activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
const r = Math.max(0, Math.min(1, mouse.x / parent.width))
|
||||
pendingSeekPosition = r * activePlayer.length
|
||||
flatSeekDebounceTimer.restart()
|
||||
}
|
||||
}
|
||||
onClicked: (mouse) => {
|
||||
if (activePlayer && activePlayer.length > 0 && activePlayer.canSeek) {
|
||||
const r = Math.max(0, Math.min(1, mouse.x / parent.width))
|
||||
activePlayer.position = r * activePlayer.length
|
||||
}
|
||||
}
|
||||
onPressed: mouse => root.handleSeekPressed(mouse, parent.width, flatMouseArea, flatHoldIndicatorTimer)
|
||||
onReleased: root.handleSeekReleased(flatMouseArea, flatHoldIndicatorTimer)
|
||||
onPositionChanged: mouse => root.handleSeekPositionChanged(mouse, parent.width, flatMouseArea)
|
||||
onCanceled: root.handleSeekCanceled(flatMouseArea, flatHoldIndicatorTimer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ Item {
|
||||
property int step: 1
|
||||
property string leftIcon: ""
|
||||
property string rightIcon: ""
|
||||
property bool enabled: true
|
||||
property string unit: "%"
|
||||
property bool showValue: true
|
||||
property bool isDragging: false
|
||||
|
||||
@@ -25,7 +25,6 @@ StyledRect {
|
||||
property string placeholderText: ""
|
||||
property alias font: textInput.font
|
||||
property alias textColor: textInput.color
|
||||
property alias enabled: textInput.enabled
|
||||
property alias echoMode: textInput.echoMode
|
||||
property alias validator: textInput.validator
|
||||
property alias maximumLength: textInput.maximumLength
|
||||
|
||||
@@ -10,7 +10,6 @@ Item {
|
||||
|
||||
// API
|
||||
property bool checked: false
|
||||
property bool enabled: true
|
||||
property bool toggling: false
|
||||
property string text: ""
|
||||
property string description: ""
|
||||
|
||||
@@ -6,6 +6,8 @@ Item {
|
||||
id: root
|
||||
|
||||
property real value: 0
|
||||
property real actualValue: value
|
||||
property bool showActualPlaybackState: false
|
||||
property real lineWidth: 2
|
||||
property real wavelength: 20
|
||||
property real amp: 1.6
|
||||
@@ -15,6 +17,7 @@ Item {
|
||||
property color trackColor: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.40)
|
||||
property color fillColor: Theme.primary
|
||||
property color playheadColor: Theme.primary
|
||||
property color actualProgressColor: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.45)
|
||||
|
||||
property real dpr: (root.window ? root.window.devicePixelRatio : 1)
|
||||
function snap(v) {
|
||||
@@ -22,7 +25,12 @@ Item {
|
||||
}
|
||||
|
||||
readonly property real playX: snap(root.width * root.value)
|
||||
readonly property real actualX: snap(root.width * root.actualValue)
|
||||
readonly property real midY: snap(height / 2)
|
||||
readonly property bool previewAhead: root.showActualPlaybackState && root.value > root.actualValue
|
||||
readonly property bool previewBehind: root.showActualPlaybackState && root.value < root.actualValue
|
||||
readonly property real previewGapStartX: Math.min(root.playX, root.actualX)
|
||||
readonly property real previewGapEndX: Math.max(root.playX, root.actualX)
|
||||
|
||||
Behavior on currentAmp {
|
||||
NumberAnimation {
|
||||
@@ -65,7 +73,9 @@ Item {
|
||||
|
||||
readonly property real startX: snap(root.lineWidth / 2)
|
||||
readonly property real aaBias: (0.25 / root.dpr)
|
||||
readonly property real endX: Math.max(startX, Math.min(root.playX - startX - aaBias, width))
|
||||
readonly property real endX: root.previewAhead ? Math.max(startX, Math.min(root.actualX - aaBias, width)) : Math.max(startX, Math.min(root.playX - startX - aaBias, width))
|
||||
readonly property real gapStartX: root.previewAhead ? Math.max(startX, Math.min(root.actualX + aaBias, width)) : Math.max(startX, Math.min(root.playX + playhead.width / 2, width))
|
||||
readonly property real gapEndX: root.previewAhead ? Math.max(gapStartX, Math.min(root.playX - playhead.width / 2 - aaBias, width)) : Math.max(gapStartX, Math.min(root.actualX - aaBias, width))
|
||||
|
||||
Rectangle {
|
||||
id: mask
|
||||
@@ -100,6 +110,37 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: actualMask
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
x: waveClip.gapStartX
|
||||
width: Math.max(0, waveClip.gapEndX - waveClip.gapStartX)
|
||||
color: "transparent"
|
||||
clip: true
|
||||
visible: (root.previewBehind || root.previewAhead) && width > 0
|
||||
|
||||
Shape {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
width: root.width + 4 * root.wavelength
|
||||
antialiasing: true
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
x: waveOffsetX
|
||||
|
||||
ShapePath {
|
||||
strokeColor: root.actualProgressColor
|
||||
strokeWidth: snap(root.lineWidth)
|
||||
capStyle: ShapePath.RoundCap
|
||||
joinStyle: ShapePath.RoundJoin
|
||||
fillColor: "transparent"
|
||||
PathSvg {
|
||||
path: waveSvg.path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: startCap
|
||||
width: snap(root.lineWidth)
|
||||
@@ -107,7 +148,7 @@ Item {
|
||||
radius: width / 2
|
||||
color: root.fillColor
|
||||
x: waveClip.startX - width / 2
|
||||
y: root.midY - height / 2 + root.currentAmp * Math.sin((waveClip.startX / root.wavelength) * 2 * Math.PI + root.phase)
|
||||
y: waveY(waveClip.startX) - height / 2
|
||||
visible: waveClip.endX > waveClip.startX
|
||||
z: 2
|
||||
}
|
||||
@@ -119,10 +160,34 @@ Item {
|
||||
radius: width / 2
|
||||
color: root.fillColor
|
||||
x: waveClip.endX - width / 2
|
||||
y: root.midY - height / 2 + root.currentAmp * Math.sin((waveClip.endX / root.wavelength) * 2 * Math.PI + root.phase)
|
||||
y: waveY(waveClip.endX) - height / 2
|
||||
visible: waveClip.endX > waveClip.startX
|
||||
z: 2
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: actualEndCap
|
||||
width: snap(root.lineWidth)
|
||||
height: snap(root.lineWidth)
|
||||
radius: width / 2
|
||||
color: root.actualProgressColor
|
||||
x: waveClip.gapEndX - width / 2
|
||||
y: waveY(waveClip.gapEndX) - height / 2
|
||||
visible: (root.previewBehind || root.previewAhead) && actualMask.width > 0
|
||||
z: 2
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: actualMarker
|
||||
width: 2
|
||||
height: Math.max(root.lineWidth + 4, 10)
|
||||
radius: width / 2
|
||||
color: root.actualProgressColor
|
||||
x: root.actualX - width / 2
|
||||
y: root.midY - height / 2
|
||||
visible: root.showActualPlaybackState
|
||||
z: 2
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -141,6 +206,10 @@ Item {
|
||||
let r = a % m;
|
||||
return r < 0 ? r + m : r;
|
||||
}
|
||||
function waveY(x, amplitude = root.currentAmp, phaseOffset = root.phase) {
|
||||
return root.midY + amplitude * Math.sin((x / root.wavelength) * 2 * Math.PI + phaseOffset);
|
||||
}
|
||||
|
||||
readonly property real waveOffsetX: -wrapMod(phase / k, wavelength)
|
||||
|
||||
FrameAnimation {
|
||||
@@ -148,8 +217,9 @@ Item {
|
||||
onTriggered: {
|
||||
if (root.isPlaying)
|
||||
root.phase += 0.03 * frameTime * 60;
|
||||
startCap.y = root.midY - startCap.height / 2 + root.currentAmp * Math.sin((waveClip.startX / root.wavelength) * 2 * Math.PI + root.phase);
|
||||
endCap.y = root.midY - endCap.height / 2 + root.currentAmp * Math.sin((waveClip.endX / root.wavelength) * 2 * Math.PI + root.phase);
|
||||
startCap.y = waveY(waveClip.startX) - startCap.height / 2;
|
||||
endCap.y = waveY(waveClip.endX) - endCap.height / 2;
|
||||
actualEndCap.y = waveY(waveClip.gapEndX) - actualEndCap.height / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#%PAM-1.0
|
||||
|
||||
auth required pam_fprintd.so max-tries=1 timeout=5
|
||||
auth required pam_fprintd.so max-tries=5
|
||||
|
||||
BIN
quickshell/assets/sounds/freedesktop/desktop-login.oga
Normal file
BIN
quickshell/assets/sounds/freedesktop/desktop-login.oga
Normal file
Binary file not shown.
BIN
quickshell/assets/sounds/freedesktop/desktop-login.wav
Normal file
BIN
quickshell/assets/sounds/freedesktop/desktop-login.wav
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -86,13 +86,13 @@ def create_poeditor_json(translations):
|
||||
references.append(ref)
|
||||
|
||||
contexts = sorted(data['contexts']) if data['contexts'] else []
|
||||
context_str = " | ".join(contexts) if contexts else term
|
||||
comment = " | ".join(contexts) if contexts else ""
|
||||
|
||||
entry = {
|
||||
"term": term,
|
||||
"context": context_str,
|
||||
"context": term,
|
||||
"reference": ", ".join(references),
|
||||
"comment": ""
|
||||
"comment": comment
|
||||
}
|
||||
poeditor_data.append(entry)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user