Ejemplo 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),
	}
}
Ejemplo n.º 2
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()
	}
}
Ejemplo 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),
	}
}
Ejemplo n.º 4
0
Archivo: Mem.go Proyecto: 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),
	}
}
Ejemplo 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),
	}
}
Ejemplo n.º 6
0
// Load user configuration if needed and initialise applet.
//
func (app *AppletGmail) Init(loadConf bool) {
	if loadConf { // Try to load config. Exit if not found.
		app.conf = &mailConf{}
		log.Fatal(app.LoadConfig(&app.conf, dock.GetKey), "config")
	}
	log.SetDebug(app.conf.Debug)

	// Reset data to be sure our display will be refreshed.
	app.data.Clear()
	app.err = nil

	// Fill config empty settings.
	if app.conf.MonitorName == "" {
		app.conf.MonitorName = app.conf.DefaultMonitorName
	}
	if app.conf.AlertSoundFile == "" {
		app.conf.AlertSoundFile = app.conf.DefaultAlertSoundFile
	}
	if app.conf.UpdateDelay == 0 {
		app.conf.UpdateDelay = defaultUpdateDelay
	}

	// Set defaults to dock icon: display and controls.
	def := cdtype.Defaults{
		Shortkeys: []string{app.conf.ShortkeyOpen, app.conf.ShortkeyCheck},
		Label:     "Mail unchecked",
		Templates: []string{"InternalDialog"},
	}
	if app.conf.Icon != "" && app.conf.Renderer != EmblemSmall && app.conf.Renderer != EmblemLarge { // User selected icon.
		def.Icon = app.conf.Icon
	}
	if app.conf.MonitorEnabled {
		def.MonitorName = app.conf.MonitorName
	}
	app.SetDefaults(def)

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

	case EmblemSmall, EmblemLarge:
		app.render = NewRenderedSVG(app.CDApplet, app.conf.Renderer)

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

	// Configure the mail polling loop.
	app.poller.SetInterval(app.conf.UpdateDelay)
}
Ejemplo n.º 7
0
Archivo: update.go Proyecto: sqp/godock
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Defaults.
	def.PollerInterval = app.conf.VersionPollingTimer.Value()
	def.Commands[cmdShowDiff] = cdtype.NewCommand(app.conf.DiffMonitored, app.conf.DiffCommand)

	// Version polling state.
	if app.conf.VersionPollingEnabled {
		app.Poller().Start()
	} else {
		app.Poller().Stop()
	}

	// Branches for versions checking.
	app.version.Clear()
	app.version.AddSources(
		versions.NewRepo(app.Log(), "cairo-dock-core", path.Join(app.conf.SourceDir, app.conf.DirCore)),
		versions.NewRepo(app.Log(), "cairo-dock-plug-ins", path.Join(app.conf.SourceDir, app.conf.DirApplets)),
	)
	for _, src := range app.conf.SourceExtra {
		app.version.AddSources(versions.NewRepo(app.Log(), path.Base(src), src))
	}

	// Build targets. Allow actions on sources and displays emblem on top left for togglable target.
	app.setBuildTarget()

	// Build globals.
	build.CmdSudo = app.conf.CommandSudo
	build.IconMissing = app.FileLocation("img", app.conf.IconMissing)
}
Ejemplo n.º 8
0
Archivo: Cpu.go Proyecto: 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)
}
Ejemplo n.º 9
0
// Init is called after load config. We'll set the poller interval.
//
func (app *PollerApplet) Init(def *cdtype.Defaults, confLoaded bool) {
	// In Init, we'll use the Defaults as it's already provided.
	def.PollerInterval = app.conf.UpdateInterval.Value()

	// But you can also set a poller interval directly anytime.
	app.Poller().SetInterval(app.conf.UpdateInterval.Value())

	// Set your other defaults here...

	// Set your other variable settings here...
}
Ejemplo n.º 10
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...
}
Ejemplo n.º 11
0
Archivo: clouds.go Proyecto: sqp/godock
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Defaults.
	def.PollerInterval = app.conf.UpdateDelay.Value()

	// Share the conf with the weather service.
	app.weather.SetConfig(&app.conf.Config)
	app.weather.Clear()

	// if app.conf.WeatherTheme == "" {
	app.conf.WeatherTheme = defaultTheme
	// }

	// Set theme full path.
	app.conf.WeatherTheme = app.ThemePath(app.conf.WeatherTheme)

	if app.conf.LocationCode == "" {
		app.DetectLocation()
	}
}