From b59058c5c21eb4b5f12000d65673264b2c2d2c5f Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 8 Feb 2024 02:23:34 +0100 Subject: [PATCH] focus 1st power button on Tab key --- main.go | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 5fc7c50..f392bbf 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ var ( exclusions []string hyprlandMonitors []monitor beenScrolled bool + firstPowerBtn *gtk.Button ) var categoryNames = [...]string{ @@ -462,6 +463,10 @@ func main() { } } return true + } else if key.KeyVal() == gdk.KEY_Tab { + if firstPowerBtn != nil { + firstPowerBtn.ToWidget().GrabFocus() + } } return false }) @@ -588,25 +593,30 @@ func main() { powerButtonsWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0) powerBarWrapper.PackStart(powerButtonsWrapper, true, false, 12) - if *pbLock != "" { - btn := powerButton(filepath.Join(dataDirectory, "img/lock.svg"), *pbLock) - powerButtonsWrapper.PackStart(btn, true, false, 0) - } - if *pbExit != "" { - btn := powerButton(filepath.Join(dataDirectory, "img/exit.svg"), *pbExit) - powerButtonsWrapper.PackStart(btn, true, false, 0) - } - if *pbReboot != "" { - btn := powerButton(filepath.Join(dataDirectory, "img/reboot.svg"), *pbReboot) - powerButtonsWrapper.PackStart(btn, true, false, 0) + if *pbPoweroff != "" { + btn := powerButton(filepath.Join(dataDirectory, "img/poweroff.svg"), *pbPoweroff) + powerButtonsWrapper.PackEnd(btn, true, false, 0) + firstPowerBtn = btn } if *pbSleep != "" { btn := powerButton(filepath.Join(dataDirectory, "img/sleep.svg"), *pbSleep) - powerButtonsWrapper.PackStart(btn, true, false, 0) + powerButtonsWrapper.PackEnd(btn, true, false, 0) + firstPowerBtn = btn } - if *pbPoweroff != "" { - btn := powerButton(filepath.Join(dataDirectory, "img/poweroff.svg"), *pbPoweroff) - powerButtonsWrapper.PackStart(btn, true, false, 0) + if *pbReboot != "" { + btn := powerButton(filepath.Join(dataDirectory, "img/reboot.svg"), *pbReboot) + powerButtonsWrapper.PackEnd(btn, true, false, 0) + firstPowerBtn = btn + } + if *pbExit != "" { + btn := powerButton(filepath.Join(dataDirectory, "img/exit.svg"), *pbExit) + powerButtonsWrapper.PackEnd(btn, true, false, 0) + firstPowerBtn = btn + } + if *pbLock != "" { + btn := powerButton(filepath.Join(dataDirectory, "img/lock.svg"), *pbLock) + powerButtonsWrapper.PackEnd(btn, true, false, 0) + firstPowerBtn = btn } } } else {