Skip to content
Snippets Groups Projects
Select Git revision
  • 7410cef1fd960a90e56d893c4a774f3b24eff666
  • release default protected
  • more-testing
  • attempt-vax90b1
  • attempt-1
  • conversion protected
  • linux
  • v0.9.1 protected
  • v0.9.0 protected
9 results

batch.go

Blame
  • run.go 899 B
    // Package bar handles the main program for i3going-on.
    // Copyright (C) 2022 Kevin Lyda <kevin@lyda.ie>
    package bar
    
    import (
    	"fmt"
    	"strings"
    	"time"
    
    	"github.com/spf13/cobra"
    	"github.com/spf13/viper"
    	"golang.org/x/sys/unix"
    )
    
    // Run is essentially the main program.
    func Run(cmd *cobra.Command, args []string) {
    	viper.BindPFlags(cmd.Flags())
    	cfg, err := readConfig(viper.GetString("config"))
    	cobra.CheckErr(err)
    	go handleCommands()
    
    	fmt.Printf(`{ "version": 1, "stop_signal": %d, "cont_signal": %d, "click_events": true }`+"\n",
    		unix.SignalNum("SIGSTOP"), unix.SignalNum("SIGCONT"))
    	separator := "["
    	for {
    		line := make([]string, 0, 5)
    		for _, module := range cfg.Modules {
    			line = append(line, module.Render())
    		}
    		fmt.Printf("%s\n[%s]", separator, strings.Join(line, ","))
    		separator = ","
    		select {
    		case <-time.After(time.Duration(cfg.Refresh) * time.Second):
    		}
    	}
    }