mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-22 19:45:54 -04:00
Simple output of idle/away
This commit is contained in:
parent
846d3f848a
commit
020e516acf
@ -47,6 +47,10 @@ AC_CHECK_LIB([notify], [main], [],
|
|||||||
[AC_MSG_NOTICE([libnotify not found, desktop notifications not supported])])
|
[AC_MSG_NOTICE([libnotify not found, desktop notifications not supported])])
|
||||||
AC_CHECK_LIB([headunit], [main], [],
|
AC_CHECK_LIB([headunit], [main], [],
|
||||||
[AC_MSG_NOTICE([headunit not found, will not be able to run tests])])
|
[AC_MSG_NOTICE([headunit not found, will not be able to run tests])])
|
||||||
|
AC_CHECK_LIB([Xss], [main], [],
|
||||||
|
[AC_MSG_NOTICE([libxss not found, falling back to profanity auto-away])])
|
||||||
|
AC_CHECK_LIB([X11], [main], [],
|
||||||
|
[AC_MSG_NOTICE([libX11 not found, falling back to profanity auto-away])])
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_CHECK_HEADERS([stdlib.h string.h])
|
AC_CHECK_HEADERS([stdlib.h string.h])
|
||||||
|
@ -46,9 +46,13 @@
|
|||||||
|
|
||||||
static log_level_t _get_log_level(char *log_level);
|
static log_level_t _get_log_level(char *log_level);
|
||||||
static gboolean _process_input(char *inp);
|
static gboolean _process_input(char *inp);
|
||||||
|
static void _handle_idle_time(void);
|
||||||
static void _init(const int disable_tls, char *log_level);
|
static void _init(const int disable_tls, char *log_level);
|
||||||
static void _shutdown(void);
|
static void _shutdown(void);
|
||||||
|
|
||||||
|
static gboolean idle = FALSE;
|
||||||
|
static gboolean away = FALSE;
|
||||||
|
|
||||||
void
|
void
|
||||||
prof_run(const int disable_tls, char *log_level)
|
prof_run(const int disable_tls, char *log_level)
|
||||||
{
|
{
|
||||||
@ -67,6 +71,8 @@ prof_run(const int disable_tls, char *log_level)
|
|||||||
|
|
||||||
while(ch != '\n') {
|
while(ch != '\n') {
|
||||||
|
|
||||||
|
_handle_idle_time();
|
||||||
|
|
||||||
gdouble elapsed = g_timer_elapsed(timer, NULL);
|
gdouble elapsed = g_timer_elapsed(timer, NULL);
|
||||||
|
|
||||||
gint remind_period = prefs_get_notify_remind();
|
gint remind_period = prefs_get_notify_remind();
|
||||||
@ -434,6 +440,28 @@ _process_input(char *inp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_idle_time()
|
||||||
|
{
|
||||||
|
unsigned long idle_ms = ui_get_desktop_idle();
|
||||||
|
if (!idle) {
|
||||||
|
if (idle_ms >= 5000) {
|
||||||
|
idle = TRUE;
|
||||||
|
cons_show("IDLE");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (idle_ms < 5000) {
|
||||||
|
idle = FALSE;
|
||||||
|
away = FALSE;
|
||||||
|
cons_show("BACK");
|
||||||
|
} else if ((idle_ms >= 10000) && (!away)) {
|
||||||
|
away = TRUE;
|
||||||
|
cons_show("AWAY");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_init(const int disable_tls, char *log_level)
|
_init(const int disable_tls, char *log_level)
|
||||||
{
|
{
|
||||||
|
3
src/ui.h
3
src/ui.h
@ -76,6 +76,9 @@ void ui_disconnected(void);
|
|||||||
void ui_handle_special_keys(const int * const ch);
|
void ui_handle_special_keys(const int * const ch);
|
||||||
void ui_switch_win(const int i);
|
void ui_switch_win(const int i);
|
||||||
gboolean ui_windows_full(void);
|
gboolean ui_windows_full(void);
|
||||||
|
#ifdef HAVE_LIBXSS
|
||||||
|
unsigned long ui_get_desktop_idle(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
// create windows
|
// create windows
|
||||||
void create_title_bar(void);
|
void create_title_bar(void);
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXSS
|
||||||
|
#include <X11/extensions/scrnsaver.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
#include <libnotify/notify.h>
|
#include <libnotify/notify.h>
|
||||||
@ -66,6 +70,10 @@ static int dirty;
|
|||||||
// max columns for main windows, never resize below
|
// max columns for main windows, never resize below
|
||||||
static int max_cols = 0;
|
static int max_cols = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXSS
|
||||||
|
static Display *display;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void _set_current(int index);
|
static void _set_current(int index);
|
||||||
static void _create_windows(void);
|
static void _create_windows(void);
|
||||||
static void _cons_splash_logo(void);
|
static void _cons_splash_logo(void);
|
||||||
@ -116,7 +124,9 @@ ui_init(void)
|
|||||||
status_bar_active(0);
|
status_bar_active(0);
|
||||||
create_input_window();
|
create_input_window();
|
||||||
_create_windows();
|
_create_windows();
|
||||||
|
#ifdef HAVE_LIBXSS
|
||||||
|
display = XOpenDisplay(0);
|
||||||
|
#endif
|
||||||
dirty = TRUE;
|
dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +171,19 @@ ui_refresh(void)
|
|||||||
inp_put_back();
|
inp_put_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXSS
|
||||||
|
unsigned long
|
||||||
|
ui_get_desktop_idle(void)
|
||||||
|
{
|
||||||
|
XScreenSaverInfo *info = XScreenSaverAllocInfo();
|
||||||
|
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
|
||||||
|
unsigned long result = info->idle;
|
||||||
|
XFree(info);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_close(void)
|
ui_close(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user