}
}
-static void log_measures(struct psensor **sensors)
-{
- if (log_level == LOG_DEBUG)
- while (*sensors) {
- log_debug("Measure: %s %.2f",
- (*sensors)->name,
- psensor_get_current_value(*sensors));
-
- sensors++;
- }
-}
-
void update_psensor_measures(struct ui_psensor *ui)
{
struct psensor **sensors = ui->sensors;
amd_psensor_list_update(sensors);
#endif
- log_measures(sensors);
+ psensor_log_measures(sensors);
g_mutex_unlock(ui->sensors_mutex);
g_mutex_lock(ui->sensors_mutex);
- graph_update(ui->sensors, ui->w_graph, ui->config);
+ graph_update(ui->sensors, ui->w_graph, ui->config, ui->main_window);
ui_sensorlist_update(ui);
#ifdef HAVE_UNITY
ui_unity_launcher_entry_update(ui->sensors,
- !cfg->unity_launcher_count_disabled);
+ !cfg->unity_launcher_count_disabled,
+ cfg->temperature_unit == CELCIUS);
#endif
if (ui->graph_update_interval != cfg->graph_update_interval) {
n = config_get_sensor_name(s->id);
- if (n)
+ if (n) {
+ free(s->name);
s->name = n;
+ }
sensor_cur++;
}
glib_micro_version);
}
+static void activate(GApplication *application,
+ gpointer data)
+{
+ ui_window_show((struct ui_psensor *)data);
+}
+
int main(int argc, char **argv)
{
struct ui_psensor ui;
GThread *thread;
int optc, cmdok, opti, use_libatasmart;
char *url = NULL;
+ GApplication *app;
program_name = argv[0];
log_init();
+ app = g_application_new("wpitchoune.psensor", 0);
+ g_application_register(app, NULL, NULL);
+
+ if (g_application_get_is_remote(app)) {
+ g_application_activate(app);
+ log_debug(_("Psensor instance already exists"));
+ exit(EXIT_SUCCESS);
+ }
+
+ g_signal_connect(app, "activate", G_CALLBACK(activate), &ui);
+
log_glib_info();
#if !(GLIB_CHECK_VERSION(2, 31, 0))
/*
#if !defined(HAVE_APPINDICATOR) && !defined(HAVE_APPINDICATOR_029)
ui_status_init(&ui);
+ ui_status_set_visible(1);
#endif
/* main window */
/* drawing box */
ui.w_graph = ui_graph_create(&ui);
+ ui_enable_alpha_channel(&ui);
+
/* sensor list */
ui_sensorlist_create(&ui);
#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
ui_appindicator_init(&ui);
+ ui_status_set_visible(1);
#endif
/*
/* main loop */
gtk_main();
+ log_debug("Quitting...");
+
g_mutex_lock(ui.sensors_mutex);
psensor_cleanup();
config_cleanup();
+ log_debug("Cleanup done, closing log");
+
log_close();
return 0;