Use less hardcoded paths, improve README

This commit is contained in:
Camille Scholtz 2018-12-28 00:19:04 +01:00
parent 23e13b7a76
commit 6ea749585f
3 changed files with 11 additions and 4 deletions

@ -9,7 +9,11 @@ melonbar - A concurrent, hackable bar/panel for X written in Go.
`go get github.com/onodera-punpun/melonbar`
`melonbar` depends on Go 1.9 or newer.
Or for a binary that includes embedded static files:
`packr2 get github.com/onodera-punpun/melonbar`
`melonbar` depends on Go 1.9 or newer and [packr2](https://github.com/gobuffalo/packr/tree/master/v2).
## USAGE

@ -4,6 +4,7 @@ import (
"bufio"
"log"
"os"
"path"
"strconv"
"time"
@ -14,6 +15,7 @@ import (
"github.com/BurntSushi/xgbutil/xprop"
"github.com/fhs/gompd/mpd"
"github.com/fsnotify/fsnotify"
"github.com/rkoesters/xdg/basedir"
)
func (bar *Bar) clock() {
@ -150,10 +152,10 @@ func (bar *Bar) todo() {
if err != nil {
log.Fatalln(err)
}
if err := w.Add("/home/onodera/.todo"); err != nil {
if err := w.Add(path.Join(basedir.Home, ".todo")); err != nil {
log.Fatalln(err)
}
f, err := os.Open("/home/onodera/.todo")
f, err := os.Open(path.Join(basedir.Home, ".todo"))
if err != nil {
log.Fatalln(err)
}

@ -10,6 +10,7 @@ import (
"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/fhs/gompd/mpd"
"github.com/rkoesters/xdg/userdirs"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
@ -45,7 +46,7 @@ func (popup *Popup) music(c *mpd.Client) error {
// Find album art.
var f interface{}
f, err = os.Open(path.Join("/home/onodera/media/music/", path.Dir(
f, err = os.Open(path.Join(userdirs.Music, path.Dir(
cur["file"]), "cover_popup.png"))
if err != nil {
f, err = box.Open("images/cover.png")