mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
Compare commits
3 Commits
c281bf3b53
...
f08e2ef5b8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f08e2ef5b8 | ||
|
|
2b0070c31a | ||
|
|
ae82716afa |
@@ -179,7 +179,7 @@ func runBrightnessList(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("%-*s %-12s %-*s %s\n", idPad, "Device", "Class", namePad, "Name", "Brightness")
|
||||
|
||||
sepLen := idPad + 2 + 12 + 2 + namePad + 2 + 15
|
||||
for i := 0; i < sepLen; i++ {
|
||||
for range sepLen {
|
||||
fmt.Print("─")
|
||||
}
|
||||
fmt.Println()
|
||||
|
||||
@@ -377,7 +377,7 @@ func updateDMSBinary() error {
|
||||
}
|
||||
|
||||
version := ""
|
||||
for _, line := range strings.Split(string(output), "\n") {
|
||||
for line := range strings.SplitSeq(string(output), "\n") {
|
||||
if strings.Contains(line, "\"tag_name\"") {
|
||||
parts := strings.Split(line, "\"")
|
||||
if len(parts) >= 4 {
|
||||
@@ -443,7 +443,7 @@ func updateDMSBinary() error {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -211,8 +211,8 @@ func checkGroupExists(groupName string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
lines := strings.Split(string(data), "\n")
|
||||
for _, line := range lines {
|
||||
lines := strings.SplitSeq(string(data), "\n")
|
||||
for line := range lines {
|
||||
if strings.HasPrefix(line, groupName+":") {
|
||||
return true
|
||||
}
|
||||
@@ -521,7 +521,7 @@ func enableGreeter() error {
|
||||
newConfig := strings.Join(finalLines, "\n")
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -592,8 +592,8 @@ func checkGreeterStatus() error {
|
||||
if data, err := os.ReadFile(configPath); err == nil {
|
||||
configContent := string(data)
|
||||
if strings.Contains(configContent, "dms-greeter") {
|
||||
lines := strings.Split(configContent, "\n")
|
||||
for _, line := range lines {
|
||||
lines := strings.SplitSeq(configContent, "\n")
|
||||
for line := range lines {
|
||||
trimmed := strings.TrimSpace(line)
|
||||
if strings.HasPrefix(trimmed, "command =") || strings.HasPrefix(trimmed, "command=") {
|
||||
parts := strings.SplitN(trimmed, "=", 2)
|
||||
|
||||
@@ -87,20 +87,14 @@ func newDPMSClient() (*dpmsClient, error) {
|
||||
switch e.Interface {
|
||||
case wlr_output_power.ZwlrOutputPowerManagerV1InterfaceName:
|
||||
powerMgr := wlr_output_power.NewZwlrOutputPowerManagerV1(c.ctx)
|
||||
version := e.Version
|
||||
if version > 1 {
|
||||
version = 1
|
||||
}
|
||||
version := min(e.Version, 1)
|
||||
if err := registry.Bind(e.Name, e.Interface, version, powerMgr); err == nil {
|
||||
c.powerMgr = powerMgr
|
||||
}
|
||||
|
||||
case "wl_output":
|
||||
output := wlclient.NewOutput(c.ctx)
|
||||
version := e.Version
|
||||
if version > 4 {
|
||||
version = 4
|
||||
}
|
||||
version := min(e.Version, 4)
|
||||
if err := registry.Bind(e.Name, e.Interface, version, output); err == nil {
|
||||
outputID := fmt.Sprintf("output-%d", output.ID())
|
||||
state := &outputState{
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -371,13 +372,7 @@ func killShell() {
|
||||
|
||||
func runShellDaemon(session bool) {
|
||||
isSessionManaged = session
|
||||
isDaemonChild := false
|
||||
for _, arg := range os.Args {
|
||||
if arg == "--daemon-child" {
|
||||
isDaemonChild = true
|
||||
break
|
||||
}
|
||||
}
|
||||
isDaemonChild := slices.Contains(os.Args, "--daemon-child")
|
||||
|
||||
if !isDaemonChild {
|
||||
fmt.Fprintf(os.Stderr, "dms %s\n", Version)
|
||||
@@ -534,9 +529,9 @@ func runShellDaemon(session bool) {
|
||||
func parseTargetsFromIPCShowOutput(output string) ipcTargets {
|
||||
targets := make(ipcTargets)
|
||||
var currentTarget string
|
||||
for _, line := range strings.Split(output, "\n") {
|
||||
if strings.HasPrefix(line, "target ") {
|
||||
currentTarget = strings.TrimSpace(strings.TrimPrefix(line, "target "))
|
||||
for line := range strings.SplitSeq(output, "\n") {
|
||||
if after, ok := strings.CutPrefix(line, "target "); ok {
|
||||
currentTarget = strings.TrimSpace(after)
|
||||
targets[currentTarget] = make(map[string][]string)
|
||||
}
|
||||
if strings.HasPrefix(line, " function") && currentTarget != "" {
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -36,13 +37,7 @@ func checkSystemdServiceEnabled(serviceName string) (string, bool, error) {
|
||||
|
||||
if err != nil {
|
||||
knownStates := []string{"disabled", "masked", "masked-runtime", "not-found", "enabled", "enabled-runtime", "static", "indirect", "alias"}
|
||||
isKnownState := false
|
||||
for _, known := range knownStates {
|
||||
if stateStr == known {
|
||||
isKnownState = true
|
||||
break
|
||||
}
|
||||
}
|
||||
isKnownState := slices.Contains(knownStates, stateStr)
|
||||
|
||||
if !isKnownState {
|
||||
return stateStr, false, fmt.Errorf("systemctl is-enabled failed: %w (output: %s)", err, stateStr)
|
||||
|
||||
@@ -221,10 +221,7 @@ func (p *Picker) handleGlobal(e client.RegistryGlobalEvent) {
|
||||
|
||||
case client.OutputInterfaceName:
|
||||
output := client.NewOutput(p.ctx)
|
||||
version := e.Version
|
||||
if version > 4 {
|
||||
version = 4
|
||||
}
|
||||
version := min(e.Version, 4)
|
||||
if err := p.registry.Bind(e.Name, e.Interface, version, output); err == nil {
|
||||
p.outputsMu.Lock()
|
||||
p.outputs[e.Name] = &Output{
|
||||
@@ -239,20 +236,14 @@ func (p *Picker) handleGlobal(e client.RegistryGlobalEvent) {
|
||||
|
||||
case wlr_layer_shell.ZwlrLayerShellV1InterfaceName:
|
||||
layerShell := wlr_layer_shell.NewZwlrLayerShellV1(p.ctx)
|
||||
version := e.Version
|
||||
if version > 4 {
|
||||
version = 4
|
||||
}
|
||||
version := min(e.Version, 4)
|
||||
if err := p.registry.Bind(e.Name, e.Interface, version, layerShell); err == nil {
|
||||
p.layerShell = layerShell
|
||||
}
|
||||
|
||||
case wlr_screencopy.ZwlrScreencopyManagerV1InterfaceName:
|
||||
screencopy := wlr_screencopy.NewZwlrScreencopyManagerV1(p.ctx)
|
||||
version := e.Version
|
||||
if version > 3 {
|
||||
version = 3
|
||||
}
|
||||
version := min(e.Version, 3)
|
||||
if err := p.registry.Bind(e.Name, e.Interface, version, screencopy); err == nil {
|
||||
p.screencopy = screencopy
|
||||
}
|
||||
|
||||
@@ -1157,7 +1157,7 @@ func drawGlyph(data []byte, stride, width, height, x, y int, r rune, col Color,
|
||||
rOff, bOff = 2, 0
|
||||
}
|
||||
|
||||
for row := 0; row < fontH; row++ {
|
||||
for row := range fontH {
|
||||
yy := y + row
|
||||
if yy < 0 || yy >= height {
|
||||
continue
|
||||
@@ -1165,7 +1165,7 @@ func drawGlyph(data []byte, stride, width, height, x, y int, r rune, col Color,
|
||||
rowPattern := g[row]
|
||||
dstRowOff := yy * stride
|
||||
|
||||
for colIdx := 0; colIdx < fontW; colIdx++ {
|
||||
for colIdx := range fontW {
|
||||
if (rowPattern & (1 << (fontW - 1 - colIdx))) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ func TestSurfaceState_ConcurrentPointerMotion(t *testing.T) {
|
||||
const goroutines = 50
|
||||
const iterations = 100
|
||||
|
||||
for i := 0; i < goroutines; i++ {
|
||||
for i := range goroutines {
|
||||
wg.Add(1)
|
||||
go func(id int) {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for j := range iterations {
|
||||
s.OnPointerMotion(float64(id*10+j), float64(id*10+j))
|
||||
}
|
||||
}(i)
|
||||
@@ -34,21 +34,21 @@ func TestSurfaceState_ConcurrentScaleAccess(t *testing.T) {
|
||||
const goroutines = 30
|
||||
const iterations = 100
|
||||
|
||||
for i := 0; i < goroutines/2; i++ {
|
||||
for i := range goroutines / 2 {
|
||||
wg.Add(1)
|
||||
go func(id int) {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
s.SetScale(int32(id%3 + 1))
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
|
||||
for i := 0; i < goroutines/2; i++ {
|
||||
for range goroutines / 2 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
scale := s.Scale()
|
||||
assert.GreaterOrEqual(t, scale, int32(1))
|
||||
}
|
||||
@@ -65,21 +65,21 @@ func TestSurfaceState_ConcurrentLogicalSize(t *testing.T) {
|
||||
const goroutines = 20
|
||||
const iterations = 100
|
||||
|
||||
for i := 0; i < goroutines/2; i++ {
|
||||
for i := range goroutines / 2 {
|
||||
wg.Add(1)
|
||||
go func(id int) {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for j := range iterations {
|
||||
_ = s.OnLayerConfigure(1920+id, 1080+j)
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
|
||||
for i := 0; i < goroutines/2; i++ {
|
||||
for range goroutines / 2 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
w, h := s.LogicalSize()
|
||||
_ = w
|
||||
_ = h
|
||||
@@ -97,31 +97,31 @@ func TestSurfaceState_ConcurrentIsDone(t *testing.T) {
|
||||
const goroutines = 30
|
||||
const iterations = 100
|
||||
|
||||
for i := 0; i < goroutines/3; i++ {
|
||||
for range goroutines / 3 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
s.OnPointerButton(0x110, 1)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
for i := 0; i < goroutines/3; i++ {
|
||||
for range goroutines / 3 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
s.OnKey(1, 1)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
for i := 0; i < goroutines/3; i++ {
|
||||
for range goroutines / 3 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
picked, cancelled := s.IsDone()
|
||||
_ = picked
|
||||
_ = cancelled
|
||||
@@ -139,11 +139,11 @@ func TestSurfaceState_ConcurrentIsReady(t *testing.T) {
|
||||
const goroutines = 20
|
||||
const iterations = 100
|
||||
|
||||
for i := 0; i < goroutines; i++ {
|
||||
for range goroutines {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
_ = s.IsReady()
|
||||
}
|
||||
}()
|
||||
@@ -159,11 +159,11 @@ func TestSurfaceState_ConcurrentSwapBuffers(t *testing.T) {
|
||||
const goroutines = 20
|
||||
const iterations = 100
|
||||
|
||||
for i := 0; i < goroutines; i++ {
|
||||
for range goroutines {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
for range iterations {
|
||||
s.SwapBuffers()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -21,7 +21,7 @@ func LocateDMSConfig() (string, error) {
|
||||
dataDirs = "/usr/local/share:/usr/share"
|
||||
}
|
||||
|
||||
for _, dir := range strings.Split(dataDirs, ":") {
|
||||
for dir := range strings.SplitSeq(dataDirs, ":") {
|
||||
if dir != "" {
|
||||
primaryPaths = append(primaryPaths, filepath.Join(dir, "quickshell", "dms"))
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func LocateDMSConfig() (string, error) {
|
||||
configDirs = "/etc/xdg"
|
||||
}
|
||||
|
||||
for _, dir := range strings.Split(configDirs, ":") {
|
||||
for dir := range strings.SplitSeq(configDirs, ":") {
|
||||
if dir != "" {
|
||||
primaryPaths = append(primaryPaths, filepath.Join(dir, "quickshell", "dms"))
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ func EnsureContrastDPSLstar(hexColor, hexBg string, minLc float64, isLightMode b
|
||||
}
|
||||
|
||||
step := 0.5
|
||||
for i := 0; i < 120; i++ {
|
||||
for range 120 {
|
||||
Lf = math.Max(0, math.Min(100, Lf+dir*step))
|
||||
cand := labToHex(Lf, af, bf)
|
||||
if DeltaPhiStarContrast(cand, hexBg, isLightMode) >= minLc {
|
||||
|
||||
@@ -658,7 +658,7 @@ func TestContrastAlgorithmComparison(t *testing.T) {
|
||||
}
|
||||
|
||||
differentCount := 0
|
||||
for i := 0; i < 16; i++ {
|
||||
for i := range 16 {
|
||||
if wcagColors[i].Hex != dpsColors[i].Hex {
|
||||
differentCount++
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/deps"
|
||||
@@ -514,12 +515,9 @@ func (a *ArchDistribution) reorderAURPackages(packages []string) []string {
|
||||
dmsShell = append(dmsShell, pkg)
|
||||
} else {
|
||||
isDep := false
|
||||
for _, dep := range dmsDepencies {
|
||||
if pkg == dep {
|
||||
deps = append(deps, pkg)
|
||||
isDep = true
|
||||
break
|
||||
}
|
||||
if slices.Contains(dmsDepencies, pkg) {
|
||||
deps = append(deps, pkg)
|
||||
isDep = true
|
||||
}
|
||||
if !isDep {
|
||||
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))
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
defer func() {
|
||||
|
||||
@@ -18,8 +18,8 @@ type ManualPackageInstaller struct {
|
||||
|
||||
// parseLatestTagFromGitOutput parses git ls-remote output and returns the latest tag
|
||||
func (m *ManualPackageInstaller) parseLatestTagFromGitOutput(output string) string {
|
||||
lines := strings.Split(output, "\n")
|
||||
for _, line := range lines {
|
||||
lines := strings.SplitSeq(output, "\n")
|
||||
for line := range lines {
|
||||
if strings.Contains(line, "refs/tags/") && !strings.Contains(line, "^{}") {
|
||||
parts := strings.Split(line, "refs/tags/")
|
||||
if len(parts) > 1 {
|
||||
@@ -103,12 +103,12 @@ func (m *ManualPackageInstaller) installDgop(ctx context.Context, sudoPassword s
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
@@ -160,10 +160,10 @@ func (m *ManualPackageInstaller) installNiri(ctx context.Context, sudoPassword s
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
buildDir := filepath.Join(homeDir, ".cache", "dankinstall", "niri-build")
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
defer func() {
|
||||
@@ -237,12 +237,12 @@ func (m *ManualPackageInstaller) installQuickshell(ctx context.Context, variant
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
@@ -273,7 +273,7 @@ func (m *ManualPackageInstaller) installQuickshell(ctx context.Context, variant
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -343,12 +343,12 @@ func (m *ManualPackageInstaller) installHyprland(ctx context.Context, sudoPasswo
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
@@ -406,12 +406,12 @@ func (m *ManualPackageInstaller) installGhostty(ctx context.Context, sudoPasswor
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
@@ -528,7 +528,7 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, v
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func DefaultDiscoveryConfig() *DiscoveryConfig {
|
||||
|
||||
configDirs := os.Getenv("XDG_CONFIG_DIRS")
|
||||
if configDirs != "" {
|
||||
for _, dir := range strings.Split(configDirs, ":") {
|
||||
for dir := range strings.SplitSeq(configDirs, ":") {
|
||||
if dir != "" {
|
||||
searchPaths = append(searchPaths, filepath.Join(dir, "DankMaterialShell", "cheatsheets"))
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func TestNewJSONFileProvider(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func TestJSONFileProviderGetCheatSheetNoProvider(t *testing.T) {
|
||||
"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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ func TestJSONFileProviderInvalidJSON(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -205,6 +205,27 @@ Singleton {
|
||||
const result = {};
|
||||
const lines = content.split("\n");
|
||||
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.]+)/);
|
||||
if (!match)
|
||||
continue;
|
||||
@@ -842,6 +863,8 @@ Singleton {
|
||||
|
||||
for (const outputId in pendingHyprlandChanges) {
|
||||
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)
|
||||
changeDescriptions.push(outputId + ": " + I18n.tr("Bit Depth") + " → " + changes.bitdepth);
|
||||
if (changes.colorManagement !== undefined)
|
||||
|
||||
@@ -71,6 +71,13 @@ Column {
|
||||
}
|
||||
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 {
|
||||
width: parent.width
|
||||
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)")]
|
||||
|
||||
property var cmValueMap: ({
|
||||
[I18n.tr("Auto (Wide)")]: "auto",
|
||||
[I18n.tr("Wide (BT2020)")]: "wide",
|
||||
"DCI-P3": "dcip3",
|
||||
"Apple P3": "dp3",
|
||||
"Adobe RGB": "adobe",
|
||||
"EDID": "edid",
|
||||
"HDR": "hdr",
|
||||
[I18n.tr("HDR (EDID)")]: "hdredid"
|
||||
})
|
||||
[I18n.tr("Auto (Wide)")]: "auto",
|
||||
[I18n.tr("Wide (BT2020)")]: "wide",
|
||||
"DCI-P3": "dcip3",
|
||||
"Apple P3": "dp3",
|
||||
"Adobe RGB": "adobe",
|
||||
"EDID": "edid",
|
||||
"HDR": "hdr",
|
||||
[I18n.tr("HDR (EDID)")]: "hdredid"
|
||||
})
|
||||
|
||||
property var cmLabelMap: ({
|
||||
"auto": I18n.tr("Auto (Wide)"),
|
||||
"wide": I18n.tr("Wide (BT2020)"),
|
||||
"dcip3": "DCI-P3",
|
||||
"dp3": "Apple P3",
|
||||
"adobe": "Adobe RGB",
|
||||
"edid": "EDID",
|
||||
"hdr": "HDR",
|
||||
"hdredid": I18n.tr("HDR (EDID)")
|
||||
})
|
||||
"auto": I18n.tr("Auto (Wide)"),
|
||||
"wide": I18n.tr("Wide (BT2020)"),
|
||||
"dcip3": "DCI-P3",
|
||||
"dp3": "Apple P3",
|
||||
"adobe": "Adobe RGB",
|
||||
"edid": "EDID",
|
||||
"hdr": "HDR",
|
||||
"hdredid": I18n.tr("HDR (EDID)")
|
||||
})
|
||||
|
||||
onValueChanged: value => {
|
||||
const cmValue = cmValueMap[value] || "auto";
|
||||
|
||||
@@ -35,6 +35,11 @@ Singleton {
|
||||
const identifier = getOutputIdentifier(output, outputName);
|
||||
const outputSettings = settings[identifier] || {};
|
||||
|
||||
if (outputSettings.disabled) {
|
||||
lines.push("monitor = " + identifier + ", disable");
|
||||
continue;
|
||||
}
|
||||
|
||||
let resolution = "preferred";
|
||||
if (output.modes && output.current_mode !== undefined) {
|
||||
const mode = output.modes[output.current_mode];
|
||||
@@ -73,10 +78,7 @@ Singleton {
|
||||
|
||||
lines.push(monitorLine);
|
||||
|
||||
const needsMonitorv2 = outputSettings.supportsHdr || outputSettings.supportsWideColor ||
|
||||
outputSettings.sdrMinLuminance !== undefined || outputSettings.sdrMaxLuminance !== undefined ||
|
||||
outputSettings.minLuminance !== undefined || outputSettings.maxLuminance !== undefined ||
|
||||
outputSettings.maxAvgLuminance !== undefined;
|
||||
const needsMonitorv2 = outputSettings.supportsHdr || outputSettings.supportsWideColor || outputSettings.sdrMinLuminance !== undefined || outputSettings.sdrMaxLuminance !== undefined || outputSettings.minLuminance !== undefined || outputSettings.maxLuminance !== undefined || outputSettings.maxAvgLuminance !== undefined;
|
||||
|
||||
if (needsMonitorv2) {
|
||||
let block = "monitorv2 {\n";
|
||||
|
||||
@@ -5,48 +5,81 @@ return {
|
||||
config = function()
|
||||
require('base16-colorscheme').setup({
|
||||
base00 = '{{dank16.color0.default.hex}}',
|
||||
base01 = '{{dank16.color8.default.hex}}',
|
||||
base02 = '{{dank16.color14.default.hex}}',
|
||||
base03 = '{{dank16.color5.default.hex}}',
|
||||
base01 = '{{dank16.color0.default.hex}}',
|
||||
base02 = '{{dank16.color8.default.hex}}',
|
||||
base03 = '{{dank16.color8.default.hex}}',
|
||||
base04 = '{{dank16.color7.default.hex}}',
|
||||
base05 = '{{dank16.color12.default.hex}}',
|
||||
base06 = '{{dank16.color6.default.hex}}',
|
||||
base05 = '{{dank16.color15.default.hex}}',
|
||||
base06 = '{{dank16.color15.default.hex}}',
|
||||
base07 = '{{dank16.color15.default.hex}}',
|
||||
|
||||
base08 = '{{dank16.color4.default.hex}}',
|
||||
base09 = '{{dank16.color3.default.hex}}',
|
||||
base0A = '{{dank16.color11.default.hex}}',
|
||||
base0B = '{{dank16.color2.default.hex}}',
|
||||
base0C = '{{dank16.color10.default.hex}}',
|
||||
base0D = '{{dank16.color9.default.hex}}',
|
||||
base0E = '{{dank16.color1.default.hex}}',
|
||||
base08 = '{{dank16.color9.default.hex}}',
|
||||
base09 = '{{dank16.color9.default.hex}}',
|
||||
base0A = '{{dank16.color12.default.hex}}',
|
||||
base0B = '{{dank16.color10.default.hex}}',
|
||||
base0C = '{{dank16.color14.default.hex}}',
|
||||
base0D = '{{dank16.color12.default.hex}}',
|
||||
base0E = '{{dank16.color13.default.hex}}',
|
||||
base0F = '{{dank16.color13.default.hex}}',
|
||||
})
|
||||
|
||||
vim.api.nvim_set_hl(0, 'Visual', {
|
||||
bg = '{{dank16.color14.default.hex}}',
|
||||
bg = '{{dank16.color8.default.hex}}',
|
||||
fg = '{{dank16.color15.default.hex}}',
|
||||
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', {
|
||||
fg = '{{dank16.color8.default.hex}}'
|
||||
vim.api.nvim_set_hl(0, 'Statement', {
|
||||
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', {
|
||||
fg = '{{dank16.color6.default.hex}}',
|
||||
bold = true
|
||||
vim.api.nvim_set_hl(0, 'Operator', { fg = '{{dank16.color7.default.hex}}' })
|
||||
vim.api.nvim_set_hl(0, 'Delimiter', { fg = '{{dank16.color7.default.hex}}' })
|
||||
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"
|
||||
|
||||
if not _G._matugen_theme_watcher then
|
||||
local uv = vim.uv or vim.loop
|
||||
_G._matugen_theme_watcher = uv.new_fs_event()
|
||||
|
||||
_G._matugen_theme_watcher:start(current_file_path, {}, vim.schedule_wrap(function()
|
||||
local new_spec = dofile(current_file_path)
|
||||
|
||||
if new_spec and new_spec[1] and new_spec[1].config then
|
||||
new_spec[1].config()
|
||||
print("Theme reload")
|
||||
|
||||
Reference in New Issue
Block a user