aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/state
diff options
context:
space:
mode:
Diffstat (limited to 'internal/state')
-rw-r--r--internal/state/enablement.go46
-rw-r--r--internal/state/print.go3
-rw-r--r--internal/state/state.go4
3 files changed, 5 insertions, 48 deletions
diff --git a/internal/state/enablement.go b/internal/state/enablement.go
deleted file mode 100644
index 9cc8f60d..00000000
--- a/internal/state/enablement.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package state
-
-type (
- // Enablement represents an optional system resource
- Enablement uint8
- // Enablements represents optional system resources to share
- Enablements uint64
-)
-
-const (
- EnableWayland Enablement = iota
- EnableX
- EnableDBus
- EnablePulse
-
- EnableLength
-)
-
-var enablementString = [EnableLength]string{
- "Wayland",
- "X11",
- "D-Bus",
- "PulseAudio",
-}
-
-func (e Enablement) String() string {
- return enablementString[e]
-}
-
-func (e Enablement) Mask() Enablements {
- return 1 << e
-}
-
-// Has returns whether a feature is enabled
-func (es *Enablements) Has(e Enablement) bool {
- return *es&e.Mask() != 0
-}
-
-// Set enables a feature
-func (es *Enablements) Set(e Enablement) {
- if es.Has(e) {
- panic("enablement " + e.String() + " set twice")
- }
-
- *es |= e.Mask()
-}
diff --git a/internal/state/print.go b/internal/state/print.go
index 8de5a59d..fbd0110d 100644
--- a/internal/state/print.go
+++ b/internal/state/print.go
@@ -10,6 +10,7 @@ import (
"text/tabwriter"
"time"
+ "git.ophivana.moe/cat/fortify/internal/system"
"git.ophivana.moe/cat/fortify/internal/verbose"
)
@@ -85,7 +86,7 @@ func (s *simpleStore) mustPrintLauncherState(w **tabwriter.Writer, now time.Time
// build enablements string
ets := strings.Builder{}
// append enablement strings in order
- for i := Enablement(0); i < EnableLength; i++ {
+ for i := system.Enablement(0); i < system.Enablement(system.ELen); i++ {
if state.Capability.Has(i) {
ets.WriteString(", " + i.String())
}
diff --git a/internal/state/state.go b/internal/state/state.go
index 61aae2cf..bc2be691 100644
--- a/internal/state/state.go
+++ b/internal/state/state.go
@@ -2,6 +2,8 @@ package state
import (
"time"
+
+ "git.ophivana.moe/cat/fortify/internal/system"
)
type Store interface {
@@ -29,7 +31,7 @@ type State struct {
// command used to seal the app
Command []string
// capability enablements applied to child
- Capability Enablements
+ Capability system.Enablements
// resolved launcher path
Launcher string