mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
feat: add scroll compositor support (#959)
* added scroll support * import QuickShell.i3 * update scroll provider registration logic * improve scroll support for workspace switcher * update title for scroll keybinds * add scroll to dms-greeter * fix: formatting & sway keybind provider * readme update --------- Co-authored-by: bbedward <bbedward@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package providers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/keybinds"
|
||||
@@ -9,18 +10,38 @@ import (
|
||||
|
||||
type SwayProvider struct {
|
||||
configPath string
|
||||
isScroll bool
|
||||
}
|
||||
|
||||
func NewSwayProvider(configPath string) *SwayProvider {
|
||||
isScroll := false
|
||||
_, ok := os.LookupEnv("SCROLLSOCK")
|
||||
if ok {
|
||||
isScroll = true
|
||||
}
|
||||
if configPath == "" {
|
||||
configPath = "$HOME/.config/sway"
|
||||
}
|
||||
if isScroll && configPath == "" {
|
||||
configPath = "$HOME/.config/scroll"
|
||||
}
|
||||
return &SwayProvider{
|
||||
configPath: configPath,
|
||||
isScroll: isScroll,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SwayProvider) Name() string {
|
||||
if s != nil && s.isScroll {
|
||||
return "scroll"
|
||||
}
|
||||
if s == nil {
|
||||
_, ok := os.LookupEnv("SCROLLSOCK")
|
||||
if ok {
|
||||
return "scroll"
|
||||
}
|
||||
}
|
||||
|
||||
return "sway"
|
||||
}
|
||||
|
||||
@@ -33,8 +54,13 @@ func (s *SwayProvider) GetCheatSheet() (*keybinds.CheatSheet, error) {
|
||||
categorizedBinds := make(map[string][]keybinds.Keybind)
|
||||
s.convertSection(section, "", categorizedBinds)
|
||||
|
||||
cheatSheetTitle := "Sway Keybinds"
|
||||
if s != nil && s.isScroll {
|
||||
cheatSheetTitle = "Scroll Keybinds"
|
||||
}
|
||||
|
||||
return &keybinds.CheatSheet{
|
||||
Title: "Sway Keybinds",
|
||||
Title: cheatSheetTitle,
|
||||
Provider: s.Name(),
|
||||
Binds: categorizedBinds,
|
||||
}, nil
|
||||
|
||||
@@ -20,6 +20,7 @@ const (
|
||||
CompositorSway
|
||||
CompositorNiri
|
||||
CompositorDWL
|
||||
CompositorScroll
|
||||
)
|
||||
|
||||
var detectedCompositor Compositor = -1
|
||||
@@ -32,6 +33,7 @@ func DetectCompositor() Compositor {
|
||||
hyprlandSig := os.Getenv("HYPRLAND_INSTANCE_SIGNATURE")
|
||||
niriSocket := os.Getenv("NIRI_SOCKET")
|
||||
swaySocket := os.Getenv("SWAYSOCK")
|
||||
scrollSocket := os.Getenv("SCROLLSOCK")
|
||||
|
||||
switch {
|
||||
case niriSocket != "":
|
||||
@@ -39,6 +41,12 @@ func DetectCompositor() Compositor {
|
||||
detectedCompositor = CompositorNiri
|
||||
return detectedCompositor
|
||||
}
|
||||
case scrollSocket != "":
|
||||
if _, err := os.Stat(scrollSocket); err == nil {
|
||||
detectedCompositor = CompositorScroll
|
||||
return detectedCompositor
|
||||
}
|
||||
|
||||
case swaySocket != "":
|
||||
if _, err := os.Stat(swaySocket); err == nil {
|
||||
detectedCompositor = CompositorSway
|
||||
@@ -233,6 +241,25 @@ func getSwayFocusedMonitor() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func getScrollFocusedMonitor() string {
|
||||
output, err := exec.Command("scrollmsg", "-t", "get_workspaces").Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
var workspaces []swayWorkspace
|
||||
if err := json.Unmarshal(output, &workspaces); err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
for _, ws := range workspaces {
|
||||
if ws.Focused {
|
||||
return ws.Output
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type niriWorkspace struct {
|
||||
Output string `json:"output"`
|
||||
IsFocused bool `json:"is_focused"`
|
||||
@@ -378,6 +405,8 @@ func GetFocusedMonitor() string {
|
||||
return getHyprlandFocusedMonitor()
|
||||
case CompositorSway:
|
||||
return getSwayFocusedMonitor()
|
||||
case CompositorScroll:
|
||||
return getScrollFocusedMonitor()
|
||||
case CompositorNiri:
|
||||
return getNiriFocusedMonitor()
|
||||
case CompositorDWL:
|
||||
|
||||
Reference in New Issue
Block a user