Skip to content

Commit

Permalink
Merge pull request #28 from nwg-piotr/cont
Browse files Browse the repository at this point in the history
ioutil -> os
  • Loading branch information
nwg-piotr authored Oct 13, 2022
2 parents 142d616 + 3a3768f commit ed6fa95
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nwg-piotr/nwg-dock

go 1.16
go 1.19

require (
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
Expand All @@ -9,3 +9,11 @@ require (
github.com/joshuarubin/go-sway v0.0.4
github.com/sirupsen/logrus v1.8.1
)

require (
github.com/joshuarubin/lifecycle v1.0.0 // indirect
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
golang.org/x/sync v0.0.0-20190412183630-56d357773e84 // indirect
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
)
17 changes: 10 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/gotk3/gotk3/gtk"
)

const version = "0.3.0"
const version = "0.3.1"

type WindowState int

Expand Down Expand Up @@ -395,11 +395,14 @@ func main() {

dataHome = getDataHome()
configDirectory = configDir()
// if doesn't exist:
// if it doesn't exist:
createDir(configDirectory)

if !pathExists(fmt.Sprintf("%s/style.css", configDirectory)) {
copyFile(filepath.Join(dataHome, "nwg-dock/style.css"), fmt.Sprintf("%s/style.css", configDirectory))
err := copyFile(filepath.Join(dataHome, "nwg-dock/style.css"), fmt.Sprintf("%s/style.css", configDirectory))
if err != nil {
log.Warnf("Error copying file: %s", err)
}
}

cacheDirectory := cacheDir()
Expand Down Expand Up @@ -597,8 +600,8 @@ func main() {
for _, monitor := range monitors {
win := setupHotSpot(monitor, win)

context, _ := win.GetStyleContext()
context.AddProvider(mRefProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
ctx, _ := win.GetStyleContext()
ctx.AddProvider(mRefProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

win.ShowAll()
}
Expand All @@ -607,8 +610,8 @@ func main() {
monitor := output2mon[*targetOutput]
win := setupHotSpot(*monitor, win)

context, _ := win.GetStyleContext()
context.AddProvider(mRefProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
ctx, _ := win.GetStyleContext()
ctx.AddProvider(mRefProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

win.ShowAll()
}
Expand Down
13 changes: 6 additions & 7 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -585,7 +584,7 @@ func tempDir() string {
}

func readTextFile(path string) (string, error) {
bytes, err := ioutil.ReadFile(path)
bytes, err := os.ReadFile(path)
if err != nil {
return "", err
}
Expand All @@ -597,7 +596,7 @@ func configDir() string {
if os.Getenv("XDG_CONFIG_HOME") != "" {
return (fmt.Sprintf("%s/nwg-dock", os.Getenv("XDG_CONFIG_HOME")))
}
return (fmt.Sprintf("%s/.config/nwg-dock", os.Getenv("HOME")))
return fmt.Sprintf("%s/.config/nwg-dock", os.Getenv("HOME"))
}

func createDir(dir string) {
Expand Down Expand Up @@ -718,7 +717,7 @@ func getIcon(appName string) (string, error) {
func searchDesktopDirs(badAppID string) string {
b4Hyphen := strings.Split(badAppID, "-")[0]
for _, d := range appDirs {
items, _ := ioutil.ReadDir(d)
items, _ := os.ReadDir(d)
for _, item := range items {
if strings.Contains(item.Name(), b4Hyphen) {
//Let's check items starting from 'org.' first
Expand All @@ -737,7 +736,7 @@ func getExec(appName string) (string, error) {
cmd = "gimp"
}
for _, d := range appDirs {
files, _ := ioutil.ReadDir(d)
files, _ := os.ReadDir(d)
path := ""
for _, f := range files {
if strings.HasSuffix(f.Name(), ".desktop") {
Expand Down Expand Up @@ -779,7 +778,7 @@ func getExec(appName string) (string, error) {
func getName(appName string) string {
name := appName
for _, d := range appDirs {
files, _ := ioutil.ReadDir(d)
files, _ := os.ReadDir(d)
path := ""
for _, f := range files {
if strings.HasSuffix(f.Name(), ".desktop") {
Expand Down Expand Up @@ -817,7 +816,7 @@ func pathExists(name string) bool {
}

func loadTextFile(path string) ([]string, error) {
bytes, err := ioutil.ReadFile(path)
bytes, err := os.ReadFile(path)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ed6fa95

Please sign in to comment.