22 Commits

Author SHA1 Message Date
Piotr Miller
433c05ca1e Merge pull request #125 from nwg-piotr/icon-theme
update README.md
2024-06-29 20:20:34 +02:00
piotr
cd06a981cb update README.md 2024-06-29 20:19:12 +02:00
Piotr Miller
0f6f92433e Merge pull request #124 from nwg-piotr/icon-theme
Add the `-pbuseicontheme` flagIcon theme
2024-06-29 03:01:20 +02:00
piotr
3ffd09b5d7 add more desc 2024-06-29 02:40:01 +02:00
piotr
071841da46 bump to 0.4.9 2024-06-29 02:38:43 +02:00
piotr
c7a0b564c0 improve description 2024-06-29 02:34:41 +02:00
piotr
6862711010 add pbUseIconTheme flag #122 2024-06-29 02:32:27 +02:00
piotr
6d671062df change logging level 2024-06-17 02:16:52 +02:00
piotr
9aebff5d98 fix typos 2024-06-17 02:10:03 +02:00
piotr
051590ce4b revert gotk3 to v0.6.3 2024-06-17 02:03:39 +02:00
piotr
16be4ff00d bump to 0.4.8 2024-06-17 02:01:20 +02:00
piotr
9f0f708cae Merge remote-tracking branch 'origin/main' 2024-06-17 01:53:43 +02:00
piotr
4e04e7a4f4 update dependencies 2024-06-17 01:53:25 +02:00
Piotr Miller
85a0b87024 Merge pull request #121 from RRRRRm/open_close
Add -open and -close options
2024-06-17 01:52:21 +02:00
RRRRRm
6649dcefdb Correct the default terminal 2024-06-17 00:31:52 +01:00
Zijia Xiong
e501038c64 Merge branch 'open_close' of github.com:RRRRRm/nwg-drawer into open_close 2024-06-16 19:04:31 +01:00
Zijia Xiong
008f31278d Fix logic about receive signals 2024-06-16 19:01:26 +01:00
RRRRRm
69e3b06b39 Update README.md,
Add some information about new flags `-open` and `-close`
2024-06-16 18:35:01 +01:00
Zijia Xiong
99765402d7 Change usage of SIGINT to SIGRTMIN+3 2024-06-14 00:48:10 +01:00
Zijia Xiong
3fb70fc0cb Fix bug of -open and -close 2024-06-13 23:30:58 +01:00
Zijia Xiong
04a04c1417 Add -close and -open options. 2024-06-13 19:09:33 +01:00
Piotr Miller
a54a56c4b9 Update FUNDING.yml 2024-02-16 13:17:28 +01:00
7 changed files with 110 additions and 25 deletions

1
.github/FUNDING.yml vendored
View File

@@ -1 +1,2 @@
github: nwg-piotr github: nwg-piotr
liberapay: nwg

View File

@@ -54,6 +54,8 @@ $ nwg-drawer -h
Usage of nwg-drawer: Usage of nwg-drawer:
-c uint -c uint
number of Columns (default 6) number of Columns (default 6)
-close
close drawer of existing instance
-d Turn on Debug messages -d Turn on Debug messages
-fm string -fm string
File Manager (default "thunar") File Manager (default "thunar")
@@ -86,6 +88,8 @@ Usage of nwg-drawer:
Disable file search Disable file search
-o string -o string
name of the Output to display the drawer on (sway & Hyprland only) name of the Output to display the drawer on (sway & Hyprland only)
-open
open drawer of existing instance
-ovl -ovl
use OVerLay layer use OVerLay layer
-pbexit string -pbexit string
@@ -97,9 +101,11 @@ Usage of nwg-drawer:
-pbreboot string -pbreboot string
command for the Reboot power bar icon command for the Reboot power bar icon
-pbsize int -pbsize int
power bar icon size (default 64) power bar icon size (only works w/ built-in icons) (default 64)
-pbsleep string -pbsleep string
command for the sleep power bar icon command for the sleep power bar icon
-pbuseicontheme
use icon theme instead of built-in icons in power bar
-r Leave the program resident in memory -r Leave the program resident in memory
-s string -s string
Styling: css file name (default "drawer.css") Styling: css file name (default "drawer.css")
@@ -137,6 +143,15 @@ this should be a little bit faster.
Running a resident instance should speed up use of the drawer significantly. Pay attention to the fact, that you Running a resident instance should speed up use of the drawer significantly. Pay attention to the fact, that you
need to `pkill -f nwg-drawer` and reload the compositor to apply any new arguments! need to `pkill -f nwg-drawer` and reload the compositor to apply any new arguments!
If you want to explicitly specify commands to open and close the resident instance, which can be helpful for touchpad gestures, please use the `-open` and `-close` parameters. Similarly, some signals can also be use: pkill -USR2 nwg-drawer to open and pkill -SIGRTMIN+3 nwg-drawer to close.
For a MacOS-style three-finger pinch:
```text
bindgesture pinch:4:inward exec pkill -SIGUSR2 nwg-drawer
bindgesture pinch:4:outward exec pkill -SIGRTMIN+3 nwg-drawer
```
## Logging ## Logging
In case you encounter an issue, you may need debug messages. If you use the resident instance, you'll see nothing In case you encounter an issue, you may need debug messages. If you use the resident instance, you'll see nothing

6
go.mod
View File

@@ -4,7 +4,7 @@ go 1.22
require ( require (
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37 github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
github.com/dlasky/gotk3-layershell v0.0.0-20230802002603-b0c42cd8474f github.com/dlasky/gotk3-layershell v0.0.0-20240515133811-5c5115f0d774
github.com/fsnotify/fsnotify v1.7.0 github.com/fsnotify/fsnotify v1.7.0
github.com/gotk3/gotk3 v0.6.3 github.com/gotk3/gotk3 v0.6.3
github.com/joshuarubin/go-sway v1.2.0 github.com/joshuarubin/go-sway v1.2.0
@@ -14,6 +14,6 @@ require (
require ( require (
github.com/joshuarubin/lifecycle v1.1.4 // indirect github.com/joshuarubin/lifecycle v1.1.4 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sync v0.6.0 // indirect golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.17.0 // indirect golang.org/x/sys v0.21.0 // indirect
) )

8
go.sum
View File

@@ -7,6 +7,8 @@ github.com/dlasky/gotk3-layershell v0.0.0-20221218201547-1f6674a3f872 h1:16qcNl+
github.com/dlasky/gotk3-layershell v0.0.0-20221218201547-1f6674a3f872/go.mod h1:JHLx2Wz4mAPVwn4PFhC69ydwyHP4A3wQvlg7HKVVc1U= github.com/dlasky/gotk3-layershell v0.0.0-20221218201547-1f6674a3f872/go.mod h1:JHLx2Wz4mAPVwn4PFhC69ydwyHP4A3wQvlg7HKVVc1U=
github.com/dlasky/gotk3-layershell v0.0.0-20230802002603-b0c42cd8474f h1:qDnUQAD7tVX/gnL6uSgouzfGNA4xXH+B/fd6Ko19GgM= github.com/dlasky/gotk3-layershell v0.0.0-20230802002603-b0c42cd8474f h1:qDnUQAD7tVX/gnL6uSgouzfGNA4xXH+B/fd6Ko19GgM=
github.com/dlasky/gotk3-layershell v0.0.0-20230802002603-b0c42cd8474f/go.mod h1:JHLx2Wz4mAPVwn4PFhC69ydwyHP4A3wQvlg7HKVVc1U= github.com/dlasky/gotk3-layershell v0.0.0-20230802002603-b0c42cd8474f/go.mod h1:JHLx2Wz4mAPVwn4PFhC69ydwyHP4A3wQvlg7HKVVc1U=
github.com/dlasky/gotk3-layershell v0.0.0-20240515133811-5c5115f0d774 h1:o87OVL4olQBlVwN3+NSVQpS6gj9FWUYtxOfHXWZigUE=
github.com/dlasky/gotk3-layershell v0.0.0-20240515133811-5c5115f0d774/go.mod h1:JHLx2Wz4mAPVwn4PFhC69ydwyHP4A3wQvlg7HKVVc1U=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
@@ -16,6 +18,8 @@ github.com/gotk3/gotk3 v0.6.2 h1:sx/PjaKfKULJPTPq8p2kn2ZbcNFxpOJqi4VLzMbEOO8=
github.com/gotk3/gotk3 v0.6.2/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q= github.com/gotk3/gotk3 v0.6.2/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/gotk3/gotk3 v0.6.3 h1:+Ke4WkM1TQUNOlM2TZH6szqknqo+zNbX3BZWVXjSHYw= github.com/gotk3/gotk3 v0.6.3 h1:+Ke4WkM1TQUNOlM2TZH6szqknqo+zNbX3BZWVXjSHYw=
github.com/gotk3/gotk3 v0.6.3/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q= github.com/gotk3/gotk3 v0.6.3/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/gotk3/gotk3 v0.6.4 h1:5ur/PRr86PwCG8eSj98D1eXvhrNNK6GILS2zq779dCg=
github.com/gotk3/gotk3 v0.6.4/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/joshuarubin/go-sway v1.2.0 h1:t3eqW504//uj9PDwFf0+IVfkD+WoOGaDX5gYIe0BHyM= github.com/joshuarubin/go-sway v1.2.0 h1:t3eqW504//uj9PDwFf0+IVfkD+WoOGaDX5gYIe0BHyM=
github.com/joshuarubin/go-sway v1.2.0/go.mod h1:qcDd6f25vJ0++wICwA1BainIcRC67p2Mb4lsrZ0k3/k= github.com/joshuarubin/go-sway v1.2.0/go.mod h1:qcDd6f25vJ0++wICwA1BainIcRC67p2Mb4lsrZ0k3/k=
github.com/joshuarubin/lifecycle v1.0.0/go.mod h1:sRy++ATvR9Ee21tkRdFkQeywAWvDsue66V70K0Dnl54= github.com/joshuarubin/lifecycle v1.0.0/go.mod h1:sRy++ATvR9Ee21tkRdFkQeywAWvDsue66V70K0Dnl54=
@@ -40,6 +44,8 @@ golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
@@ -50,6 +56,8 @@ golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

84
main.go
View File

@@ -21,7 +21,7 @@ import (
"github.com/gotk3/gotk3/gtk" "github.com/gotk3/gotk3/gtk"
) )
const version = "0.4.7" const version = "0.4.9"
var ( var (
appDirs []string appDirs []string
@@ -155,6 +155,8 @@ var targetOutput = flag.String("o", "", "name of the Output to display the drawe
var displayVersion = flag.Bool("v", false, "display Version information") var displayVersion = flag.Bool("v", false, "display Version information")
var keyboard = flag.Bool("k", false, "set GTK layer shell Keyboard interactivity to 'on-demand' mode") var keyboard = flag.Bool("k", false, "set GTK layer shell Keyboard interactivity to 'on-demand' mode")
var overlay = flag.Bool("ovl", false, "use OVerLay layer") var overlay = flag.Bool("ovl", false, "use OVerLay layer")
var flagDrawerOpen = flag.Bool("open", false, "open drawer of existing instance")
var flagDrawerClose = flag.Bool("close", false, "close drawer of existing instance")
var gtkTheme = flag.String("g", "", "GTK theme name") var gtkTheme = flag.String("g", "", "GTK theme name")
var gtkIconTheme = flag.String("i", "", "GTK icon theme name") var gtkIconTheme = flag.String("i", "", "GTK icon theme name")
var iconSize = flag.Int("is", 64, "Icon Size") var iconSize = flag.Int("is", 64, "Icon Size")
@@ -179,7 +181,8 @@ var pbLock = flag.String("pblock", "", "command for the Lock power bar icon")
var pbPoweroff = flag.String("pbpoweroff", "", "command for the Poweroff power bar icon") var pbPoweroff = flag.String("pbpoweroff", "", "command for the Poweroff power bar icon")
var pbReboot = flag.String("pbreboot", "", "command for the Reboot power bar icon") var pbReboot = flag.String("pbreboot", "", "command for the Reboot power bar icon")
var pbSleep = flag.String("pbsleep", "", "command for the sleep power bar icon") var pbSleep = flag.String("pbsleep", "", "command for the sleep power bar icon")
var pbSize = flag.Int("pbsize", 64, "power bar icon size") var pbSize = flag.Int("pbsize", 64, "power bar icon size (only works w/ built-in icons)")
var pbUseIconTheme = flag.Bool("pbuseicontheme", false, "use icon theme instead of built-in icons in power bar")
var debug = flag.Bool("d", false, "Turn on Debug messages") var debug = flag.Bool("d", false, "Turn on Debug messages")
func main() { func main() {
@@ -201,8 +204,10 @@ func main() {
// v0.2: we also need to support SIGUSR from now on // v0.2: we also need to support SIGUSR from now on
showWindowChannel := make(chan interface{}, 1) showWindowChannel := make(chan interface{}, 1)
signalChan := make(chan os.Signal, 1) signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGTERM, syscall.SIGUSR1) const (
SIG25 = syscall.Signal(0x25) // Which is SIGRTMIN+3 on Linux, it's not used by the system
)
signal.Notify(signalChan, syscall.SIGTERM, syscall.SIGUSR1, syscall.SIGUSR2, SIG25)
go func() { go func() {
for { for {
s := <-signalChan s := <-signalChan
@@ -210,7 +215,7 @@ func main() {
case syscall.SIGTERM: case syscall.SIGTERM:
log.Info("SIGTERM received, bye bye") log.Info("SIGTERM received, bye bye")
gtk.MainQuit() gtk.MainQuit()
case syscall.SIGUSR1: case syscall.SIGUSR1: // toggle drawer
if *resident { if *resident {
// As win.Show() called from inside a goroutine randomly crashes GTK, // As win.Show() called from inside a goroutine randomly crashes GTK,
// let's just set e helper variable here. We'll be checking it with glib.TimeoutAdd. // let's just set e helper variable here. We'll be checking it with glib.TimeoutAdd.
@@ -225,6 +230,23 @@ func main() {
log.Info("SIGUSR1 received, and I'm not resident, bye bye") log.Info("SIGUSR1 received, and I'm not resident, bye bye")
gtk.MainQuit() gtk.MainQuit()
} }
case syscall.SIGUSR2: // open drawer
if *resident {
log.Debug("SIGUSR2 received, showing the window")
showWindowChannel <- struct{}{}
} else {
log.Info("SIGUSR2 received, and I'm not resident but I'm still here, doing nothing")
}
case SIG25: // close drawer
if *resident {
log.Debug("SIG25 received, hiding the window")
if win.IsVisible() {
restoreStateAndHide()
}
} else {
log.Info("A signal received, and I'm not resident, bye bye")
gtk.MainQuit()
}
default: default:
log.Infof("Unknown signal: %s", s.String()) log.Infof("Unknown signal: %s", s.String())
} }
@@ -233,8 +255,8 @@ func main() {
// If running instance found, we want it to show the window. The new instance will send SIGUSR1 and die // If running instance found, we want it to show the window. The new instance will send SIGUSR1 and die
// (equivalent of `pkill -USR1 nwg-drawer`). // (equivalent of `pkill -USR1 nwg-drawer`).
// Otherwise the command may behave in two ways: // Otherwise, the command may behave in two ways:
// 1. kill the running non-residennt instance and exit; // 1. kill the running non-resident instance and exit;
// 2. die if a resident instance found. // 2. die if a resident instance found.
lockFilePath := path.Join(dataHome(), "nwg-drawer.lock") lockFilePath := path.Join(dataHome(), "nwg-drawer.lock")
lockFile, err := singleinstance.CreateLockFile(lockFilePath) lockFile, err := singleinstance.CreateLockFile(lockFilePath)
@@ -246,8 +268,17 @@ func main() {
if *resident { if *resident {
log.Warnf("Resident instance already running (PID %v)", i) log.Warnf("Resident instance already running (PID %v)", i)
} else { } else {
log.Infof("Showing resident instance (PID %v)", i) var err error
err := syscall.Kill(i, syscall.SIGUSR1) if *flagDrawerClose {
log.Infof("Closing resident instance (PID %v)", i)
err = syscall.Kill(i, SIG25)
} else if *flagDrawerOpen {
log.Infof("Showing resident instance (PID %v)", i)
err = syscall.Kill(i, syscall.SIGUSR2)
} else {
log.Infof("Toggling resident instance (PID %v)", i)
err = syscall.Kill(i, syscall.SIGUSR1)
}
if err != nil { if err != nil {
return return
} }
@@ -594,27 +625,52 @@ func main() {
powerBarWrapper.PackStart(powerButtonsWrapper, true, false, 12) powerBarWrapper.PackStart(powerButtonsWrapper, true, false, 12)
if *pbPoweroff != "" { if *pbPoweroff != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/poweroff.svg"), *pbPoweroff) btn, _ := gtk.ButtonNew()
if !*pbUseIconTheme {
btn = powerButton(filepath.Join(dataDirectory, "img/poweroff.svg"), *pbPoweroff)
} else {
btn = powerButton("system-shutdown-symbolic", *pbPoweroff)
}
powerButtonsWrapper.PackEnd(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn firstPowerBtn = btn
} }
if *pbSleep != "" { if *pbSleep != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/sleep.svg"), *pbSleep) btn, _ := gtk.ButtonNew()
if !*pbUseIconTheme {
btn = powerButton(filepath.Join(dataDirectory, "img/sleep.svg"), *pbSleep)
} else {
btn = powerButton("face-yawn-symbolic", *pbSleep)
}
powerButtonsWrapper.PackEnd(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn firstPowerBtn = btn
} }
if *pbReboot != "" { if *pbReboot != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/reboot.svg"), *pbReboot) btn, _ := gtk.ButtonNew()
if !*pbUseIconTheme {
btn = powerButton(filepath.Join(dataDirectory, "img/reboot.svg"), *pbReboot)
} else {
btn = powerButton("system-reboot-symbolic", *pbReboot)
}
powerButtonsWrapper.PackEnd(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn firstPowerBtn = btn
} }
if *pbExit != "" { if *pbExit != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/exit.svg"), *pbExit) btn, _ := gtk.ButtonNew()
if !*pbUseIconTheme {
btn = powerButton(filepath.Join(dataDirectory, "img/exit.svg"), *pbExit)
} else {
btn = powerButton("system-log-out-symbolic", *pbExit)
}
powerButtonsWrapper.PackEnd(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn firstPowerBtn = btn
} }
if *pbLock != "" { if *pbLock != "" {
btn := powerButton(filepath.Join(dataDirectory, "img/lock.svg"), *pbLock) btn, _ := gtk.ButtonNew()
if !*pbUseIconTheme {
btn = powerButton(filepath.Join(dataDirectory, "img/lock.svg"), *pbLock)
} else {
btn = powerButton("system-lock-screen-symbolic", *pbLock)
}
powerButtonsWrapper.PackEnd(btn, true, false, 0) powerButtonsWrapper.PackEnd(btn, true, false, 0)
firstPowerBtn = btn firstPowerBtn = btn
} }

View File

@@ -181,7 +181,7 @@ func dataHome() string {
dir = path.Join(home, ".local/share/nwg-drawer") dir = path.Join(home, ".local/share/nwg-drawer")
} }
log.Infof("Data home: %s", dir) log.Debugf("Data home: %s", dir)
createDir(dir) createDir(dir)
return dir return dir

View File

@@ -298,19 +298,24 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
return button return button
} }
func powerButton(iconPath, command string) *gtk.Button { func powerButton(iconPathOrName, command string) *gtk.Button {
button, _ := gtk.ButtonNew() button, _ := gtk.ButtonNew()
button.SetAlwaysShowImage(true) button.SetAlwaysShowImage(true)
var pixbuf *gdk.Pixbuf var pixbuf *gdk.Pixbuf
var img *gtk.Image var img *gtk.Image
var err error var err error
pixbuf, err = gdk.PixbufNewFromFileAtSize(iconPath, *pbSize, *pbSize) if !*pbUseIconTheme {
if err != nil { pixbuf, err = gdk.PixbufNewFromFileAtSize(iconPathOrName, *pbSize, *pbSize)
pixbuf, _ = createPixbuf("unknown", *pbSize) if err != nil {
log.Warnf("Couldn't find icon %s", iconPath) pixbuf, _ = createPixbuf("unknown", *pbSize)
log.Warnf("Couldn't find icon %s", iconPathOrName)
}
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
} else {
img, _ = gtk.ImageNewFromIconName(iconPathOrName, gtk.ICON_SIZE_DIALOG)
} }
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
button.SetImage(img) button.SetImage(img)
button.SetImagePosition(gtk.POS_TOP) button.SetImagePosition(gtk.POS_TOP)