aurpkg/jwm-git/lang.patch

168 lines
5.8 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff -cr jwm-2.1.0/src/clock.c jwm-roand/src/clock.c
*** jwm-2.1.0/src/clock.c 2012-01-27 01:04:17.000000000 +0000
--- jwm-roand/src/clock.c 2012-03-03 16:14:31.710077664 +0000
***************
*** 22,27 ****
--- 22,31 ----
#include "event.h"
#include "action.h"
+ #include <X11/XKBlib.h>
+ #include <X11/extensions/XKBrules.h>
+
+
/** Structure to respresent a clock tray component. */
typedef struct ClockType {
***************
*** 48,53 ****
--- 52,59 ----
static ClockType *clocks;
+ static char lastLayout[2];
+
static void Create(TrayComponentType *cp);
static void Resize(TrayComponentType *cp);
static void Destroy(TrayComponentType *cp);
***************
*** 241,248 ****
abs(cp->mousex - x) < settings.doubleClickDelta &&
abs(cp->mousey - y) < settings.doubleClickDelta) {
if(GetTimeDifference(now, &cp->mouseTime) >= settings.popupDelay) {
! longTime = GetTimeString("%c", cp->zone);
! ShowPopup(x, y, longTime, POPUP_CLOCK);
}
}
--- 247,304 ----
abs(cp->mousex - x) < settings.doubleClickDelta &&
abs(cp->mousey - y) < settings.doubleClickDelta) {
if(GetTimeDifference(now, &cp->mouseTime) >= settings.popupDelay) {
! longTime = GetTimeString("%d %B %Y%n%A %T", cp->zone);
! FILE *fp1;
! FILE *fp2;
! FILE *fp3;
! FILE *fp4;
! int presentRate = 0;
! int remainingCapacity = 0;
! int lastFullCapacity = 0;
! char charging;
!
! fp1 = fopen("/sys/class/power_supply/BAT0/power_now", "r");
! if(fp1 != NULL) {
! fscanf(fp1, "%d", &presentRate);
! fclose(fp1);
! }
! fp2=fopen("/sys/class/power_supply/BAT0/energy_now", "r");
! if(fp2 != NULL) {
! fscanf(fp2, "%d", &remainingCapacity);
! fclose(fp2);
! }
! fp3 = fopen("/sys/class/power_supply/BAT0/energy_full", "r");
! if(fp3 != NULL) {
! fscanf(fp3, "%d", &lastFullCapacity);
! fclose(fp3);
! }
! fp4 = fopen("/sys/class/power_supply/BAT0/status", "r");
! if(fp4 != NULL) {
! charging=fgetc(fp4);
! fclose(fp4);
! }
! char *out = NULL;
! int perc = (lastFullCapacity != 0) ? ((float)remainingCapacity/(float)lastFullCapacity*100) : 0;
! if(presentRate != 0) {
! int hours = 0;
! int minute = 0;
! if(charging == 'D') {
! hours = remainingCapacity/presentRate;
! minute = ((float)(remainingCapacity)/(float)(presentRate)-hours)*60;
! asprintf(&out, "\nРазрядка, %d%%, %.2d:%.2d",perc, hours, minute);
! } else {
! hours = (float)(lastFullCapacity-remainingCapacity)/(float)presentRate;
! minute = ((float)(lastFullCapacity-remainingCapacity)/(float)(presentRate)-(float)hours)*60;
! asprintf(&out, "\nЗарядка, %d%%, %.2d:%.2d", perc, hours, minute);
! }
! } else {
! if(charging =='D')
! asprintf(&out, "\nРазрядка, %d%%, none", perc);
! else
! asprintf(&out, "\nЗарядка, %d%%, none", perc);
! }
! ShowPopup(x, y, strcat(longTime,out), POPUP_CLOCK);
! free(out);
}
}
***************
*** 256,266 ****
const char *timeString;
int width;
int rwidth;
/* Only draw if the time changed. */
! if(now->seconds == clk->lastTime.seconds) {
return;
}
/* Clear the area. */
cp = clk->cp;
--- 312,332 ----
const char *timeString;
int width;
int rwidth;
+
+ XkbStateRec state;
+ XkbGetState(display, XkbUseCoreKbd, &state);
+
+ XkbDescPtr desc = XkbGetKeyboard(display, XkbAllComponentsMask, XkbUseCoreKbd);
+ char *group = XGetAtomName(display, desc->names->groups[state.group]);
+ char layout[2];
+ strncpy(layout, group, 2);
/* Only draw if the time changed. */
! if((int)(now->seconds/60) == (int)(clk->lastTime.seconds/60) && layout == lastLayout) {
return;
}
+ clk->lastTime.seconds = now->seconds;
+ strncpy(lastLayout, layout, 2);
/* Clear the area. */
cp = clk->cp;
***************
*** 274,281 ****
0, 0, cp->width, cp->height);
}
/* Determine if the clock is the right size. */
! timeString = GetTimeString(clk->format, clk->zone);
width = GetStringWidth(FONT_CLOCK, timeString);
rwidth = width + 4;
if(rwidth == clk->cp->requestedWidth || clk->userWidth) {
--- 340,364 ----
0, 0, cp->width, cp->height);
}
+ FILE *fp1;
+ FILE *fp2;
+ int remainingCapacity = 0;
+ int lastFullCapacity = 0;
+ fp1 = fopen("/sys/class/power_supply/BAT0/energy_now", "r");
+ if(fp1 != NULL) {
+ fscanf(fp1, "%d", &remainingCapacity);
+ fclose(fp1);
+ }
+ fp2 = fopen("/sys/class/power_supply/BAT0/energy_full", "r");
+ if(fp2 != NULL) {
+ fscanf(fp2, "%d", &lastFullCapacity);
+ fclose(fp2);
+ }
+ char *out = NULL;
+ int perc = (lastFullCapacity != 0) ? ((float)remainingCapacity/(float)lastFullCapacity*100) : 0;
+ asprintf(&out, " %d%% %s ", perc, layout);
/* Determine if the clock is the right size. */
! timeString = strcat(out, GetTimeString(clk->format, clk->zone));
width = GetStringWidth(FONT_CLOCK, timeString);
rwidth = width + 4;
if(rwidth == clk->cp->requestedWidth || clk->userWidth) {