main amadaluzia/webfetch / internal / desktop_info.go
 1package internal
 2
 3import "fmt"
 4
 5// DesktopInfo holds information about the desktop environment you are using.
 6type DesktopInfo struct {
 7	SessionType    string
 8	CurrentDesktop string
 9}
10
11func (d DesktopInfo) String() string {
12	var sessionType string
13	var currentDesktop string
14	switch d.SessionType {
15	case "wayland":
16		sessionType = "Wayland"
17	case "x11":
18		sessionType = "X11"
19	default:
20		sessionType = d.SessionType
21	}
22	switch d.CurrentDesktop {
23	case "kde":
24		currentDesktop = "KDE Plasma"
25	default:
26		currentDesktop = d.CurrentDesktop
27	}
28	return fmt.Sprintf("%s (%s)", currentDesktop, sessionType)
29}