mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 04:06:03 +00:00
sticky hints
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@548 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
8ad961d96f
commit
ac23be3d25
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
2006-03-06
|
2006-03-06
|
||||||
* Fixed battery problems when charged
|
* Fixed battery problems when charged
|
||||||
|
* MPD code handles broken pipe now, instead of just killing conky
|
||||||
|
|
||||||
2006-03-05
|
2006-03-05
|
||||||
* Added patch to make $cpu stuff work on alpha (thanks Thomas Cort)
|
* Added patch to make $cpu stuff work on alpha (thanks Thomas Cort)
|
||||||
|
@ -836,6 +836,15 @@
|
|||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command><option>mpd_smart<option></command>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
Prints the song name in either the form "artist - title" or file name, depending on whats available
|
||||||
|
<para></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command><option>new_mails</option></command>
|
<command><option>new_mails</option></command>
|
||||||
|
30
src/conky.c
30
src/conky.c
@ -890,6 +890,7 @@ enum text_object_type {
|
|||||||
OBJ_mpd_name,
|
OBJ_mpd_name,
|
||||||
OBJ_mpd_file,
|
OBJ_mpd_file,
|
||||||
OBJ_mpd_percent,
|
OBJ_mpd_percent,
|
||||||
|
OBJ_mpd_smart,
|
||||||
#endif
|
#endif
|
||||||
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
|
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
|
||||||
OBJ_xmms_status,
|
OBJ_xmms_status,
|
||||||
@ -1182,6 +1183,20 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
|
|||||||
info.mpd.status = 0;
|
info.mpd.status = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case OBJ_mpd_smart:
|
||||||
|
if (info.mpd.artist) {
|
||||||
|
free(info.mpd.artist);
|
||||||
|
info.mpd.artist = 0;
|
||||||
|
}
|
||||||
|
if (info.mpd.title) {
|
||||||
|
free(info.mpd.title);
|
||||||
|
info.mpd.title = 0;
|
||||||
|
}
|
||||||
|
if (info.mpd.file) {
|
||||||
|
free(info.mpd.file);
|
||||||
|
info.mpd.file = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case OBJ_mpd_host:
|
case OBJ_mpd_host:
|
||||||
#endif
|
#endif
|
||||||
#ifdef BMPX
|
#ifdef BMPX
|
||||||
@ -1891,13 +1906,13 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
|||||||
END OBJ(mpd_name, INFO_MPD)
|
END OBJ(mpd_name, INFO_MPD)
|
||||||
END OBJ(mpd_file, INFO_MPD)
|
END OBJ(mpd_file, INFO_MPD)
|
||||||
END OBJ(mpd_percent, INFO_MPD)
|
END OBJ(mpd_percent, INFO_MPD)
|
||||||
END OBJ(mpd_album, INFO_MPD) END OBJ(mpd_vol,
|
END OBJ(mpd_album, INFO_MPD)
|
||||||
INFO_MPD) END OBJ(mpd_bitrate,
|
END OBJ(mpd_vol, INFO_MPD)
|
||||||
INFO_MPD)
|
END OBJ(mpd_bitrate, INFO_MPD)
|
||||||
END OBJ(mpd_status, INFO_MPD)
|
END OBJ(mpd_status, INFO_MPD)
|
||||||
END OBJ(mpd_bar, INFO_MPD)
|
END OBJ(mpd_bar, INFO_MPD)
|
||||||
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
|
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
|
||||||
END
|
END OBJ(mpd_smart, INFO_MPD) END
|
||||||
#endif
|
#endif
|
||||||
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
|
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
|
||||||
OBJ(xmms_status, INFO_XMMS) END
|
OBJ(xmms_status, INFO_XMMS) END
|
||||||
@ -3186,6 +3201,13 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
|||||||
(int) (cur->mpd.progress *
|
(int) (cur->mpd.progress *
|
||||||
255.0f));
|
255.0f));
|
||||||
}
|
}
|
||||||
|
OBJ(mpd_smart) {
|
||||||
|
if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.title) < 2) {
|
||||||
|
snprintf(p, p_max_size, "%s", cur->mpd.file);
|
||||||
|
} else {
|
||||||
|
snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
|
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
|
||||||
OBJ(xmms_status) {
|
OBJ(xmms_status) {
|
||||||
|
@ -297,7 +297,7 @@ char tmpstring2[TEXT_BUFFER_SIZE];
|
|||||||
#include <X11/extensions/Xdbe.h>
|
#include <X11/extensions/Xdbe.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ATOM(a) XInternAtom(display, #a, False)
|
#define ATOM(a) XInternAtom(display, #a, True)
|
||||||
|
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
enum _window_hints {
|
enum _window_hints {
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
|
||||||
#ifndef MPD_NO_IPV6
|
#ifndef MPD_NO_IPV6
|
||||||
#ifdef AF_INET6
|
#ifdef AF_INET6
|
||||||
@ -52,6 +53,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static char sigpipe = 0;
|
||||||
|
|
||||||
#define COMMAND_LIST 1
|
#define COMMAND_LIST 1
|
||||||
#define COMMAND_LIST_OK 2
|
#define COMMAND_LIST_OK 2
|
||||||
|
|
||||||
@ -136,6 +139,8 @@ mpd_Connection *mpd_newConnection(const char *host, int port,
|
|||||||
mpd_Connection *connection = malloc(sizeof(mpd_Connection));
|
mpd_Connection *connection = malloc(sizeof(mpd_Connection));
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
struct sigaction sapipe; /* definition of signal action */
|
||||||
|
|
||||||
#ifdef MPD_HAVE_IPV6
|
#ifdef MPD_HAVE_IPV6
|
||||||
struct sockaddr_in6 sin6;
|
struct sockaddr_in6 sin6;
|
||||||
#endif
|
#endif
|
||||||
@ -149,6 +154,7 @@ mpd_Connection *mpd_newConnection(const char *host, int port,
|
|||||||
connection->listOks = 0;
|
connection->listOks = 0;
|
||||||
connection->doneListOk = 0;
|
connection->doneListOk = 0;
|
||||||
connection->returnElement = NULL;
|
connection->returnElement = NULL;
|
||||||
|
sigpipe = 0;
|
||||||
|
|
||||||
if (!(he = gethostbyname(host))) {
|
if (!(he = gethostbyname(host))) {
|
||||||
snprintf(connection->errorStr, MPD_BUFFER_MAX_LENGTH,
|
snprintf(connection->errorStr, MPD_BUFFER_MAX_LENGTH,
|
||||||
@ -205,6 +211,13 @@ mpd_Connection *mpd_newConnection(const char *host, int port,
|
|||||||
|
|
||||||
mpd_setConnectionTimeout(connection, timeout);
|
mpd_setConnectionTimeout(connection, timeout);
|
||||||
|
|
||||||
|
/* install the signal handler */
|
||||||
|
sapipe.sa_handler = mpd_signalHandler;
|
||||||
|
// sapipe.sa_mask = 0;
|
||||||
|
sapipe.sa_flags = 0;
|
||||||
|
sapipe.sa_restorer = NULL;
|
||||||
|
sigaction(SIGPIPE,&sapipe,NULL);
|
||||||
|
|
||||||
/* connect stuff */
|
/* connect stuff */
|
||||||
{
|
{
|
||||||
int flags = fcntl(connection->sock, F_GETFL, 0);
|
int flags = fcntl(connection->sock, F_GETFL, 0);
|
||||||
@ -367,29 +380,34 @@ void mpd_executeCommand(mpd_Connection * connection, char *command)
|
|||||||
tv.tv_sec = connection->timeout.tv_sec;
|
tv.tv_sec = connection->timeout.tv_sec;
|
||||||
tv.tv_usec = connection->timeout.tv_usec;
|
tv.tv_usec = connection->timeout.tv_usec;
|
||||||
|
|
||||||
while ((ret =
|
if (sigpipe) {
|
||||||
select(connection->sock + 1, NULL, &fds, NULL, &tv) == 1)
|
perror("");
|
||||||
|| (ret == -1 && errno == EINTR)) {
|
snprintf(connection->errorStr, MPD_BUFFER_MAX_LENGTH, "got SIGINT");
|
||||||
ret =
|
connection->error = MPD_ERROR_SENDING;
|
||||||
send(connection->sock, commandPtr, commandLen,
|
return;
|
||||||
MSG_DONTWAIT);
|
}
|
||||||
|
while ((ret = select(connection->sock + 1, NULL, &fds, NULL, &tv) == 1) || (ret == -1 && errno == EINTR)) {
|
||||||
|
if (sigpipe) {
|
||||||
|
perror("");
|
||||||
|
snprintf(connection->errorStr, MPD_BUFFER_MAX_LENGTH, "got SIGINT");
|
||||||
|
connection->error = MPD_ERROR_SENDING;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
ret = send(connection->sock, commandPtr, commandLen, MSG_DONTWAIT);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
if (ret == EAGAIN || ret == EINTR)
|
if (ret == EAGAIN || ret == EINTR)
|
||||||
continue;
|
continue;
|
||||||
snprintf(connection->errorStr,
|
snprintf(connection->errorStr, MPD_BUFFER_MAX_LENGTH, "problems giving command \"%s\"", command);
|
||||||
MPD_BUFFER_MAX_LENGTH,
|
|
||||||
"problems giving command \"%s\"",
|
|
||||||
command);
|
|
||||||
connection->error = MPD_ERROR_SENDING;
|
connection->error = MPD_ERROR_SENDING;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
commandPtr += ret;
|
commandPtr += ret;
|
||||||
commandLen -= ret;
|
commandLen -= ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandLen <= 0)
|
if (commandLen <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (commandLen > 0) {
|
if (commandLen > 0) {
|
||||||
perror("");
|
perror("");
|
||||||
@ -1515,3 +1533,12 @@ void mpd_sendCommandListEnd(mpd_Connection * connection)
|
|||||||
connection->commandList = 0;
|
connection->commandList = 0;
|
||||||
mpd_executeCommand(connection, "command_list_end\n");
|
mpd_executeCommand(connection, "command_list_end\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mpd_signalHandler(int signal)
|
||||||
|
{
|
||||||
|
if (signal == SIGPIPE) {
|
||||||
|
fprintf(stderr, "Conky: recieved SIGPIPE from MPD connection\n");
|
||||||
|
sigpipe = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -503,6 +503,9 @@ extern "C" {
|
|||||||
* returns -1 if it advanced to an OK or ACK */
|
* returns -1 if it advanced to an OK or ACK */
|
||||||
int mpd_nextListOkCommand(mpd_Connection * connection);
|
int mpd_nextListOkCommand(mpd_Connection * connection);
|
||||||
|
|
||||||
|
/* handles SIGPIPE from full close on the server side */
|
||||||
|
void mpd_signalHandler(int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
10
src/linux.c
10
src/linux.c
@ -1186,14 +1186,12 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat)
|
|||||||
/* charged */
|
/* charged */
|
||||||
/* thanks to Lukas Zapletal <lzap@seznam.cz> */
|
/* thanks to Lukas Zapletal <lzap@seznam.cz> */
|
||||||
else if (strcmp(charging_state, "charged") == 0) {
|
else if (strcmp(charging_state, "charged") == 0) {
|
||||||
if (acpi_last_full != 0
|
if (acpi_last_full != 0 && remaining_capacity != acpi_last_full) {
|
||||||
&& remaining_capacity != acpi_last_full)
|
sprintf(last_battery_str, "charged %d%%", remaining_capacity * 100 / design_capacity);
|
||||||
sprintf(last_battery_str, "charged %d%%",
|
} else {
|
||||||
remaining_capacity * 100 /
|
|
||||||
design_capacity);
|
|
||||||
else
|
|
||||||
strcpy(last_battery_str, "charged");
|
strcpy(last_battery_str, "charged");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* unknown, probably full / AC */
|
/* unknown, probably full / AC */
|
||||||
else {
|
else {
|
||||||
if (acpi_last_full != 0
|
if (acpi_last_full != 0
|
||||||
|
@ -312,11 +312,11 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
|
|||||||
if (TEST_HINT(window.hints,HINT_STICKY)) {
|
if (TEST_HINT(window.hints,HINT_STICKY)) {
|
||||||
fprintf(stderr, "Conky: hint - sticky\n"); fflush(stderr);
|
fprintf(stderr, "Conky: hint - sticky\n"); fflush(stderr);
|
||||||
|
|
||||||
xa = ATOM(_NET_WM_STATE);
|
xa = ATOM(_NET_WM_DESKTOP);
|
||||||
if (xa != None) {
|
if (xa != None) {
|
||||||
Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
|
uint32_t xa_prop = UINT32_MAX;
|
||||||
XChangeProperty(display, window.window, xa,
|
XChangeProperty(display, window.window, xa,
|
||||||
XA_ATOM, 32,
|
XA_CARDINAL, 32,
|
||||||
PropModeAppend,
|
PropModeAppend,
|
||||||
(unsigned char *) &xa_prop,
|
(unsigned char *) &xa_prop,
|
||||||
1);
|
1);
|
||||||
|
Loading…
Reference in New Issue
Block a user