commit bfd89a6dacb629f0ac58de27e46b0904b1e2b253
parent 6e2cdade7ebb49ea8f80eff499cf14f8351caa34
Author: Sean Enck <sean@ttypty.com>
Date: Sun, 29 Jun 2025 16:31:15 -0400
users should use 'osc' utility or other helps
Diffstat:
8 files changed, 26 insertions(+), 74 deletions(-)
diff --git a/cmd/lb/main.go b/cmd/lb/main.go
@@ -123,10 +123,7 @@ func clearClipboard() error {
if err != nil {
return err
}
- pCmd, pArgs, valid := clipboard.Args(false)
- if !valid {
- return nil
- }
+ pCmd, pArgs := clipboard.Args(false)
val = strings.TrimSpace(val)
for idx < clipboard.MaxTime {
idx++
diff --git a/go.mod b/go.mod
@@ -6,7 +6,6 @@ toolchain go1.24.1
require (
github.com/BurntSushi/toml v1.5.0
- github.com/aymanbagabas/go-osc52 v1.2.2
github.com/pquerna/otp v1.5.0
github.com/tobischo/gokeepasslib/v3 v3.6.1
)
diff --git a/go.sum b/go.sum
@@ -1,7 +1,5 @@
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
-github.com/aymanbagabas/go-osc52 v1.2.2 h1:NT7wkhEhPTcKnBCdPi9djmyy9L3JOL4+3SsfJyqptCo=
-github.com/aymanbagabas/go-osc52 v1.2.2/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/boombuler/barcode v1.0.2 h1:79yrbttoZrLGkL/oOI8hBrUKucwOL0oOjUgEguGMcJ4=
github.com/boombuler/barcode v1.0.2/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
diff --git a/internal/config/toml_test.go b/internal/config/toml_test.go
@@ -179,16 +179,16 @@ timeout = -1
func TestReadBool(t *testing.T) {
store.Clear()
data := `
-[clip]
-osc52 = 1
+[feature]
+clip = 1
`
r := strings.NewReader(data)
if err := config.LoadConfig(r, emptyRead); err == nil || err.Error() != "non-bool found where expected: 1" {
t.Errorf("invalid error: %v", err)
}
data = `include = []
-[clip]
-osc52 = true
+[feature]
+clip = true
`
r = strings.NewReader(data)
if err := config.LoadConfig(r, emptyRead); err != nil {
@@ -197,13 +197,13 @@ osc52 = true
if len(store.List()) != 1 {
t.Errorf("invalid store")
}
- val, ok := store.GetBool("LOCKBOX_CLIP_OSC52")
+ val, ok := store.GetBool("LOCKBOX_FEATURE_CLIP")
if !val || !ok {
t.Errorf("invalid object: %v", val)
}
data = `include = []
-[clip]
-osc52 = false
+[feature]
+clip = false
`
r = strings.NewReader(data)
if err := config.LoadConfig(r, emptyRead); err != nil {
@@ -212,7 +212,7 @@ osc52 = false
if len(store.List()) != 1 {
t.Errorf("invalid store")
}
- val, ok = store.GetBool("LOCKBOX_CLIP_OSC52")
+ val, ok = store.GetBool("LOCKBOX_FEATURE_CLIP")
if val || !ok {
t.Errorf("invalid object: %v", val)
}
@@ -251,7 +251,7 @@ func TestDefaultTOMLToLoadFile(t *testing.T) {
if err := config.LoadConfigFile(file); err != nil {
t.Errorf("invalid error: %v", err)
}
- if len(store.List()) != 19 {
+ if len(store.List()) != 18 {
t.Errorf("invalid environment after load: %d", len(store.List()))
}
}
diff --git a/internal/config/vars.go b/internal/config/vars.go
@@ -53,14 +53,6 @@ var (
short: "hash length",
canZero: true,
})
- // EnvClipOSC52 indicates if OSC52 clipboard mode is enabled
- EnvClipOSC52 = environmentRegister(EnvironmentBool{
- environmentDefault: newDefaultedEnvironment(false,
- environmentBase{
- key: clipCategory + "OSC52",
- description: "Enable OSC52 clipboard mode.",
- }),
- })
// EnvReadOnly indicates if in read-only mode
EnvReadOnly = environmentRegister(EnvironmentBool{
environmentDefault: newDefaultedEnvironment(false,
diff --git a/internal/config/vars_test.go b/internal/config/vars_test.go
@@ -40,10 +40,6 @@ func TestColorFeature(t *testing.T) {
checkYesNo("LOCKBOX_FEATURE_COLOR", t, config.EnvFeatureColor, true)
}
-func TestIsOSC52(t *testing.T) {
- checkYesNo("LOCKBOX_CLIP_OSC52", t, config.EnvClipOSC52, false)
-}
-
func TestFormatTOTP(t *testing.T) {
store.Clear()
otp := config.EnvTOTPFormat.Get("otpauth://abc")
diff --git a/internal/platform/clip/core.go b/internal/platform/clip/core.go
@@ -9,7 +9,6 @@ import (
"git.sr.ht/~enckse/lockbox/internal/app/commands"
"git.sr.ht/~enckse/lockbox/internal/config"
"git.sr.ht/~enckse/lockbox/internal/platform"
- osc "github.com/aymanbagabas/go-osc52"
)
type (
@@ -18,7 +17,6 @@ type (
copying []string
pasting []string
MaxTime int64
- isOSC52 bool
}
)
@@ -27,7 +25,7 @@ func newBoard(copying, pasting []string) (Board, error) {
if err != nil {
return Board{}, err
}
- return Board{copying: copying, pasting: pasting, MaxTime: maximum, isOSC52: false}, nil
+ return Board{copying: copying, pasting: pasting, MaxTime: maximum}, nil
}
// New creates a new clipboard
@@ -42,10 +40,6 @@ func New() (Board, error) {
if setPaste && setCopy {
return newBoard(overrideCopy, overridePaste)
}
- if config.EnvClipOSC52.Get() {
- c := Board{isOSC52: true}
- return c, nil
- }
sys, err := platform.NewSystem(config.EnvPlatform.Get())
if err != nil {
return Board{}, err
@@ -80,11 +74,7 @@ func New() (Board, error) {
// CopyTo will copy to clipboard, if non-empty will clear later.
func (c Board) CopyTo(value string) error {
- if c.isOSC52 {
- osc.Copy(value)
- return nil
- }
- cmd, args, _ := c.Args(true)
+ cmd, args := c.Args(true)
pipeTo(cmd, value, true, args...)
if value != "" {
fmt.Printf("clipboard will clear in %d seconds\n", c.MaxTime)
@@ -94,10 +84,7 @@ func (c Board) CopyTo(value string) error {
}
// Args returns clipboard args for execution.
-func (c Board) Args(copying bool) (string, []string, bool) {
- if c.isOSC52 {
- return "", []string{}, false
- }
+func (c Board) Args(copying bool) (string, []string) {
var using []string
if copying {
using = c.copying
@@ -108,7 +95,7 @@ func (c Board) Args(copying bool) (string, []string, bool) {
if len(using) > 1 {
args = using[1:]
}
- return using[0], args, true
+ return using[0], args
}
func pipeTo(command, value string, wait bool, args ...string) error {
diff --git a/internal/platform/clip/core_test.go b/internal/platform/clip/core_test.go
@@ -19,7 +19,6 @@ func TestDisabled(t *testing.T) {
func TestMaxTime(t *testing.T) {
store.Clear()
defer store.Clear()
- store.SetBool("LOCKBOX_CLIP_OSC52", false)
store.SetString("LOCKBOX_PLATFORM", string(platform.Systems.LinuxWaylandSystem))
c, err := clip.New()
if err != nil {
@@ -46,7 +45,6 @@ func TestMaxTime(t *testing.T) {
func TestClipboardInstances(t *testing.T) {
store.Clear()
defer store.Clear()
- store.SetBool("LOCKBOX_CLIP_OSC52", false)
for _, item := range platform.Systems.List() {
store.SetString("LOCKBOX_PLATFORM", item)
_, err := clip.New()
@@ -56,21 +54,6 @@ func TestClipboardInstances(t *testing.T) {
}
}
-func TestOSC52(t *testing.T) {
- store.Clear()
- defer store.Clear()
- store.SetBool("LOCKBOX_CLIP_OSC52", true)
- c, _ := clip.New()
- _, _, ok := c.Args(true)
- if ok {
- t.Error("invalid clipboard, should be an internal call")
- }
- _, _, ok = c.Args(false)
- if ok {
- t.Error("invalid clipboard, should be an internal call")
- }
-}
-
func TestArgsOverride(t *testing.T) {
store.Clear()
defer store.Clear()
@@ -80,12 +63,12 @@ func TestArgsOverride(t *testing.T) {
if err != nil {
t.Errorf("invalid error: %v", err)
}
- cmd, args, ok := c.Args(true)
- if cmd != "clip.exe" || len(args) != 0 || !ok {
+ cmd, args := c.Args(true)
+ if cmd != "clip.exe" || len(args) != 0 {
t.Error("invalid parse")
}
- cmd, args, ok = c.Args(false)
- if cmd != "abc" || len(args) != 2 || args[0] != "xyz" || args[1] != "111" || !ok {
+ cmd, args = c.Args(false)
+ if cmd != "abc" || len(args) != 2 || args[0] != "xyz" || args[1] != "111" {
t.Error("invalid parse")
}
store.SetArray("LOCKBOX_CLIP_COPY_COMMAND", []string{"zzz", "lll", "123"})
@@ -93,12 +76,12 @@ func TestArgsOverride(t *testing.T) {
if err != nil {
t.Errorf("invalid error: %v", err)
}
- cmd, args, ok = c.Args(true)
- if cmd != "zzz" || len(args) != 2 || args[0] != "lll" || args[1] != "123" || !ok {
+ cmd, args = c.Args(true)
+ if cmd != "zzz" || len(args) != 2 || args[0] != "lll" || args[1] != "123" {
t.Error("invalid parse")
}
- cmd, args, ok = c.Args(false)
- if cmd != "abc" || len(args) != 2 || args[0] != "xyz" || args[1] != "111" || !ok {
+ cmd, args = c.Args(false)
+ if cmd != "abc" || len(args) != 2 || args[0] != "xyz" || args[1] != "111" {
t.Error("invalid parse")
}
store.Clear()
@@ -107,12 +90,12 @@ func TestArgsOverride(t *testing.T) {
if err != nil {
t.Errorf("invalid error: %v", err)
}
- cmd, args, ok = c.Args(true)
- if cmd != "clip.exe" || len(args) != 0 || !ok {
+ cmd, args = c.Args(true)
+ if cmd != "clip.exe" || len(args) != 0 {
t.Error("invalid parse")
}
- cmd, args, ok = c.Args(false)
- if cmd != "powershell.exe" || len(args) != 2 || args[0] != "-command" || args[1] != "Get-Clipboard" || !ok {
+ cmd, args = c.Args(false)
+ if cmd != "powershell.exe" || len(args) != 2 || args[0] != "-command" || args[1] != "Get-Clipboard" {
t.Errorf("invalid parse %s %v", cmd, args)
}
}