summaryrefslogtreecommitdiff
path: root/raveos-hyprland-theme/theme-data/DankMaterialShell/core/internal/screenshot/theme.go
diff options
context:
space:
mode:
authorNippy <nippy@rp1.hu>2026-05-09 13:33:09 +0200
committerNippy <nippy@rp1.hu>2026-05-09 13:33:09 +0200
commita2b924d7e9492b978ad6dc33b6c1ffcb304b4bc5 (patch)
tree1a8769217f84bfe9d6216fafaadaf8cdd876d457 /raveos-hyprland-theme/theme-data/DankMaterialShell/core/internal/screenshot/theme.go
parent34b9c34f982b2596cfa9e368a2d7f74e9a17477c (diff)
downloadRaveOS-PKGBUILD-a2b924d7e9492b978ad6dc33b6c1ffcb304b4bc5.tar.gz
RaveOS-PKGBUILD-a2b924d7e9492b978ad6dc33b6c1ffcb304b4bc5.zip
raveos update
Diffstat (limited to 'raveos-hyprland-theme/theme-data/DankMaterialShell/core/internal/screenshot/theme.go')
-rw-r--r--raveos-hyprland-theme/theme-data/DankMaterialShell/core/internal/screenshot/theme.go125
1 files changed, 0 insertions, 125 deletions
diff --git a/raveos-hyprland-theme/theme-data/DankMaterialShell/core/internal/screenshot/theme.go b/raveos-hyprland-theme/theme-data/DankMaterialShell/core/internal/screenshot/theme.go
deleted file mode 100644
index a2bd5f6..0000000
--- a/raveos-hyprland-theme/theme-data/DankMaterialShell/core/internal/screenshot/theme.go
+++ /dev/null
@@ -1,125 +0,0 @@
-package screenshot
-
-import (
- "encoding/json"
- "os"
- "path/filepath"
- "strings"
-
- "github.com/AvengeMedia/DankMaterialShell/core/internal/log"
- "github.com/AvengeMedia/DankMaterialShell/core/internal/utils"
-)
-
-type ThemeColors struct {
- Background string `json:"surface"`
- OnSurface string `json:"on_surface"`
- Primary string `json:"primary"`
-}
-
-type ColorScheme struct {
- Dark ThemeColors `json:"dark"`
- Light ThemeColors `json:"light"`
-}
-
-type ColorsFile struct {
- Colors ColorScheme `json:"colors"`
-}
-
-var cachedStyle *OverlayStyle
-
-func LoadOverlayStyle() OverlayStyle {
- if cachedStyle != nil {
- return *cachedStyle
- }
-
- style := DefaultOverlayStyle
- colors := loadColorsFile()
- if colors == nil {
- cachedStyle = &style
- return style
- }
-
- theme := &colors.Dark
- if isLightMode() {
- theme = &colors.Light
- }
-
- if bg, ok := parseHexColor(theme.Background); ok {
- style.BackgroundR, style.BackgroundG, style.BackgroundB = bg[0], bg[1], bg[2]
- }
- if text, ok := parseHexColor(theme.OnSurface); ok {
- style.TextR, style.TextG, style.TextB = text[0], text[1], text[2]
- }
- if accent, ok := parseHexColor(theme.Primary); ok {
- style.AccentR, style.AccentG, style.AccentB = accent[0], accent[1], accent[2]
- }
-
- cachedStyle = &style
- return style
-}
-
-func loadColorsFile() *ColorScheme {
- path := getColorsFilePath()
- data, err := os.ReadFile(path)
- if err != nil {
- return nil
- }
-
- var file ColorsFile
- if err := json.Unmarshal(data, &file); err != nil {
- return nil
- }
-
- return &file.Colors
-}
-
-func getColorsFilePath() string {
- cacheDir, err := os.UserCacheDir()
- if err != nil {
- log.Error("Failed to get user cache dir", "err", err)
- return ""
- }
- return filepath.Join(cacheDir, "DankMaterialShell", "dms-colors.json")
-}
-
-func isLightMode() bool {
- scheme, err := utils.GsettingsGet("org.gnome.desktop.interface", "color-scheme")
- if err != nil {
- return false
- }
-
- switch scheme {
- case "'prefer-light'", "'default'":
- return true
- }
- return false
-}
-
-func parseHexColor(hex string) ([3]uint8, bool) {
- hex = strings.TrimPrefix(hex, "#")
- if len(hex) != 6 {
- return [3]uint8{}, false
- }
-
- var r, g, b uint8
- for i, ptr := range []*uint8{&r, &g, &b} {
- val := 0
- for j := 0; j < 2; j++ {
- c := hex[i*2+j]
- val *= 16
- switch {
- case c >= '0' && c <= '9':
- val += int(c - '0')
- case c >= 'a' && c <= 'f':
- val += int(c - 'a' + 10)
- case c >= 'A' && c <= 'F':
- val += int(c - 'A' + 10)
- default:
- return [3]uint8{}, false
- }
- }
- *ptr = uint8(val)
- }
-
- return [3]uint8{r, g, b}, true
-}