diff --git a/README.md b/README.md index 14da3d0..2a7ee75 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ All assets are already exported as .png and included. inkscape and optipng are u * \[ ] appmenu * \[ ] backlight -* \[ ] battery +* \[x] battery * \[ ] bluez4 * \[ ] clock * \[ ] colors diff --git a/arc-dark.edj b/arc-dark.edj index f8cf1f4..5bddaf5 100644 Binary files a/arc-dark.edj and b/arc-dark.edj differ diff --git a/arc.edj b/arc.edj index dd1c8ae..d79f0d7 100644 Binary files a/arc.edj and b/arc.edj differ diff --git a/src/Makefile b/src/Makefile index 6bd7846..01a46fc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,6 +39,7 @@ edc/pager16_arc.edc \ edc/fileman_arc.edc \ edc/toolbar_arc.edc \ edc/background_arc.edc \ +edc/battery_arc.edc \ edc/conf_arc.edc \ edc/clock_arc.edc \ edc/shelf_arc.edc \ diff --git a/src/common_includes_arc.edc b/src/common_includes_arc.edc index 867e0e4..ab3dccf 100644 --- a/src/common_includes_arc.edc +++ b/src/common_includes_arc.edc @@ -132,7 +132,7 @@ // #include "../orig-theme/edc/temperature.edc" // #include "../orig-theme/edc/backlight.edc" // #include "../orig-theme/edc/mixer.edc" -// #include "../orig-theme/edc/battery.edc" +#include "edc/battery_arc.edc" #include "edc/evrything_arc.edc" // #include "../orig-theme/edc/illume.edc" // #include "../orig-theme/edc/bluez4.edc" diff --git a/src/edc/battery_arc.edc b/src/edc/battery_arc.edc new file mode 100644 index 0000000..278fdb0 --- /dev/null +++ b/src/edc/battery_arc.edc @@ -0,0 +1,171 @@ +group { name: "e/modules/battery/main"; + externals { + external: "elm"; + } + min: 24 24; + + script { + public global_charging_state; + + public message(Msg_Type:type, id, ...) + { + if ((type != MSG_FLOAT) || (id != 1)) + return; + + new base_icon_name[200]; + new full_icon_name[256]; + new Float:val; + val = getfarg(2); + + if (val < 0.05) { + snprintf(base_icon_name, sizeof(base_icon_name), "%s", "battery-empty"); + } else if (val < 0.10) { + snprintf(base_icon_name, sizeof(base_icon_name), "%s", "battery-caution"); + } else if (val < 0.5) { + snprintf(base_icon_name, sizeof(base_icon_name), "%s", "battery-low"); + } else if (val < 0.98) { + snprintf(base_icon_name, sizeof(base_icon_name), "%s", "battery-good"); + } else { + snprintf(base_icon_name, sizeof(base_icon_name), "%s", "battery-full"); + } + + if (get_int(global_charging_state) == 1) { + snprintf(full_icon_name, sizeof(full_icon_name), "%s-charging-symbolic", base_icon_name); + } else { + snprintf(full_icon_name, sizeof(full_icon_name), "%s-symbolic", base_icon_name); + } + + external_param_set_str(PART:"elm.icon", "icon", full_icon_name); + } + } + parts { + + part { name: "elm.icon"; type: EXTERNAL; + source: "elm/icon"; + mouse_events: 0; + description { state: "default" 0.0; + fixed: 1 1; + aspect: 1.0 1.0; aspect_preference: BOTH; + } + } + part { name: "info_clip"; type: RECT; + description { state: "default" 0.0; + color: 255 255 255 0; + } + description { state: "visible" 0.0; + color: 255 255 255 255; + } + } + part { name: "e.text.reading"; type: TEXT; mouse_events: 0; + scale: 1; + clip_to: "info_clip"; + description { state: "default" 0.0; + align: 0.5 0.0; + rel2.relative: 1.0 0.5; + color: COL_FONT_BASIC_DEFAULT; + text { font: FN; + fit: 1 1; + ellipsis: -1; + align: 0.5 0.5; + } + } + } + part { name: "e.text.time"; type: TEXT; mouse_events: 0; + scale: 1; + clip_to: "info_clip"; + description { state: "default" 0.0; + align: 0.5 1.0; + rel1.relative: 0.0 0.5; + color: COL_FONT_BASIC_DEFAULT; + text { font: FN; + fit: 1 1; + ellipsis: -1; + align: 0.5 0.5; + } + } + } + part { name: "over"; type: RECT; + description { state: "default" 0.0; + color: 0 0 0 0; + } + } + } + programs { + program { + signal: "mouse,in"; source: "over"; + action: STATE_SET "visible" 0.0; + transition: LINEAR 0.3; + target: "info_clip"; + } + program { + signal: "mouse,out"; source: "over"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.3; + target: "info_clip"; + } + program { + signal: "e,state,charging"; source: "e"; + action: STATE_SET "visible" 0.0; + script { + set_int(global_charging_state, 1); + } + } + program { + signal: "e,state,discharging"; source: "e"; + action: STATE_SET "default" 0.0; + script { + set_int(global_charging_state, 0); + } + } + program { + signal: "e,state,unknown"; source: "e"; + action: STATE_SET "faded" 0.0; + script { + send_message(MSG_STRING_SET, 0xfd0, "e.swallow.icon", "battery-missing"); + } + } + } +} + +group { name: "e/modules/battery/popup"; + min: 240 60; + parts { + part { name: "e.swallow.battery"; type: SWALLOW; + description { state: "default" 0.0; + aspect: 1.0 1.0; aspect_preference: VERTICAL; + min: 1 1; + max: 160 160; + align: 0.0 0.5; + } + } + part { name: "e.text.title"; type: TEXT; + scale: 1; + description { state: "default" 0.0; + rel1.relative: 1.0 0.0; + rel1.to_x: "e.swallow.battery"; + rel2.relative: 1.0 0.5; + color: COL_FONT_BASIC_DEFAULT; + text { font: "Sans:style=Bold"; size: 10; + text: "Your battery is low!"; + min: 1 1; + ellipsis: -1; + text_class: "module_large"; + } + } + } + part { name: "e.text.label"; type: TEXT; + scale: 1; + description { state: "default" 0.0; + rel1.relative: 1.0 0.5; + rel1.to_x: "e.swallow.battery"; + color: COL_FONT_BASIC_DEFAULT; + text { font: "Sans"; size: 10; + text: "AC power is recommended."; + min: 1 1; + ellipsis: -1; + text_class: "module_normal"; + } + } + } + } +}