Update to version 1.1
This commit is contained in:
parent
9c9d1a22b0
commit
aba739e980
|
@ -1,3 +1,12 @@
|
|||
2018-04-02 Panagiotis A. Dimopoulos <panosdim@gmail.com>
|
||||
|
||||
- Release 1.1
|
||||
- Add a gear icon to show when checking for updates
|
||||
- Right click initiate a check for updates
|
||||
- Left click will open an xterm and start system update
|
||||
- You can now define that check interval with -c or --check-interval
|
||||
command line arguments
|
||||
|
||||
2018-03-29 Panagiotis A. Dimopoulos <panosdim@gmail.com>
|
||||
|
||||
Initial Release 1.0
|
||||
- Initial Release 1.0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CC=gcc
|
||||
INSTALL=install
|
||||
PREFIX=/usr/local
|
||||
CFLAGS+=-Wall `pkg-config --cflags dockapp`
|
||||
CFLAGS+=-Wall -O3 `pkg-config --cflags dockapp`
|
||||
LIBS=`pkg-config --libs dockapp`
|
||||
|
||||
wmarchup: wmarchup.o
|
||||
|
@ -13,6 +13,7 @@ wmarchup.o: wmarchup.c
|
|||
install:
|
||||
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
|
||||
$(INSTALL) wmarchup $(DESTDIR)$(PREFIX)/bin
|
||||
$(INSTALL) arch_update.sh $(DESTDIR)$(PREFIX)/bin
|
||||
|
||||
clean:
|
||||
rm -f wmarchup wmarchup.o
|
||||
|
|
|
@ -17,13 +17,19 @@ managers such as Window Maker, AfterStep, BlackBox, Fluxbox and Enlightenment.
|
|||
This dockapp is quite simple. It contains an Arch Linux logo icon. When there is
|
||||
not package updates then the Arch Linux logo icon is greyed. When there are
|
||||
package updates then the Arch Linux logo icon is blue. The program check for
|
||||
updates every 10 minutes.
|
||||
updates every 10 minutes by default. However you can specify the checking
|
||||
interval by using the -c or --check-interval command line arguments. When the
|
||||
program checks for updates it change its icon in a gear. If you right click the
|
||||
Arch Linux logo icon then it immediately starts a check for updates. If you left
|
||||
click the Arch Linux log the it opens an xterm window and start a system update.
|
||||
|
||||
***************
|
||||
*** OPTIONS ***
|
||||
***************
|
||||
|
||||
This program has no command line options.
|
||||
This program has the following command line options
|
||||
-c <number> : Sets the checking time interval in minutes. Default is 10 minutes.
|
||||
--check-interval <number> : Same as -c
|
||||
|
||||
*********************
|
||||
*** REQUIREMENTS ***
|
||||
|
@ -31,6 +37,7 @@ This program has no command line options.
|
|||
|
||||
This program needs libdockapp library files in order to compile.
|
||||
You can find libdockapp at http://www.dockapps.net/libdockapp
|
||||
Also you need to have xterm installed.
|
||||
|
||||
*******************
|
||||
*** COMPILATION ***
|
||||
|
|
7
wmArchUp/arch_update.sh
Executable file
7
wmArchUp/arch_update.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
statusfile=$(mktemp)
|
||||
xterm -e sh -c 'sudo pacman -Syu; echo $? > '$statusfile
|
||||
status=$(cat $statusfile)
|
||||
rm $statusfile
|
||||
exit $status
|
64
wmArchUp/loading.xpm
Normal file
64
wmArchUp/loading.xpm
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* XPM */
|
||||
static char *loading[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"56 56 2 1 ",
|
||||
" c #FF727D",
|
||||
". c None",
|
||||
/* pixels */
|
||||
"........................................................",
|
||||
"......................... .........................",
|
||||
"........................ ........................",
|
||||
"................. ...... ...... .................",
|
||||
"................ ..... ..... ................",
|
||||
".............. ..... ..... ..............",
|
||||
"............ .... .... ............",
|
||||
"............ .. .. ............",
|
||||
"............. .............",
|
||||
"............. .............",
|
||||
".............. ..............",
|
||||
".............. ..............",
|
||||
"...... ..... ..... ......",
|
||||
"...... .. .. ......",
|
||||
"..... .....",
|
||||
"..... .....",
|
||||
".... ....",
|
||||
"... ........ ...",
|
||||
".... ............ ....",
|
||||
"...... .............. ......",
|
||||
"........ ................ ........",
|
||||
"........ .................. ........",
|
||||
"....... .................... .......",
|
||||
"....... .................... .......",
|
||||
".. ...................... ..",
|
||||
". ...................... .",
|
||||
". ...................... .",
|
||||
". ...................... .",
|
||||
". ...................... .",
|
||||
". ...................... .",
|
||||
". ...................... .",
|
||||
".. ...................... ..",
|
||||
"....... .................... .......",
|
||||
"....... .................... .......",
|
||||
"........ .................. ........",
|
||||
"........ ................ ........",
|
||||
"...... .............. ......",
|
||||
".... ............ ....",
|
||||
"... ........ ...",
|
||||
".... ....",
|
||||
"..... .....",
|
||||
"..... .....",
|
||||
"...... .. .. ......",
|
||||
"...... ..... ..... ......",
|
||||
".............. ..............",
|
||||
".............. ..............",
|
||||
"............. .............",
|
||||
"............. .............",
|
||||
"............ .. .. ............",
|
||||
"............ .... .... ............",
|
||||
".............. ..... ..... ..............",
|
||||
"................ ..... ..... ................",
|
||||
"................. ...... ...... .................",
|
||||
"........................ ........................",
|
||||
"......................... .........................",
|
||||
"........................................................"
|
||||
};
|
|
@ -1,36 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Alban G. Hertroys
|
||||
*
|
||||
* Basic example of libDockapp usage
|
||||
*
|
||||
* This dockapp will draw a rectangle with a
|
||||
* bouncing ball in it.
|
||||
*/
|
||||
|
||||
/* also includes Xlib, Xresources, XPM, stdlib and stdio */
|
||||
/* Also includes Xlib, Xresources, XPM, stdlib and stdio */
|
||||
#include <dockapp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* include the pixmap to use */
|
||||
/* Include the pixmap to use */
|
||||
#include "archlinux.xpm"
|
||||
#include "archlinux_bw.xpm"
|
||||
#include "loading.xpm"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define MAX 256
|
||||
#define CHK_INTERVAL 600
|
||||
#define WMARCHUP_VER "1.1"
|
||||
#define VERSION "wmArchUp version " WMARCHUP_VER
|
||||
|
||||
/*
|
||||
* Prototypes for local functions
|
||||
*/
|
||||
void destroy(void);
|
||||
int check_for_updates();
|
||||
void check_for_updates();
|
||||
void buttonrelease(int button, int state, int x, int y);
|
||||
void update();
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
Pixmap arch, arch_mask, arch_bw, arch_bw_mask;
|
||||
Pixmap arch, arch_mask, arch_bw, arch_bw_mask, checking, checking_mask;
|
||||
unsigned short height, width;
|
||||
XEvent ev;
|
||||
unsigned int check_interval = CHK_INTERVAL;
|
||||
int updates_available = FALSE;
|
||||
|
||||
/*
|
||||
* M A I N
|
||||
|
@ -39,27 +37,43 @@ XEvent ev;
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/* Set callbacks for events */
|
||||
DACallbacks eventCallbacks = {
|
||||
destroy, /* destroy */
|
||||
NULL, /* buttonPress */
|
||||
NULL, /* buttonRelease */
|
||||
&buttonrelease, /* buttonRelease */
|
||||
NULL, /* motion (mouse) */
|
||||
NULL, /* mouse enters window */
|
||||
NULL, /* mouse leaves window */
|
||||
NULL /* timeout */
|
||||
check_for_updates /* timeout */
|
||||
};
|
||||
|
||||
int interval = 0;
|
||||
|
||||
/* Set program options */
|
||||
DAProgramOption options[] = {
|
||||
{
|
||||
"-c",
|
||||
"--check-interval",
|
||||
"Check interval in minutes. Default 10 minutes.",
|
||||
DONatural,
|
||||
False,
|
||||
{&interval}
|
||||
},
|
||||
};
|
||||
|
||||
/* provide standard command-line options */
|
||||
DAParseArguments(
|
||||
argc, argv, /* Where the options come from */
|
||||
NULL, 0, /* Our list with options - none as you can see */
|
||||
options, 1, /* Our list with options */
|
||||
"This is dockapp watch for available updates "
|
||||
"in Arch Linux packages.\n",
|
||||
"wmarchup version 1.0");
|
||||
VERSION);
|
||||
|
||||
/* Tell libdockapp what version we expect it to be (a date from
|
||||
* NEWS should do).
|
||||
*/
|
||||
/* Set the check interval */
|
||||
check_interval = interval ? (interval * 60) : CHK_INTERVAL;
|
||||
|
||||
/* Check if correct libdockapp version exists in system */
|
||||
DASetExpectedVersion(20050716);
|
||||
|
||||
DAInitialize("", "WMArchUp", 56, 56, argc, argv);
|
||||
|
@ -78,50 +92,80 @@ main(int argc, char **argv)
|
|||
&height,
|
||||
&width);
|
||||
|
||||
DASetShape(arch_bw_mask);
|
||||
DASetPixmap(arch_bw);
|
||||
DAMakePixmapFromData(
|
||||
loading,
|
||||
&checking,
|
||||
&checking_mask,
|
||||
&height,
|
||||
&width);
|
||||
|
||||
/* Respond to destroy and timeout events (the ones not NULL in the
|
||||
* eventCallbacks variable.
|
||||
*/
|
||||
DASetCallbacks(&eventCallbacks);
|
||||
|
||||
DAShow(); /* Show the dockapp window. */
|
||||
/* Set timeout in msec */
|
||||
DASetTimeout(check_interval * 1000);
|
||||
|
||||
while (1) {
|
||||
if (check_for_updates() == TRUE) {
|
||||
DASetShape(arch_mask);
|
||||
DASetPixmap(arch);
|
||||
} else {
|
||||
DASetShape(arch_bw_mask);
|
||||
DASetPixmap(arch_bw);
|
||||
}
|
||||
/* Show the dockapp window. */
|
||||
DAShow();
|
||||
|
||||
/* handle all pending X events */
|
||||
while (XPending(DADisplay)) {
|
||||
XNextEvent(DADisplay, &ev);
|
||||
DAProcessEvent(&ev);
|
||||
}
|
||||
sleep(600);
|
||||
}
|
||||
/* Check for updates at the begining */
|
||||
check_for_updates();
|
||||
|
||||
/* Loop for events */
|
||||
DAEventLoop();
|
||||
|
||||
/* not reached */
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
int
|
||||
check_for_updates() {
|
||||
void
|
||||
update()
|
||||
{
|
||||
if (updates_available == TRUE) {
|
||||
XSelectInput(DAGetDisplay(NULL), DAGetWindow(), NoEventMask);
|
||||
|
||||
char *update_script = "./arch_update.sh";
|
||||
int ret = system(update_script);
|
||||
|
||||
if (WEXITSTATUS(ret) == 0) {
|
||||
updates_available = FALSE;
|
||||
DASetShape(arch_bw_mask);
|
||||
DASetPixmap(arch_bw);
|
||||
}
|
||||
|
||||
XSelectInput(DAGetDisplay(NULL), DAGetWindow(),
|
||||
ButtonPressMask | ButtonReleaseMask);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
check_for_updates()
|
||||
{
|
||||
XSelectInput(DAGetDisplay(NULL), DAGetWindow(), NoEventMask);
|
||||
FILE *fp;
|
||||
char res[MAX];
|
||||
|
||||
|
||||
DASetShape(checking_mask);
|
||||
DASetPixmap(checking);
|
||||
|
||||
/* Read output from command */
|
||||
fp = popen("checkupdates", "r");
|
||||
if (fgets(res, MAX, fp) != NULL) {
|
||||
fclose(fp);
|
||||
return TRUE;
|
||||
updates_available = TRUE;
|
||||
DASetShape(arch_mask);
|
||||
DASetPixmap(arch);
|
||||
} else {
|
||||
return FALSE;
|
||||
updates_available = FALSE;
|
||||
DASetShape(arch_bw_mask);
|
||||
DASetPixmap(arch_bw);
|
||||
}
|
||||
|
||||
XSelectInput(DAGetDisplay(NULL), DAGetWindow(),
|
||||
ButtonPressMask | ButtonReleaseMask);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -129,3 +173,15 @@ destroy(void)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* A mouse button was pressed and released.
|
||||
* See if it was button 1 left click or button 3 right click. */
|
||||
void
|
||||
buttonrelease(int button, int state, int x, int y)
|
||||
{
|
||||
if (button == 1) {
|
||||
update();
|
||||
} else if (button == 3) {
|
||||
check_for_updates();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue