1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

Compare commits

...

3 Commits

Author SHA1 Message Date
bbedward
f08e2ef5b8 hypr: add disable output option 2025-12-28 23:15:43 -05:00
Joaquim S.
2b0070c31a matugen/template: Soothing neovim theme (#1201) 2025-12-28 21:49:44 -05:00
Marcus Ramberg
ae82716afa core: apply gopls automatic modernizers (#1198) 2025-12-28 21:48:56 -05:00
20 changed files with 180 additions and 142 deletions

View File

@@ -179,7 +179,7 @@ func runBrightnessList(cmd *cobra.Command, args []string) {
fmt.Printf("%-*s %-12s %-*s %s\n", idPad, "Device", "Class", namePad, "Name", "Brightness") fmt.Printf("%-*s %-12s %-*s %s\n", idPad, "Device", "Class", namePad, "Name", "Brightness")
sepLen := idPad + 2 + 12 + 2 + namePad + 2 + 15 sepLen := idPad + 2 + 12 + 2 + namePad + 2 + 15
for i := 0; i < sepLen; i++ { for range sepLen {
fmt.Print("─") fmt.Print("─")
} }
fmt.Println() fmt.Println()

View File

@@ -377,7 +377,7 @@ func updateDMSBinary() error {
} }
version := "" version := ""
for _, line := range strings.Split(string(output), "\n") { for line := range strings.SplitSeq(string(output), "\n") {
if strings.Contains(line, "\"tag_name\"") { if strings.Contains(line, "\"tag_name\"") {
parts := strings.Split(line, "\"") parts := strings.Split(line, "\"")
if len(parts) >= 4 { if len(parts) >= 4 {
@@ -443,7 +443,7 @@ func updateDMSBinary() error {
decompressedPath := filepath.Join(tempDir, "dms") decompressedPath := filepath.Join(tempDir, "dms")
if err := os.Chmod(decompressedPath, 0755); err != nil { if err := os.Chmod(decompressedPath, 0o755); err != nil {
return fmt.Errorf("failed to make binary executable: %w", err) return fmt.Errorf("failed to make binary executable: %w", err)
} }

View File

@@ -211,8 +211,8 @@ func checkGroupExists(groupName string) bool {
return false return false
} }
lines := strings.Split(string(data), "\n") lines := strings.SplitSeq(string(data), "\n")
for _, line := range lines { for line := range lines {
if strings.HasPrefix(line, groupName+":") { if strings.HasPrefix(line, groupName+":") {
return true return true
} }
@@ -521,7 +521,7 @@ func enableGreeter() error {
newConfig := strings.Join(finalLines, "\n") newConfig := strings.Join(finalLines, "\n")
tmpFile := "/tmp/greetd-config.toml" tmpFile := "/tmp/greetd-config.toml"
if err := os.WriteFile(tmpFile, []byte(newConfig), 0644); err != nil { if err := os.WriteFile(tmpFile, []byte(newConfig), 0o644); err != nil {
return fmt.Errorf("failed to write temp config: %w", err) return fmt.Errorf("failed to write temp config: %w", err)
} }
@@ -592,8 +592,8 @@ func checkGreeterStatus() error {
if data, err := os.ReadFile(configPath); err == nil { if data, err := os.ReadFile(configPath); err == nil {
configContent := string(data) configContent := string(data)
if strings.Contains(configContent, "dms-greeter") { if strings.Contains(configContent, "dms-greeter") {
lines := strings.Split(configContent, "\n") lines := strings.SplitSeq(configContent, "\n")
for _, line := range lines { for line := range lines {
trimmed := strings.TrimSpace(line) trimmed := strings.TrimSpace(line)
if strings.HasPrefix(trimmed, "command =") || strings.HasPrefix(trimmed, "command=") { if strings.HasPrefix(trimmed, "command =") || strings.HasPrefix(trimmed, "command=") {
parts := strings.SplitN(trimmed, "=", 2) parts := strings.SplitN(trimmed, "=", 2)

View File

@@ -87,20 +87,14 @@ func newDPMSClient() (*dpmsClient, error) {
switch e.Interface { switch e.Interface {
case wlr_output_power.ZwlrOutputPowerManagerV1InterfaceName: case wlr_output_power.ZwlrOutputPowerManagerV1InterfaceName:
powerMgr := wlr_output_power.NewZwlrOutputPowerManagerV1(c.ctx) powerMgr := wlr_output_power.NewZwlrOutputPowerManagerV1(c.ctx)
version := e.Version version := min(e.Version, 1)
if version > 1 {
version = 1
}
if err := registry.Bind(e.Name, e.Interface, version, powerMgr); err == nil { if err := registry.Bind(e.Name, e.Interface, version, powerMgr); err == nil {
c.powerMgr = powerMgr c.powerMgr = powerMgr
} }
case "wl_output": case "wl_output":
output := wlclient.NewOutput(c.ctx) output := wlclient.NewOutput(c.ctx)
version := e.Version version := min(e.Version, 4)
if version > 4 {
version = 4
}
if err := registry.Bind(e.Name, e.Interface, version, output); err == nil { if err := registry.Bind(e.Name, e.Interface, version, output); err == nil {
outputID := fmt.Sprintf("output-%d", output.ID()) outputID := fmt.Sprintf("output-%d", output.ID())
state := &outputState{ state := &outputState{

View File

@@ -7,6 +7,7 @@ import (
"os/exec" "os/exec"
"os/signal" "os/signal"
"path/filepath" "path/filepath"
"slices"
"strconv" "strconv"
"strings" "strings"
"syscall" "syscall"
@@ -371,13 +372,7 @@ func killShell() {
func runShellDaemon(session bool) { func runShellDaemon(session bool) {
isSessionManaged = session isSessionManaged = session
isDaemonChild := false isDaemonChild := slices.Contains(os.Args, "--daemon-child")
for _, arg := range os.Args {
if arg == "--daemon-child" {
isDaemonChild = true
break
}
}
if !isDaemonChild { if !isDaemonChild {
fmt.Fprintf(os.Stderr, "dms %s\n", Version) fmt.Fprintf(os.Stderr, "dms %s\n", Version)
@@ -534,9 +529,9 @@ func runShellDaemon(session bool) {
func parseTargetsFromIPCShowOutput(output string) ipcTargets { func parseTargetsFromIPCShowOutput(output string) ipcTargets {
targets := make(ipcTargets) targets := make(ipcTargets)
var currentTarget string var currentTarget string
for _, line := range strings.Split(output, "\n") { for line := range strings.SplitSeq(output, "\n") {
if strings.HasPrefix(line, "target ") { if after, ok := strings.CutPrefix(line, "target "); ok {
currentTarget = strings.TrimSpace(strings.TrimPrefix(line, "target ")) currentTarget = strings.TrimSpace(after)
targets[currentTarget] = make(map[string][]string) targets[currentTarget] = make(map[string][]string)
} }
if strings.HasPrefix(line, " function") && currentTarget != "" { if strings.HasPrefix(line, " function") && currentTarget != "" {

View File

@@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"os/exec" "os/exec"
"slices"
"strings" "strings"
) )
@@ -36,13 +37,7 @@ func checkSystemdServiceEnabled(serviceName string) (string, bool, error) {
if err != nil { if err != nil {
knownStates := []string{"disabled", "masked", "masked-runtime", "not-found", "enabled", "enabled-runtime", "static", "indirect", "alias"} knownStates := []string{"disabled", "masked", "masked-runtime", "not-found", "enabled", "enabled-runtime", "static", "indirect", "alias"}
isKnownState := false isKnownState := slices.Contains(knownStates, stateStr)
for _, known := range knownStates {
if stateStr == known {
isKnownState = true
break
}
}
if !isKnownState { if !isKnownState {
return stateStr, false, fmt.Errorf("systemctl is-enabled failed: %w (output: %s)", err, stateStr) return stateStr, false, fmt.Errorf("systemctl is-enabled failed: %w (output: %s)", err, stateStr)

View File

@@ -221,10 +221,7 @@ func (p *Picker) handleGlobal(e client.RegistryGlobalEvent) {
case client.OutputInterfaceName: case client.OutputInterfaceName:
output := client.NewOutput(p.ctx) output := client.NewOutput(p.ctx)
version := e.Version version := min(e.Version, 4)
if version > 4 {
version = 4
}
if err := p.registry.Bind(e.Name, e.Interface, version, output); err == nil { if err := p.registry.Bind(e.Name, e.Interface, version, output); err == nil {
p.outputsMu.Lock() p.outputsMu.Lock()
p.outputs[e.Name] = &Output{ p.outputs[e.Name] = &Output{
@@ -239,20 +236,14 @@ func (p *Picker) handleGlobal(e client.RegistryGlobalEvent) {
case wlr_layer_shell.ZwlrLayerShellV1InterfaceName: case wlr_layer_shell.ZwlrLayerShellV1InterfaceName:
layerShell := wlr_layer_shell.NewZwlrLayerShellV1(p.ctx) layerShell := wlr_layer_shell.NewZwlrLayerShellV1(p.ctx)
version := e.Version version := min(e.Version, 4)
if version > 4 {
version = 4
}
if err := p.registry.Bind(e.Name, e.Interface, version, layerShell); err == nil { if err := p.registry.Bind(e.Name, e.Interface, version, layerShell); err == nil {
p.layerShell = layerShell p.layerShell = layerShell
} }
case wlr_screencopy.ZwlrScreencopyManagerV1InterfaceName: case wlr_screencopy.ZwlrScreencopyManagerV1InterfaceName:
screencopy := wlr_screencopy.NewZwlrScreencopyManagerV1(p.ctx) screencopy := wlr_screencopy.NewZwlrScreencopyManagerV1(p.ctx)
version := e.Version version := min(e.Version, 3)
if version > 3 {
version = 3
}
if err := p.registry.Bind(e.Name, e.Interface, version, screencopy); err == nil { if err := p.registry.Bind(e.Name, e.Interface, version, screencopy); err == nil {
p.screencopy = screencopy p.screencopy = screencopy
} }

View File

@@ -1157,7 +1157,7 @@ func drawGlyph(data []byte, stride, width, height, x, y int, r rune, col Color,
rOff, bOff = 2, 0 rOff, bOff = 2, 0
} }
for row := 0; row < fontH; row++ { for row := range fontH {
yy := y + row yy := y + row
if yy < 0 || yy >= height { if yy < 0 || yy >= height {
continue continue
@@ -1165,7 +1165,7 @@ func drawGlyph(data []byte, stride, width, height, x, y int, r rune, col Color,
rowPattern := g[row] rowPattern := g[row]
dstRowOff := yy * stride dstRowOff := yy * stride
for colIdx := 0; colIdx < fontW; colIdx++ { for colIdx := range fontW {
if (rowPattern & (1 << (fontW - 1 - colIdx))) == 0 { if (rowPattern & (1 << (fontW - 1 - colIdx))) == 0 {
continue continue
} }

View File

@@ -14,11 +14,11 @@ func TestSurfaceState_ConcurrentPointerMotion(t *testing.T) {
const goroutines = 50 const goroutines = 50
const iterations = 100 const iterations = 100
for i := 0; i < goroutines; i++ { for i := range goroutines {
wg.Add(1) wg.Add(1)
go func(id int) { go func(id int) {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for j := range iterations {
s.OnPointerMotion(float64(id*10+j), float64(id*10+j)) s.OnPointerMotion(float64(id*10+j), float64(id*10+j))
} }
}(i) }(i)
@@ -34,21 +34,21 @@ func TestSurfaceState_ConcurrentScaleAccess(t *testing.T) {
const goroutines = 30 const goroutines = 30
const iterations = 100 const iterations = 100
for i := 0; i < goroutines/2; i++ { for i := range goroutines / 2 {
wg.Add(1) wg.Add(1)
go func(id int) { go func(id int) {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
s.SetScale(int32(id%3 + 1)) s.SetScale(int32(id%3 + 1))
} }
}(i) }(i)
} }
for i := 0; i < goroutines/2; i++ { for range goroutines / 2 {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
scale := s.Scale() scale := s.Scale()
assert.GreaterOrEqual(t, scale, int32(1)) assert.GreaterOrEqual(t, scale, int32(1))
} }
@@ -65,21 +65,21 @@ func TestSurfaceState_ConcurrentLogicalSize(t *testing.T) {
const goroutines = 20 const goroutines = 20
const iterations = 100 const iterations = 100
for i := 0; i < goroutines/2; i++ { for i := range goroutines / 2 {
wg.Add(1) wg.Add(1)
go func(id int) { go func(id int) {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for j := range iterations {
_ = s.OnLayerConfigure(1920+id, 1080+j) _ = s.OnLayerConfigure(1920+id, 1080+j)
} }
}(i) }(i)
} }
for i := 0; i < goroutines/2; i++ { for range goroutines / 2 {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
w, h := s.LogicalSize() w, h := s.LogicalSize()
_ = w _ = w
_ = h _ = h
@@ -97,31 +97,31 @@ func TestSurfaceState_ConcurrentIsDone(t *testing.T) {
const goroutines = 30 const goroutines = 30
const iterations = 100 const iterations = 100
for i := 0; i < goroutines/3; i++ { for range goroutines / 3 {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
s.OnPointerButton(0x110, 1) s.OnPointerButton(0x110, 1)
} }
}() }()
} }
for i := 0; i < goroutines/3; i++ { for range goroutines / 3 {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
s.OnKey(1, 1) s.OnKey(1, 1)
} }
}() }()
} }
for i := 0; i < goroutines/3; i++ { for range goroutines / 3 {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
picked, cancelled := s.IsDone() picked, cancelled := s.IsDone()
_ = picked _ = picked
_ = cancelled _ = cancelled
@@ -139,11 +139,11 @@ func TestSurfaceState_ConcurrentIsReady(t *testing.T) {
const goroutines = 20 const goroutines = 20
const iterations = 100 const iterations = 100
for i := 0; i < goroutines; i++ { for range goroutines {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
_ = s.IsReady() _ = s.IsReady()
} }
}() }()
@@ -159,11 +159,11 @@ func TestSurfaceState_ConcurrentSwapBuffers(t *testing.T) {
const goroutines = 20 const goroutines = 20
const iterations = 100 const iterations = 100
for i := 0; i < goroutines; i++ { for range goroutines {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
for j := 0; j < iterations; j++ { for range iterations {
s.SwapBuffers() s.SwapBuffers()
} }
}() }()

View File

@@ -21,7 +21,7 @@ func LocateDMSConfig() (string, error) {
dataDirs = "/usr/local/share:/usr/share" dataDirs = "/usr/local/share:/usr/share"
} }
for _, dir := range strings.Split(dataDirs, ":") { for dir := range strings.SplitSeq(dataDirs, ":") {
if dir != "" { if dir != "" {
primaryPaths = append(primaryPaths, filepath.Join(dir, "quickshell", "dms")) primaryPaths = append(primaryPaths, filepath.Join(dir, "quickshell", "dms"))
} }
@@ -33,7 +33,7 @@ func LocateDMSConfig() (string, error) {
configDirs = "/etc/xdg" configDirs = "/etc/xdg"
} }
for _, dir := range strings.Split(configDirs, ":") { for dir := range strings.SplitSeq(configDirs, ":") {
if dir != "" { if dir != "" {
primaryPaths = append(primaryPaths, filepath.Join(dir, "quickshell", "dms")) primaryPaths = append(primaryPaths, filepath.Join(dir, "quickshell", "dms"))
} }

View File

@@ -345,7 +345,7 @@ func EnsureContrastDPSLstar(hexColor, hexBg string, minLc float64, isLightMode b
} }
step := 0.5 step := 0.5
for i := 0; i < 120; i++ { for range 120 {
Lf = math.Max(0, math.Min(100, Lf+dir*step)) Lf = math.Max(0, math.Min(100, Lf+dir*step))
cand := labToHex(Lf, af, bf) cand := labToHex(Lf, af, bf)
if DeltaPhiStarContrast(cand, hexBg, isLightMode) >= minLc { if DeltaPhiStarContrast(cand, hexBg, isLightMode) >= minLc {

View File

@@ -658,7 +658,7 @@ func TestContrastAlgorithmComparison(t *testing.T) {
} }
differentCount := 0 differentCount := 0
for i := 0; i < 16; i++ { for i := range 16 {
if wcagColors[i].Hex != dpsColors[i].Hex { if wcagColors[i].Hex != dpsColors[i].Hex {
differentCount++ differentCount++
} }

View File

@@ -7,6 +7,7 @@ import (
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime" "runtime"
"slices"
"strings" "strings"
"github.com/AvengeMedia/DankMaterialShell/core/internal/deps" "github.com/AvengeMedia/DankMaterialShell/core/internal/deps"
@@ -514,12 +515,9 @@ func (a *ArchDistribution) reorderAURPackages(packages []string) []string {
dmsShell = append(dmsShell, pkg) dmsShell = append(dmsShell, pkg)
} else { } else {
isDep := false isDep := false
for _, dep := range dmsDepencies { if slices.Contains(dmsDepencies, pkg) {
if pkg == dep { deps = append(deps, pkg)
deps = append(deps, pkg) isDep = true
isDep = true
break
}
} }
if !isDep { if !isDep {
others = append(others, pkg) others = append(others, pkg)
@@ -545,7 +543,7 @@ func (a *ArchDistribution) installSingleAURPackage(ctx context.Context, pkg, sud
a.log(fmt.Sprintf("Warning: failed to clean existing cache for %s: %v", pkg, err)) a.log(fmt.Sprintf("Warning: failed to clean existing cache for %s: %v", pkg, err))
} }
if err := os.MkdirAll(buildDir, 0755); err != nil { if err := os.MkdirAll(buildDir, 0o755); err != nil {
return fmt.Errorf("failed to create build directory: %w", err) return fmt.Errorf("failed to create build directory: %w", err)
} }
defer func() { defer func() {

View File

@@ -18,8 +18,8 @@ type ManualPackageInstaller struct {
// parseLatestTagFromGitOutput parses git ls-remote output and returns the latest tag // parseLatestTagFromGitOutput parses git ls-remote output and returns the latest tag
func (m *ManualPackageInstaller) parseLatestTagFromGitOutput(output string) string { func (m *ManualPackageInstaller) parseLatestTagFromGitOutput(output string) string {
lines := strings.Split(output, "\n") lines := strings.SplitSeq(output, "\n")
for _, line := range lines { for line := range lines {
if strings.Contains(line, "refs/tags/") && !strings.Contains(line, "^{}") { if strings.Contains(line, "refs/tags/") && !strings.Contains(line, "^{}") {
parts := strings.Split(line, "refs/tags/") parts := strings.Split(line, "refs/tags/")
if len(parts) > 1 { if len(parts) > 1 {
@@ -103,12 +103,12 @@ func (m *ManualPackageInstaller) installDgop(ctx context.Context, sudoPassword s
} }
cacheDir := filepath.Join(homeDir, ".cache", "dankinstall") cacheDir := filepath.Join(homeDir, ".cache", "dankinstall")
if err := os.MkdirAll(cacheDir, 0755); err != nil { if err := os.MkdirAll(cacheDir, 0o755); err != nil {
return fmt.Errorf("failed to create cache directory: %w", err) return fmt.Errorf("failed to create cache directory: %w", err)
} }
tmpDir := filepath.Join(cacheDir, "dgop-build") tmpDir := filepath.Join(cacheDir, "dgop-build")
if err := os.MkdirAll(tmpDir, 0755); err != nil { if err := os.MkdirAll(tmpDir, 0o755); err != nil {
return fmt.Errorf("failed to create temp directory: %w", err) return fmt.Errorf("failed to create temp directory: %w", err)
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@@ -160,10 +160,10 @@ func (m *ManualPackageInstaller) installNiri(ctx context.Context, sudoPassword s
homeDir, _ := os.UserHomeDir() homeDir, _ := os.UserHomeDir()
buildDir := filepath.Join(homeDir, ".cache", "dankinstall", "niri-build") buildDir := filepath.Join(homeDir, ".cache", "dankinstall", "niri-build")
tmpDir := filepath.Join(homeDir, ".cache", "dankinstall", "tmp") tmpDir := filepath.Join(homeDir, ".cache", "dankinstall", "tmp")
if err := os.MkdirAll(buildDir, 0755); err != nil { if err := os.MkdirAll(buildDir, 0o755); err != nil {
return fmt.Errorf("failed to create build directory: %w", err) return fmt.Errorf("failed to create build directory: %w", err)
} }
if err := os.MkdirAll(tmpDir, 0755); err != nil { if err := os.MkdirAll(tmpDir, 0o755); err != nil {
return fmt.Errorf("failed to create temp directory: %w", err) return fmt.Errorf("failed to create temp directory: %w", err)
} }
defer func() { defer func() {
@@ -237,12 +237,12 @@ func (m *ManualPackageInstaller) installQuickshell(ctx context.Context, variant
} }
cacheDir := filepath.Join(homeDir, ".cache", "dankinstall") cacheDir := filepath.Join(homeDir, ".cache", "dankinstall")
if err := os.MkdirAll(cacheDir, 0755); err != nil { if err := os.MkdirAll(cacheDir, 0o755); err != nil {
return fmt.Errorf("failed to create cache directory: %w", err) return fmt.Errorf("failed to create cache directory: %w", err)
} }
tmpDir := filepath.Join(cacheDir, "quickshell-build") tmpDir := filepath.Join(cacheDir, "quickshell-build")
if err := os.MkdirAll(tmpDir, 0755); err != nil { if err := os.MkdirAll(tmpDir, 0o755); err != nil {
return fmt.Errorf("failed to create temp directory: %w", err) return fmt.Errorf("failed to create temp directory: %w", err)
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@@ -273,7 +273,7 @@ func (m *ManualPackageInstaller) installQuickshell(ctx context.Context, variant
} }
buildDir := tmpDir + "/build" buildDir := tmpDir + "/build"
if err := os.MkdirAll(buildDir, 0755); err != nil { if err := os.MkdirAll(buildDir, 0o755); err != nil {
return fmt.Errorf("failed to create build directory: %w", err) return fmt.Errorf("failed to create build directory: %w", err)
} }
@@ -343,12 +343,12 @@ func (m *ManualPackageInstaller) installHyprland(ctx context.Context, sudoPasswo
} }
cacheDir := filepath.Join(homeDir, ".cache", "dankinstall") cacheDir := filepath.Join(homeDir, ".cache", "dankinstall")
if err := os.MkdirAll(cacheDir, 0755); err != nil { if err := os.MkdirAll(cacheDir, 0o755); err != nil {
return fmt.Errorf("failed to create cache directory: %w", err) return fmt.Errorf("failed to create cache directory: %w", err)
} }
tmpDir := filepath.Join(cacheDir, "hyprland-build") tmpDir := filepath.Join(cacheDir, "hyprland-build")
if err := os.MkdirAll(tmpDir, 0755); err != nil { if err := os.MkdirAll(tmpDir, 0o755); err != nil {
return fmt.Errorf("failed to create temp directory: %w", err) return fmt.Errorf("failed to create temp directory: %w", err)
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@@ -406,12 +406,12 @@ func (m *ManualPackageInstaller) installGhostty(ctx context.Context, sudoPasswor
} }
cacheDir := filepath.Join(homeDir, ".cache", "dankinstall") cacheDir := filepath.Join(homeDir, ".cache", "dankinstall")
if err := os.MkdirAll(cacheDir, 0755); err != nil { if err := os.MkdirAll(cacheDir, 0o755); err != nil {
return fmt.Errorf("failed to create cache directory: %w", err) return fmt.Errorf("failed to create cache directory: %w", err)
} }
tmpDir := filepath.Join(cacheDir, "ghostty-build") tmpDir := filepath.Join(cacheDir, "ghostty-build")
if err := os.MkdirAll(tmpDir, 0755); err != nil { if err := os.MkdirAll(tmpDir, 0o755); err != nil {
return fmt.Errorf("failed to create temp directory: %w", err) return fmt.Errorf("failed to create temp directory: %w", err)
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
@@ -528,7 +528,7 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, v
} }
configDir := filepath.Dir(dmsPath) configDir := filepath.Dir(dmsPath)
if err := os.MkdirAll(configDir, 0755); err != nil { if err := os.MkdirAll(configDir, 0o755); err != nil {
return fmt.Errorf("failed to create quickshell config directory: %w", err) return fmt.Errorf("failed to create quickshell config directory: %w", err)
} }

View File

@@ -23,7 +23,7 @@ func DefaultDiscoveryConfig() *DiscoveryConfig {
configDirs := os.Getenv("XDG_CONFIG_DIRS") configDirs := os.Getenv("XDG_CONFIG_DIRS")
if configDirs != "" { if configDirs != "" {
for _, dir := range strings.Split(configDirs, ":") { for dir := range strings.SplitSeq(configDirs, ":") {
if dir != "" { if dir != "" {
searchPaths = append(searchPaths, filepath.Join(dir, "DankMaterialShell", "cheatsheets")) searchPaths = append(searchPaths, filepath.Join(dir, "DankMaterialShell", "cheatsheets"))
} }

View File

@@ -12,7 +12,7 @@ func TestNewJSONFileProvider(t *testing.T) {
tmpDir := t.TempDir() tmpDir := t.TempDir()
testFile := filepath.Join(tmpDir, "test.json") testFile := filepath.Join(tmpDir, "test.json")
if err := os.WriteFile(testFile, []byte("{}"), 0644); err != nil { if err := os.WriteFile(testFile, []byte("{}"), 0o644); err != nil {
t.Fatalf("Failed to create test file: %v", err) t.Fatalf("Failed to create test file: %v", err)
} }
@@ -81,7 +81,7 @@ func TestJSONFileProviderGetCheatSheet(t *testing.T) {
} }
}` }`
if err := os.WriteFile(testFile, []byte(content), 0644); err != nil { if err := os.WriteFile(testFile, []byte(content), 0o644); err != nil {
t.Fatalf("Failed to write test file: %v", err) t.Fatalf("Failed to write test file: %v", err)
} }
@@ -135,7 +135,7 @@ func TestJSONFileProviderGetCheatSheetNoProvider(t *testing.T) {
"binds": {} "binds": {}
}` }`
if err := os.WriteFile(testFile, []byte(content), 0644); err != nil { if err := os.WriteFile(testFile, []byte(content), 0o644); err != nil {
t.Fatalf("Failed to write test file: %v", err) t.Fatalf("Failed to write test file: %v", err)
} }
@@ -181,7 +181,7 @@ func TestJSONFileProviderFlatArrayBackwardsCompat(t *testing.T) {
] ]
}` }`
if err := os.WriteFile(testFile, []byte(content), 0644); err != nil { if err := os.WriteFile(testFile, []byte(content), 0o644); err != nil {
t.Fatalf("Failed to write test file: %v", err) t.Fatalf("Failed to write test file: %v", err)
} }
@@ -216,7 +216,7 @@ func TestJSONFileProviderInvalidJSON(t *testing.T) {
tmpDir := t.TempDir() tmpDir := t.TempDir()
testFile := filepath.Join(tmpDir, "invalid.json") testFile := filepath.Join(tmpDir, "invalid.json")
if err := os.WriteFile(testFile, []byte("not valid json"), 0644); err != nil { if err := os.WriteFile(testFile, []byte("not valid json"), 0o644); err != nil {
t.Fatalf("Failed to write test file: %v", err) t.Fatalf("Failed to write test file: %v", err)
} }

View File

@@ -205,6 +205,27 @@ Singleton {
const result = {}; const result = {};
const lines = content.split("\n"); const lines = content.split("\n");
for (const line of lines) { for (const line of lines) {
const disableMatch = line.match(/^\s*monitor\s*=\s*([^,]+),\s*disable\s*$/);
if (disableMatch) {
const name = disableMatch[1].trim();
result[name] = {
"name": name,
"logical": {
"x": 0,
"y": 0,
"scale": 1.0,
"transform": "Normal"
},
"modes": [],
"current_mode": -1,
"vrr_enabled": false,
"vrr_supported": false,
"hyprlandSettings": {
"disabled": true
}
};
continue;
}
const match = line.match(/^\s*monitor\s*=\s*([^,]+),\s*(\d+)x(\d+)@([\d.]+),\s*(-?\d+)x(-?\d+),\s*([\d.]+)/); const match = line.match(/^\s*monitor\s*=\s*([^,]+),\s*(\d+)x(\d+)@([\d.]+),\s*(-?\d+)x(-?\d+),\s*([\d.]+)/);
if (!match) if (!match)
continue; continue;
@@ -842,6 +863,8 @@ Singleton {
for (const outputId in pendingHyprlandChanges) { for (const outputId in pendingHyprlandChanges) {
const changes = pendingHyprlandChanges[outputId]; const changes = pendingHyprlandChanges[outputId];
if (changes.disabled !== undefined)
changeDescriptions.push(outputId + ": " + I18n.tr("Disabled") + " → " + (changes.disabled ? I18n.tr("Yes") : I18n.tr("No")));
if (changes.bitdepth !== undefined) if (changes.bitdepth !== undefined)
changeDescriptions.push(outputId + ": " + I18n.tr("Bit Depth") + " → " + changes.bitdepth); changeDescriptions.push(outputId + ": " + I18n.tr("Bit Depth") + " → " + changes.bitdepth);
if (changes.colorManagement !== undefined) if (changes.colorManagement !== undefined)

View File

@@ -71,6 +71,13 @@ Column {
} }
property bool isHdrMode: currentCm === "hdr" || currentCm === "hdredid" property bool isHdrMode: currentCm === "hdr" || currentCm === "hdredid"
DankToggle {
width: parent.width
text: I18n.tr("Disable Output")
checked: DisplayConfigState.getHyprlandSetting(root.outputData, root.outputName, "disabled", false)
onToggled: checked => DisplayConfigState.setHyprlandSetting(root.outputData, root.outputName, "disabled", checked)
}
DankDropdown { DankDropdown {
width: parent.width width: parent.width
text: I18n.tr("Mirror Display") text: I18n.tr("Mirror Display")
@@ -138,26 +145,26 @@ Column {
options: [I18n.tr("Auto (Wide)"), I18n.tr("Wide (BT2020)"), "DCI-P3", "Apple P3", "Adobe RGB", "EDID", "HDR", I18n.tr("HDR (EDID)")] options: [I18n.tr("Auto (Wide)"), I18n.tr("Wide (BT2020)"), "DCI-P3", "Apple P3", "Adobe RGB", "EDID", "HDR", I18n.tr("HDR (EDID)")]
property var cmValueMap: ({ property var cmValueMap: ({
[I18n.tr("Auto (Wide)")]: "auto", [I18n.tr("Auto (Wide)")]: "auto",
[I18n.tr("Wide (BT2020)")]: "wide", [I18n.tr("Wide (BT2020)")]: "wide",
"DCI-P3": "dcip3", "DCI-P3": "dcip3",
"Apple P3": "dp3", "Apple P3": "dp3",
"Adobe RGB": "adobe", "Adobe RGB": "adobe",
"EDID": "edid", "EDID": "edid",
"HDR": "hdr", "HDR": "hdr",
[I18n.tr("HDR (EDID)")]: "hdredid" [I18n.tr("HDR (EDID)")]: "hdredid"
}) })
property var cmLabelMap: ({ property var cmLabelMap: ({
"auto": I18n.tr("Auto (Wide)"), "auto": I18n.tr("Auto (Wide)"),
"wide": I18n.tr("Wide (BT2020)"), "wide": I18n.tr("Wide (BT2020)"),
"dcip3": "DCI-P3", "dcip3": "DCI-P3",
"dp3": "Apple P3", "dp3": "Apple P3",
"adobe": "Adobe RGB", "adobe": "Adobe RGB",
"edid": "EDID", "edid": "EDID",
"hdr": "HDR", "hdr": "HDR",
"hdredid": I18n.tr("HDR (EDID)") "hdredid": I18n.tr("HDR (EDID)")
}) })
onValueChanged: value => { onValueChanged: value => {
const cmValue = cmValueMap[value] || "auto"; const cmValue = cmValueMap[value] || "auto";

View File

@@ -35,6 +35,11 @@ Singleton {
const identifier = getOutputIdentifier(output, outputName); const identifier = getOutputIdentifier(output, outputName);
const outputSettings = settings[identifier] || {}; const outputSettings = settings[identifier] || {};
if (outputSettings.disabled) {
lines.push("monitor = " + identifier + ", disable");
continue;
}
let resolution = "preferred"; let resolution = "preferred";
if (output.modes && output.current_mode !== undefined) { if (output.modes && output.current_mode !== undefined) {
const mode = output.modes[output.current_mode]; const mode = output.modes[output.current_mode];
@@ -73,10 +78,7 @@ Singleton {
lines.push(monitorLine); lines.push(monitorLine);
const needsMonitorv2 = outputSettings.supportsHdr || outputSettings.supportsWideColor || const needsMonitorv2 = outputSettings.supportsHdr || outputSettings.supportsWideColor || outputSettings.sdrMinLuminance !== undefined || outputSettings.sdrMaxLuminance !== undefined || outputSettings.minLuminance !== undefined || outputSettings.maxLuminance !== undefined || outputSettings.maxAvgLuminance !== undefined;
outputSettings.sdrMinLuminance !== undefined || outputSettings.sdrMaxLuminance !== undefined ||
outputSettings.minLuminance !== undefined || outputSettings.maxLuminance !== undefined ||
outputSettings.maxAvgLuminance !== undefined;
if (needsMonitorv2) { if (needsMonitorv2) {
let block = "monitorv2 {\n"; let block = "monitorv2 {\n";

View File

@@ -5,48 +5,81 @@ return {
config = function() config = function()
require('base16-colorscheme').setup({ require('base16-colorscheme').setup({
base00 = '{{dank16.color0.default.hex}}', base00 = '{{dank16.color0.default.hex}}',
base01 = '{{dank16.color8.default.hex}}', base01 = '{{dank16.color0.default.hex}}',
base02 = '{{dank16.color14.default.hex}}', base02 = '{{dank16.color8.default.hex}}',
base03 = '{{dank16.color5.default.hex}}', base03 = '{{dank16.color8.default.hex}}',
base04 = '{{dank16.color7.default.hex}}', base04 = '{{dank16.color7.default.hex}}',
base05 = '{{dank16.color12.default.hex}}', base05 = '{{dank16.color15.default.hex}}',
base06 = '{{dank16.color6.default.hex}}', base06 = '{{dank16.color15.default.hex}}',
base07 = '{{dank16.color15.default.hex}}', base07 = '{{dank16.color15.default.hex}}',
base08 = '{{dank16.color9.default.hex}}',
base08 = '{{dank16.color4.default.hex}}', base09 = '{{dank16.color9.default.hex}}',
base09 = '{{dank16.color3.default.hex}}', base0A = '{{dank16.color12.default.hex}}',
base0A = '{{dank16.color11.default.hex}}', base0B = '{{dank16.color10.default.hex}}',
base0B = '{{dank16.color2.default.hex}}', base0C = '{{dank16.color14.default.hex}}',
base0C = '{{dank16.color10.default.hex}}', base0D = '{{dank16.color12.default.hex}}',
base0D = '{{dank16.color9.default.hex}}', base0E = '{{dank16.color13.default.hex}}',
base0E = '{{dank16.color1.default.hex}}',
base0F = '{{dank16.color13.default.hex}}', base0F = '{{dank16.color13.default.hex}}',
}) })
vim.api.nvim_set_hl(0, 'Visual', { vim.api.nvim_set_hl(0, 'Visual', {
bg = '{{dank16.color14.default.hex}}', bg = '{{dank16.color8.default.hex}}',
fg = '{{dank16.color15.default.hex}}', fg = '{{dank16.color15.default.hex}}',
bold = true bold = true
}) })
vim.api.nvim_set_hl(0, 'Statusline', {
bg = '{{dank16.color12.default.hex}}',
fg = '{{dank16.color0.default.hex}}',
})
vim.api.nvim_set_hl(0, 'LineNr', { fg = '{{dank16.color8.default.hex}}' })
vim.api.nvim_set_hl(0, 'CursorLineNr', { fg = '{{dank16.color14.default.hex}}', bold = true })
vim.api.nvim_set_hl(0, 'LineNr', { vim.api.nvim_set_hl(0, 'Statement', {
fg = '{{dank16.color8.default.hex}}' fg = '{{dank16.color13.default.hex}}',
bold = true
})
vim.api.nvim_set_hl(0, 'Keyword', { link = 'Statement' })
vim.api.nvim_set_hl(0, 'Repeat', { link = 'Statement' })
vim.api.nvim_set_hl(0, 'Conditional', { link = 'Statement' })
vim.api.nvim_set_hl(0, 'Function', {
fg = '{{dank16.color12.default.hex}}',
bold = true
})
vim.api.nvim_set_hl(0, 'Macro', {
fg = '{{dank16.color12.default.hex}}',
italic = true
})
vim.api.nvim_set_hl(0, '@function.macro', { link = 'Macro' })
vim.api.nvim_set_hl(0, 'Type', {
fg = '{{dank16.color14.default.hex}}',
bold = true,
italic = true
})
vim.api.nvim_set_hl(0, 'Structure', { link = 'Type' })
vim.api.nvim_set_hl(0, 'String', {
fg = '{{dank16.color10.default.hex}}',
italic = true
}) })
vim.api.nvim_set_hl(0, 'CursorLineNr', { vim.api.nvim_set_hl(0, 'Operator', { fg = '{{dank16.color7.default.hex}}' })
fg = '{{dank16.color6.default.hex}}', vim.api.nvim_set_hl(0, 'Delimiter', { fg = '{{dank16.color7.default.hex}}' })
bold = true vim.api.nvim_set_hl(0, '@punctuation.bracket', { link = 'Delimiter' })
vim.api.nvim_set_hl(0, '@punctuation.delimiter', { link = 'Delimiter' })
vim.api.nvim_set_hl(0, 'Comment', {
fg = '{{dank16.color8.default.hex}}',
italic = true
}) })
local current_file_path = vim.fn.stdpath("config") .. "/lua/plugins/dankcolors.lua" local current_file_path = vim.fn.stdpath("config") .. "/lua/plugins/dankcolors.lua"
if not _G._matugen_theme_watcher then if not _G._matugen_theme_watcher then
local uv = vim.uv or vim.loop local uv = vim.uv or vim.loop
_G._matugen_theme_watcher = uv.new_fs_event() _G._matugen_theme_watcher = uv.new_fs_event()
_G._matugen_theme_watcher:start(current_file_path, {}, vim.schedule_wrap(function() _G._matugen_theme_watcher:start(current_file_path, {}, vim.schedule_wrap(function()
local new_spec = dofile(current_file_path) local new_spec = dofile(current_file_path)
if new_spec and new_spec[1] and new_spec[1].config then if new_spec and new_spec[1] and new_spec[1].config then
new_spec[1].config() new_spec[1].config()
print("Theme reload") print("Theme reload")