diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-02-03 16:56:15 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-02-03 16:56:15 (GMT) |
commit | 6e820d4dc8e5b814ddadfd9d295acac4cd2ca916 (patch) | |
tree | 2136e54c8fe16cb7d9ae9d33d3f98d61db2dacf8 /src | |
parent | 784a184c3f292f9c84138dba180e4b30bca341a3 (diff) |
fetch username from system
Diffstat (limited to 'src')
-rw-r--r-- | src/rhlibrary/app_window.go | 4 | ||||
-rw-r--r-- | src/rhlibrary/main.go | 14 | ||||
-rw-r--r-- | src/rhlibrary/show_selector_widget.go | 2 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/rhlibrary/app_window.go b/src/rhlibrary/app_window.go index cf8ef18..2ed4c6a 100644 --- a/src/rhlibrary/app_window.go +++ b/src/rhlibrary/app_window.go @@ -25,6 +25,8 @@ package main import ( + "fmt" + "code.helsinki.at/rhrd-go/player" "code.helsinki.at/rhrd-go/rddb" "github.com/gotk3/gotk3/gtk" @@ -73,7 +75,7 @@ func NewAppWindow(db *rddb.DBChan, player *player.PlayerChan, width, height int) if aw.win, err = gtk.WindowNew(gtk.WINDOW_TOPLEVEL); err != nil { return } - aw.win.SetTitle("rhlibrary") + aw.win.SetTitle(fmt.Sprintf("rhlibrary: logged in as %s", rhuser.Username)) aw.win.Connect("destroy", func() { gtk.MainQuit() }) diff --git a/src/rhlibrary/main.go b/src/rhlibrary/main.go index 8221091..91e5790 100644 --- a/src/rhlibrary/main.go +++ b/src/rhlibrary/main.go @@ -30,6 +30,7 @@ import ( "io/ioutil" "log" "os" + "os/user" "code.helsinki.at/rhrd-go/player" "code.helsinki.at/rhrd-go/rddb" @@ -37,14 +38,20 @@ import ( ) var ( - rhl = log.New(os.Stderr, "[rhlibrary]\t", log.LstdFlags) - rhdl = log.New(ioutil.Discard, "[rhlibrary-dbg]\t", log.LstdFlags) + rhl = log.New(os.Stderr, "[rhlibrary]\t", log.LstdFlags) + rhdl = log.New(ioutil.Discard, "[rhlibrary-dbg]\t", log.LstdFlags) + rhuser *user.User ) func init() { // if _, exists := os.LookupEnv("RHLIBRARY_DEBUG"); exists { rhdl.SetOutput(os.Stderr) // } + + var err error + if rhuser, err = user.Current(); err != nil { + panic(fmt.Sprintf("can't fetch current user: %s", err.Error())) + } } type envStringValue string @@ -97,6 +104,9 @@ func main() { rhl.Println("Error initializing Main Window:", err) return } + + + rhl.Printf("rhlibrary started as user: %s", rhuser.Username) mw.ShowAndRun() gtk.Main() diff --git a/src/rhlibrary/show_selector_widget.go b/src/rhlibrary/show_selector_widget.go index 1d4b90b..3b9d464 100644 --- a/src/rhlibrary/show_selector_widget.go +++ b/src/rhlibrary/show_selector_widget.go @@ -55,7 +55,7 @@ func getShowsSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, grid.SetHExpand(true) grid.SetVExpand(true) - shows, err := db.GetShowList("equinox") // TODO: get username from system + shows, err := db.GetShowList(rhuser.Username) if err != nil { rhdl.Println(err) // TODO: feedback at GUI? return grid, nil |