Commit 201ea843 by o9000

Battery: new config option battery_full_cmd (fixes issue #585)

parent dee210ce
2017-06-20 master
- Enhancements:
- Taskbar: new config option taskbar_hide_different_desktop
- Battery: new config option bat1_format and bat2_format
- Battery: new config option battery_full_cmd
2017-06-11 0.14.6
- Fixes:
......
......@@ -536,6 +536,8 @@ The action semantics:
* `battery_low_cmd = notify-send "battery low"` : Command to execute when the battery is low.
* `battery_full_cmd = notify-send "battery full"` : Command to execute when the battery is full.
* `bat1_font = [FAMILY-LIST] [STYLE-OPTIONS] [SIZE]`
* `bat2_font = [FAMILY-LIST] [STYLE-OPTIONS] [SIZE]`
......
......@@ -49,9 +49,11 @@ static char buf_bat_line2[BATTERY_BUF_SIZE];
int8_t battery_low_status;
gboolean battery_low_cmd_sent;
gboolean battery_full_cmd_sent;
char *ac_connected_cmd;
char *ac_disconnected_cmd;
char *battery_low_cmd;
char *battery_full_cmd;
char *battery_lclick_command;
char *battery_mclick_command;
char *battery_rclick_command;
......@@ -73,6 +75,7 @@ void default_battery()
battery_found = FALSE;
percentage_hide = 101;
battery_low_cmd_sent = FALSE;
battery_full_cmd_sent = FALSE;
battery_timeout = NULL;
bat1_has_font = FALSE;
bat1_font_desc = NULL;
......@@ -83,6 +86,7 @@ void default_battery()
ac_connected_cmd = NULL;
ac_disconnected_cmd = NULL;
battery_low_cmd = NULL;
battery_full_cmd = NULL;
battery_lclick_command = NULL;
battery_mclick_command = NULL;
battery_rclick_command = NULL;
......@@ -103,6 +107,8 @@ void cleanup_battery()
bat2_font_desc = NULL;
free(battery_low_cmd);
battery_low_cmd = NULL;
free(battery_full_cmd);
battery_full_cmd = NULL;
free(bat1_format);
bat1_format = NULL;
free(bat2_format);
......@@ -342,6 +348,16 @@ void update_battery_tick(void *arg)
battery_low_cmd_sent = FALSE;
}
if ((battery_state.percentage >= 100 || battery_state.state == BATTERY_FULL) &&
!battery_full_cmd_sent) {
tint_exec_no_sn(battery_full_cmd);
battery_full_cmd_sent = TRUE;
}
if (battery_state.percentage < 100 && battery_state.state != BATTERY_FULL &&
battery_full_cmd_sent) {
battery_full_cmd_sent = FALSE;
}
for (int i = 0; i < num_panels; i++) {
// Show/hide if needed
if (!battery_found) {
......
......@@ -56,6 +56,7 @@ extern int percentage_hide;
extern int8_t battery_low_status;
extern char *battery_low_cmd;
extern char *battery_full_cmd;
extern char *ac_connected_cmd;
extern char *ac_disconnected_cmd;
......
......@@ -544,6 +544,11 @@ void add_entry(char *key, char *value)
#ifdef ENABLE_BATTERY
if (strlen(value) > 0)
battery_low_cmd = strdup(value);
#endif
} else if (strcmp(key, "battery_full_cmd") == 0) {
#ifdef ENABLE_BATTERY
if (strlen(value) > 0)
battery_full_cmd = strdup(value);
#endif
} else if (strcmp(key, "ac_connected_cmd") == 0) {
#ifdef ENABLE_BATTERY
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tint2conf 0.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-20 20:22+0200\n"
"POT-Creation-Date: 2017-06-20 20:35+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -60,12 +60,12 @@ msgid "System tray"
msgstr ""
#: ../properties.c:336 ../properties.c:1100 ../properties.c:1313
#: ../properties.c:5621
#: ../properties.c:5634
msgid "Battery"
msgstr ""
#: ../properties.c:344 ../properties.c:4591 ../properties.c:4691
#: ../properties.c:5880
#: ../properties.c:5893
msgid "Tooltip"
msgstr ""
......@@ -242,14 +242,14 @@ msgstr ""
#: ../properties.c:621 ../properties.c:2269 ../properties.c:2745
#: ../properties.c:3237 ../properties.c:3876 ../properties.c:4105
#: ../properties.c:4448 ../properties.c:4804 ../properties.c:5187
#: ../properties.c:5602 ../properties.c:5861
#: ../properties.c:5615 ../properties.c:5874
msgid "<b>Appearance</b>"
msgstr ""
#: ../properties.c:635 ../properties.c:2282 ../properties.c:3644
#: ../properties.c:3889 ../properties.c:4118 ../properties.c:4461
#: ../properties.c:4817 ../properties.c:5200 ../properties.c:5615
#: ../properties.c:5874
#: ../properties.c:4817 ../properties.c:5200 ../properties.c:5628
#: ../properties.c:5887
msgid "Background"
msgstr ""
......@@ -262,7 +262,7 @@ msgstr ""
#: ../properties.c:653 ../properties.c:2316 ../properties.c:2759
#: ../properties.c:2880 ../properties.c:3335 ../properties.c:3906
#: ../properties.c:4176 ../properties.c:4478 ../properties.c:4834
#: ../properties.c:5218 ../properties.c:5632 ../properties.c:5891
#: ../properties.c:5218 ../properties.c:5645 ../properties.c:5904
msgid "Horizontal padding"
msgstr ""
......@@ -275,7 +275,7 @@ msgstr ""
#: ../properties.c:671 ../properties.c:2333 ../properties.c:2777
#: ../properties.c:2898 ../properties.c:3352 ../properties.c:3923
#: ../properties.c:4189 ../properties.c:4495 ../properties.c:4851
#: ../properties.c:5236 ../properties.c:5649 ../properties.c:5908
#: ../properties.c:5236 ../properties.c:5662 ../properties.c:5921
msgid "Vertical padding"
msgstr ""
......@@ -403,8 +403,8 @@ msgid ""
"enters the panel."
msgstr ""
#: ../properties.c:909 ../properties.c:949 ../properties.c:5830
#: ../properties.c:5853
#: ../properties.c:909 ../properties.c:949 ../properties.c:5843
#: ../properties.c:5866
msgid "seconds"
msgstr ""
......@@ -738,7 +738,7 @@ msgid ""
"application starts."
msgstr ""
#: ../properties.c:2482 ../properties.c:5498
#: ../properties.c:2482 ../properties.c:5511
msgid "Tooltips"
msgstr ""
......@@ -957,14 +957,14 @@ msgstr ""
#: ../properties.c:2957 ../properties.c:3387 ../properties.c:3945
#: ../properties.c:3981 ../properties.c:4517 ../properties.c:4873
#: ../properties.c:5671 ../properties.c:5706 ../properties.c:5930
#: ../properties.c:5684 ../properties.c:5719 ../properties.c:5943
msgid ""
"If not checked, the desktop theme font is used. If checked, the custom font "
"specified here is used."
msgstr ""
#: ../properties.c:2962 ../properties.c:3392 ../properties.c:4522
#: ../properties.c:4878 ../properties.c:5935
#: ../properties.c:4878 ../properties.c:5948
msgid "Font"
msgstr ""
......@@ -993,7 +993,7 @@ msgid ""
msgstr ""
#: ../properties.c:3028 ../properties.c:3777 ../properties.c:4349
#: ../properties.c:4705 ../properties.c:5485
#: ../properties.c:4705 ../properties.c:5498
msgid "<b>Mouse events</b>"
msgstr ""
......@@ -1253,7 +1253,7 @@ msgid "If enabled, a custom font color is used to display the task text."
msgstr ""
#: ../properties.c:3564 ../properties.c:4012 ../properties.c:4540
#: ../properties.c:4896 ../properties.c:5736 ../properties.c:5951
#: ../properties.c:4896 ../properties.c:5749 ../properties.c:5964
msgid "Font color"
msgstr ""
......@@ -1303,7 +1303,7 @@ msgstr ""
msgid "<b>Format</b>"
msgstr ""
#: ../properties.c:3702 ../properties.c:5753
#: ../properties.c:3702 ../properties.c:5766
msgid "First line format"
msgstr ""
......@@ -1313,7 +1313,7 @@ msgid ""
"'man date' for all the available options."
msgstr ""
#: ../properties.c:3720 ../properties.c:5776
#: ../properties.c:3720 ../properties.c:5789
msgid "Second line format"
msgstr ""
......@@ -1346,7 +1346,7 @@ msgid ""
msgstr ""
#: ../properties.c:3790 ../properties.c:4362 ../properties.c:4718
#: ../properties.c:5516
#: ../properties.c:5529
msgid "Left click command"
msgstr ""
......@@ -1357,7 +1357,7 @@ msgid ""
msgstr ""
#: ../properties.c:3807 ../properties.c:4379 ../properties.c:4735
#: ../properties.c:5533
#: ../properties.c:5546
msgid "Right click command"
msgstr ""
......@@ -1368,7 +1368,7 @@ msgid ""
msgstr ""
#: ../properties.c:3824 ../properties.c:4396 ../properties.c:4752
#: ../properties.c:5550
#: ../properties.c:5563
msgid "Middle click command"
msgstr ""
......@@ -1379,7 +1379,7 @@ msgid ""
msgstr ""
#: ../properties.c:3841 ../properties.c:4413 ../properties.c:4769
#: ../properties.c:5567
#: ../properties.c:5580
msgid "Wheel scroll up command"
msgstr ""
......@@ -1390,7 +1390,7 @@ msgid ""
msgstr ""
#: ../properties.c:3858 ../properties.c:4430 ../properties.c:4786
#: ../properties.c:5584
#: ../properties.c:5597
msgid "Wheel scroll down command"
msgstr ""
......@@ -1418,7 +1418,7 @@ msgid ""
"border and the content inside."
msgstr ""
#: ../properties.c:3950 ../properties.c:5676
#: ../properties.c:3950 ../properties.c:5689
msgid "Font first line"
msgstr ""
......@@ -1426,7 +1426,7 @@ msgstr ""
msgid "Specifies the font used to display the first line of the clock."
msgstr ""
#: ../properties.c:3986 ../properties.c:5711
#: ../properties.c:3986 ../properties.c:5724
msgid "Font second line"
msgstr ""
......@@ -1797,150 +1797,154 @@ msgstr ""
msgid "Command to be executed when the alert threshold is reached."
msgstr ""
#: ../properties.c:5437
msgid "<b>AC connection events</b>"
#: ../properties.c:5436
msgid "Battery full command"
msgstr ""
#: ../properties.c:5450
msgid "AC connected command"
msgid "<b>AC connection events</b>"
msgstr ""
#: ../properties.c:5463
msgid "AC connected command"
msgstr ""
#: ../properties.c:5476
msgid ""
"Specifies a command that will be executed when AC is connected to the system."
msgstr ""
#: ../properties.c:5467
#: ../properties.c:5480
msgid "AC disconnected command"
msgstr ""
#: ../properties.c:5480
#: ../properties.c:5493
msgid ""
"Specifies a command that will be executed when AC is disconnected to the "
"system."
msgstr ""
#: ../properties.c:5511
#: ../properties.c:5524
msgid ""
"If enabled, shows a tooltip with detailed battery information when the mouse "
"is moved over the battery widget."
msgstr ""
#: ../properties.c:5529
#: ../properties.c:5542
msgid ""
"Specifies a command that will be executed when the battery receives a left "
"click."
msgstr ""
#: ../properties.c:5546
#: ../properties.c:5559
msgid ""
"Specifies a command that will be executed when the battery receives a right "
"click."
msgstr ""
#: ../properties.c:5563
#: ../properties.c:5576
msgid ""
"Specifies a command that will be executed when the battery receives a middle "
"click."
msgstr ""
#: ../properties.c:5580
#: ../properties.c:5593
msgid ""
"Specifies a command that will be executed when the battery receives a mouse "
"scroll up."
msgstr ""
#: ../properties.c:5597
#: ../properties.c:5610
msgid ""
"Specifies a command that will be executed when the battery receives a mouse "
"scroll down."
msgstr ""
#: ../properties.c:5627
#: ../properties.c:5640
msgid ""
"Selects the background used to display the battery. Backgrounds can be "
"edited in the Backgrounds tab."
msgstr ""
#: ../properties.c:5644
#: ../properties.c:5657
msgid ""
"Specifies the horizontal padding of the battery. This is the space between "
"the border and the content inside."
msgstr ""
#: ../properties.c:5661
#: ../properties.c:5674
msgid ""
"Specifies the vertical padding of the battery. This is the space between the "
"border and the content inside."
msgstr ""
#: ../properties.c:5692
#: ../properties.c:5705
msgid "Specifies the font used to display the first line of the battery text."
msgstr ""
#: ../properties.c:5727
#: ../properties.c:5740
msgid "Specifies the font used to display the second line of the battery text."
msgstr ""
#: ../properties.c:5749
#: ../properties.c:5762
msgid "Specifies the font clor used to display the battery text."
msgstr ""
#: ../properties.c:5802
#: ../properties.c:5815
msgid "<b>Timing</b>"
msgstr ""
#: ../properties.c:5815
#: ../properties.c:5828
msgid "Show delay"
msgstr ""
#: ../properties.c:5827
#: ../properties.c:5840
msgid ""
"Specifies a delay after which to show the tooltip when moving the mouse over "
"an element."
msgstr ""
#: ../properties.c:5837
#: ../properties.c:5850
msgid "Hide delay"
msgstr ""
#: ../properties.c:5848
#: ../properties.c:5861
msgid ""
"Specifies a delay after which to hide the tooltip when moving the mouse "
"outside an element."
msgstr ""
#: ../properties.c:5886
#: ../properties.c:5899
msgid ""
"Selects the background used to display the tooltip. Backgrounds can be "
"edited in the Backgrounds tab."
msgstr ""
#: ../properties.c:5903
#: ../properties.c:5916
msgid ""
"Specifies the horizontal padding of the tooltip. This is the space between "
"the border and the content inside."
msgstr ""
#: ../properties.c:5920
#: ../properties.c:5933
msgid ""
"Specifies the vertical padding of the tooltip. This is the space between the "
"border and the content inside."
msgstr ""
#: ../properties.c:5946
#: ../properties.c:5959
msgid "Specifies the font used to display the text of the tooltip."
msgstr ""
#: ../properties.c:5964
#: ../properties.c:5977
msgid "Specifies the font color used to display the text of the tooltip."
msgstr ""
#: ../properties.c:5981
#: ../properties.c:5994
msgid "Please wait..."
msgstr ""
#: ../properties.c:5984
#: ../properties.c:5997
msgid "Loading..."
msgstr ""
......
......@@ -80,7 +80,7 @@ GtkWidget *clock_font_line1, *clock_font_line1_set, *clock_font_line2, *clock_fo
GtkWidget *clock_background;
// battery
GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd;
GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd, *battery_alert_full_cmd;
GtkWidget *battery_padding_x, *battery_padding_y;
GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set,
*battery_font_color, *battery_format1, *battery_format2;
......@@ -5432,6 +5432,19 @@ void create_battery(GtkWidget *parent)
_("Command to be executed when the alert threshold is reached."),
NULL);
row++, col = 2;
label = gtk_label_new(_("Battery full command"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
battery_alert_full_cmd = gtk_entry_new();
gtk_widget_show(battery_alert_full_cmd);
gtk_entry_set_width_chars(GTK_ENTRY(battery_alert_full_cmd), 50);
gtk_table_attach(GTK_TABLE(table), battery_alert_full_cmd, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
change_paragraph(parent);
label = gtk_label_new(_("<b>AC connection events</b>"));
......
......@@ -88,7 +88,7 @@ extern GtkWidget *clock_font_line1, *clock_font_line1_set, *clock_font_line2, *c
extern GtkWidget *clock_background;
// battery
extern GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd;
extern GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd, *battery_alert_full_cmd;
extern GtkWidget *battery_padding_x, *battery_padding_y;
extern GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set,
*battery_font_color, *battery_format1, *battery_format2;
......
......@@ -755,6 +755,7 @@ void config_write_battery(FILE *fp)
fprintf(fp, "battery_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_tooltip)) ? 1 : 0);
fprintf(fp, "battery_low_status = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_alert_if_lower)));
fprintf(fp, "battery_low_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_alert_cmd)));
fprintf(fp, "battery_full_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_alert_full_cmd)));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_font_line1_set)))
fprintf(fp, "bat1_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(battery_font_line1)));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_font_line2_set)))
......@@ -1408,6 +1409,8 @@ void add_entry(char *key, char *value)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_alert_if_lower), atof(value));
} else if (strcmp(key, "battery_low_cmd") == 0) {
gtk_entry_set_text(GTK_ENTRY(battery_alert_cmd), value);
} else if (strcmp(key, "battery_full_cmd") == 0) {
gtk_entry_set_text(GTK_ENTRY(battery_alert_full_cmd), value);
} else if (strcmp(key, "bat1_font") == 0) {
gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line1), value);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_font_line1_set), TRUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment