Exemplo n.º 1
0
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Uptoshare settings.
	app.up.SetHistoryFile(app.FileDataDir(cdglobal.DirUserAppData, uptoshare.HistoryFile))
	app.up.SetHistorySize(app.conf.UploadHistory)
	app.up.LimitRate = app.conf.UploadRateLimit
	app.up.PostAnonymous = app.conf.PostAnonymous
	app.up.FileForAll = app.conf.FileForAll
	app.up.SiteFile(app.conf.SiteFile)
	app.up.SiteImage(app.conf.SiteImage)
	app.up.SiteText(app.conf.SiteText)
	app.up.SiteVideo(app.conf.SiteVideo)

	// Video download settings.
	app.video.SetConfig(&app.conf.Config)
	app.video.SetEnabledWeb(videodl.WebState(app.conf.EnabledWeb))

	// Settings for poller and IOActivity (force renderer reset in case of reload).
	app.service.Settings(uint64(app.conf.UpdateDelay.Value()), app.conf.DisplayText,
		app.conf.DisplayValues, app.conf.GraphType, app.conf.GaugeName, app.conf.Devices...)

	// Defaults.
	def.PollerInterval = app.conf.UpdateDelay.Value()
	def.Commands = cdtype.Commands{
		cmdLeft:   cdtype.NewCommandStd(app.conf.LeftAction, app.conf.LeftCommand, app.conf.LeftClass),
		cmdMiddle: cdtype.NewCommandStd(app.conf.MiddleAction, app.conf.MiddleCommand),
	}
}
Exemplo n.º 2
0
Arquivo: Cpu.go Projeto: sqp/godock
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Settings for poller and renderer.
	app.service.Settings(app.conf.DisplayText, app.conf.DisplayValues, app.conf.GraphType, app.conf.GaugeName)
	app.service.SetSize(1)
	app.service.interval = app.conf.UpdateDelay.Value()

	// Defaults.
	def.PollerInterval = app.conf.UpdateDelay.Value()
	def.Commands[cmdLeft] = cdtype.NewCommandStd(app.conf.LeftAction, app.conf.LeftCommand, app.conf.LeftClass)
	def.Commands[cmdMiddle] = cdtype.NewCommandStd(app.conf.MiddleAction, app.conf.MiddleCommand)
}
Exemplo n.º 3
0
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Settings for poller and IOActivity (force renderer reset in case of reload).
	app.service.Settings(uint64(app.conf.UpdateDelay.Value()), cdtype.InfoPosition(app.conf.DisplayText), app.conf.DisplayValues, app.conf.GraphType, app.conf.GaugeName, app.conf.Disks...)

	// Defaults.
	def.PollerInterval = app.conf.UpdateDelay.Value()
	def.Commands = cdtype.Commands{
		cmdLeft:   cdtype.NewCommandStd(app.conf.LeftAction, app.conf.LeftCommand, app.conf.LeftClass),
		cmdMiddle: cdtype.NewCommandStd(app.conf.MiddleAction, app.conf.MiddleCommand),
	}
}
Exemplo n.º 4
0
Arquivo: Mem.go Projeto: sqp/godock
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Settings for service.
	app.service.Settings(app.conf.DisplayText, app.conf.DisplayValues, app.conf.GraphType, app.conf.GaugeName)
	app.service.SetSize(countTrue(app.conf.ShowRAM, app.conf.ShowSwap))

	// Defaults.
	def.PollerInterval = app.conf.UpdateDelay.Value()
	def.Commands = cdtype.Commands{
		cmdLeft:   cdtype.NewCommandStd(app.conf.LeftAction, app.conf.LeftCommand, app.conf.LeftClass),
		cmdMiddle: cdtype.NewCommandStd(app.conf.MiddleAction, app.conf.MiddleCommand),
	}
}
Exemplo n.º 5
0
// Init loads user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Settings for DiskFree.
	app.service.Settings(app.conf.DisplayText, 0, 0, app.conf.GaugeName)
	app.service.SetParts(app.conf.Partitions, app.conf.AutoDetect)

	// Defaults.
	def.PollerInterval = app.conf.UpdateDelay.Value()
	def.Commands = cdtype.Commands{
		cmdLeft:   cdtype.NewCommandStd(app.conf.LeftAction, app.conf.LeftCommand, app.conf.LeftClass),
		cmdMiddle: cdtype.NewCommandStd(app.conf.MiddleAction, app.conf.MiddleCommand),
	}
}
Exemplo n.º 6
0
// Applet init
//
// Then we will have to declare the mandatory Init(loadConf bool) method:
//
// Init is called at startup and every time the applet is moved or asked to
// reload by the dock.
// When called, the config struct has already been filled from the config file,
// and some Defaults fields may already be set.
// You may still have to set the poller interval, some commands or declare
// shortkeys callbacks.
//
// Defaults fields not set will be reset to icon defaults (apply even if blank).
//
//   -The config data isn't available before the first Init.
//   -Use PreInit event if you need to act on the previous config before deletion.
//   -cdtype.ConfGroupIconBoth sets those def fields: Label, Icon and Debug.
//   -Don't forget that you may have to clean up some old display or data.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Set defaults to dock icon: display and controls.
	def.Commands = cdtype.Commands{
		cmdClickLeft: cdtype.NewCommandStd(
			app.conf.LeftAction,
			app.conf.LeftCommand,
			app.conf.LeftClass),

		cmdClickMiddle: cdtype.NewCommandStd(
			app.conf.MiddleAction,
			app.conf.MiddleCommand),
	}

	// Set your other variable settings here...
}
Exemplo n.º 7
0
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Reset data to be sure our display will be refreshed.
	app.data.Clear()
	app.data.LoadLogin(app.FileDataDir(loginLocation))
	app.err = nil

	// Define the mail client action.
	if app.conf.MailClientName == "" { //  Set default to webpage if not provided.
		app.conf.MailClientAction = MailClientLocation
		app.conf.MailClientName = app.conf.DefaultMonitorName
	}

	// Defaults.
	def.Label = "Mail unchecked"
	def.PollerInterval = app.conf.UpdateDelay.Value()

	// Add 1 to action as we don't provide the none option.
	cmd := cdtype.NewCommandStd(app.conf.MailClientAction+1, app.conf.MailClientName, app.conf.MailClientClass)
	def.Commands = cdtype.Commands{cmdMailClient: cmd}

	// Create the renderer.
	switch app.conf.Renderer {
	case QuickInfo:
		app.render = NewRenderedQuick(app)

	case EmblemSmall, EmblemLarge:
		var e error
		app.render, e = NewRenderedSVG(app, app.conf.Renderer)
		app.Log().Err(e, "renderer svg")

	default: // NoDisplay case, but using default to be sure we have a valid renderer.
		app.render = NewRenderedNone()
	}
}