First commit of lfsdock

This commit is contained in:
K D Hedger
2023-11-15 13:30:02 +00:00
parent c6d4945341
commit f4e3feaeb5
21 changed files with 1530 additions and 0 deletions

2
LFSDock/ChangeLog Normal file
View File

@ -0,0 +1,2 @@
0.1.0
First commit of lfsdock.

View File

@ -0,0 +1,14 @@
AUTOMAKE_OPTIONS = subdir-objects
include ../flagsandlibs
include ../sources
lfsdock_SOURCES = $(COMMONSRC)
man1_MANS = ../resources/man/lfsdock.1
#pixfilesdir = $(pkgdatadir)/pixmaps
#pixfiles_DATA = ../resources/pixmaps/*
bin_PROGRAMS = lfsdock

View File

@ -0,0 +1,23 @@
AM_CPPFLAGS = -I$(top_srcdir) \
$(ALSA_CFLAGS) \
$(X11_CFLAGS) \
$(XFT_CFLAGS) \
$(LIBGLIB_CFLAGS) \
$(CAIRO_CFLAGS) \
$(LFSTK_CFLAGS) \
$(LIBGLIB_CFLAGS) \
-DPREFIX=\""${prefix}\"" \
-DDATADIR=\""${pkgdatadir}"\" \
-DSYSCONFDIR=\""${sysconfdir}/${PACKAGE}"\" \
-DLIBDIR=\""${libdir}/${PACKAGE}"\"
LIBS = $(X11_LIBS) \
$(ALSA_LIBS) \
$(XFT_LIBS) \
$(LIBGLIB_LIBS) \
$(CAIRO_LIBS) \
$(LFSTK_LIBS) \
$(LIBGLIB_LIBS) \
-lm

View File

@ -0,0 +1,94 @@
.TH "lfspanel" "1" "0.0.5" "K.D.Hedger" "User Commands"
.SH "NAME"
\fBlfspanel\fR - Manual page for lfspanel.
.br
.SH "SYNOPSIS"
\fBlfspanel\fR PANELID
.br
.SH "DESCRIPTION"
Part of the LFS Desktop project here:
.br
http://www.linuxquestions.org/questions/linux-from-scratch-13/the-linux-from-scratch-desktop-project-4175542914
.br
This provides basic panel functionality, logout, shutdown, app menu, window menu etc etc.
.br
.SH "EXAMPLES"
Start new main panel using config file ~/.config/LFS/lfspanel.rc
.br
lfspanel
.br
Start new panel using config file ~/.config/LFS/lfspanel-0.rc
.br
lfspanel 0
.br
Start new panel using config file ~/.config/LFS/lfspanel-DEV.rc
.br
lfspanel DEV
.br
.SH "FILES"
Sample rc file:
.br
panelheight 16
.br
panelwidth -1
.br
panelpos -2
.br
panelgrav 4
.br
onmonitor 0
.br
termcommand xfce4-terminal -x
.br
logoutcommand kill -9 $(cat /tmp/lfssession.pid)
.br
restartcommand sudo reboot
.br
shutdowncommand sudo shutdown -h now
.br
gadgetsright MDCL
.br
gadgetsleft AWSS
.br
panelheight - Height of panel.
.br
panelwidth - Can be -1 for full width of monitor, -2 shrink to fit or >0 for absolute size.
.br
panelpos - Can be -1 for left position, -2 for centre position, -3 for right position or >=0 for absolute position.
.br
panelgrav - Canbe 1 for top of monitor, 2 for right of monitor, 3 for bottom of monitor, 4 for left of monitor.
.br
onmonitor - Monitor for this panel.
.br
termcommand - Command to use when launching app in terminal, defaults to "xterm -e".
.br
logoutcommand
.br
restartcommand
.br
shutdowncommand - Set to your prefs.
.br
gadgetsright
.br
gadgetsleft - Position of gadgets in panel in order L=logout menu, C=clock, D=disk usage, M=cpu load, A=applications menu, W=all window's selector, w=windows on current desktop selector, S=spacer, l=launchers.
.br
When using the 'l' widget all .desktop files in the folder ~/.config/LFS/launchers-XXX will be added to the panel, where XXX is the panel ID, the same as the prefs file, see the examples section.
.br
For an empty gadget string for gadgetsright/gadgetsleft use "", else "'s are not needed. Only one gadget of each type is allowed except for spacers which can be used multiple times.
.br
Clock, disk usage and CPU usage are not allowed on left/right panels.
.br
.SH "REPORTING BUGS"
Report bugs to keithdhedger@gmail.com
.br

1
LFSDock/LFSDock/sources Normal file
View File

@ -0,0 +1 @@
COMMONSRC = ../src/appmenu.cpp ../src/callbacks.cpp ../src/clock.cpp ../src/cpu.cpp ../src/disks.cpp ../src/globals.cpp ../src/launchers.cpp ../src/logout.cpp ../src/main.cpp ../src/slider.cpp ../src/windowlist.cpp

View File

@ -0,0 +1,117 @@
/*
*
* ©K. D. Hedger. Sat 6 Feb 13:59:35 GMT 2021 keithdhedger@gmail.com
* This file (callbacks.cpp) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#include "globals.h"
bool launcherCB(void *p,void* ud)
{
launcherList *launcher=(launcherList*)ud;
char *command;
if(launcher==NULL)
return(true);
if(launcher->entry.inTerm==false)
asprintf(&command,"%s &",launcher->entry.exec);
else
asprintf(&command,"%s %s &",prefs.LFSTK_getCString("termcommand"),launcher->entry.exec);
sendNotify("Launching ",launcher->entry.name);
#ifdef _ENABLEDEBUG_
DEBUGFUNC("%s",command);
#else
system(command);
#endif
free(command);
return(true);
}
bool gadgetDrop(void *lwc,propertyStruct *data,void* ud)
{
launcherList *launcher=(launcherList*)ud;
char *command=NULL;
if(data!=NULL)
{
if(strcasecmp(data->mimeType,"text/uri-list")==0)
{
dropDesktopFile((const char*)data->data,launcher);
return(true);
}
if(strcasecmp(data->mimeType,"text/plain")==0)
{
std::istringstream stream((const char*)data->data);
std::string line;
while(std::getline(stream,line))
{
if(launcher->entry.inTerm==false)
asprintf(&command,"%s \"%s\" &",launcher->entry.exec,line.c_str());
else
asprintf(&command,"%s %s \"%s\" &",prefs.LFSTK_getCString("termcommand"),launcher->entry.exec,line.c_str());
sendNotify(launcher->entry.name,line.c_str());
system(command);
free(command);
}
}
}
return(true);
}
bool timerCB(LFSTK_applicationClass *p,void* ud)
{
Window sink;
Window childwindow;
int sinkx;
int sinky;
unsigned int buttonmask;
XQueryPointer(apc->display,apc->rootWindow,&sink,&childwindow,&sinkx,&sinky,&sinkx,&sinky,&buttonmask);
if(buttonmask!=0)
return(true);
readMsg();
if(clockButton!=NULL)
updateClock();
if(scwindow!=NULL)
updateSlider();
return(true);
}
#define DOCK_MSG 2000
void readMsg(void)
{
int retcode;
buffer.mText[0]=0;
retcode=msgrcv(queueID,&buffer,MAX_MSG_SIZE,DOCK_MSG,IPC_NOWAIT);
if(strcmp(buffer.mText,"quitdock")==0)
{
apc->mainLoop=false;
realMainLoop=false;
}
buffer.mText[0]=0;
}

View File

@ -0,0 +1,29 @@
/*
*
* ©K. D. Hedger. Sat 6 Feb 13:59:29 GMT 2021 keithdhedger@gmail.com
* This file (callbacks.h) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CALLBACKS_
#define _CALLBACKS_
bool launcherCB(void *p,void* ud);
bool gadgetDrop(void *lwc,propertyStruct *data,void* ud);
bool timerCB(LFSTK_applicationClass *p,void* ud);
void readMsg(void);
#endif

View File

@ -0,0 +1,69 @@
/*
*
* ©K. D. Hedger. Mon 21 Sep 13:41:36 BST 2015 keithdhedger@gmail.com
* This file (clock.cpp) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <signal.h>
#include <ctime>
#include "globals.h"
LFSTK_labelClass *clockButton=NULL;
void updateClock(void)
{
char clockbuffer[256];
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);
timeinfo=localtime(&rawtime);
strftime(clockbuffer,255,"%I:%M:%S",timeinfo);
clockButton->LFSTK_setLabel(clockbuffer);
}
int addClock(int x,int y,int grav)
{
int xpos=0;
int width=BWIDTH;
int retval=width;
if((panelGravity==PANELEAST) || (panelGravity==PANELWEST))
{
printError("Clock not allowed with this panel's orientation.");
return(0);
}
if(clockButton!=NULL)
{
printError("Duplicate clock");
return(0);
}
if(grav==NorthWestGravity)
xpos=x;
else
xpos=x-width;
clockButton=new LFSTK_labelClass(mainwind,"--:--:--",xpos,0,width,panelHeight,CENTRE,grav);
setGadgetDetails(clockButton);
return(retval);
}

View File

@ -0,0 +1,30 @@
/*
*
* ©K. D. Hedger. Mon 21 Sep 13:41:31 BST 2015 keithdhedger@gmail.com
* This file (clock.h) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CLOCK_
#define _CLOCK_
extern LFSTK_labelClass *clockButton;
int addClock(int x,int y,int grav);
void updateClock(void);
#endif

View File

@ -0,0 +1,175 @@
/*
*
* ©K. D. Hedger. Sun 20 Sep 14:41:10 BST 2015 keithdhedger@gmail.com
* This file (globals.cpp) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#include "globals.h"
//prefs
LFSTK_prefsClass prefs;
/*
{prefs.LFSTK_hashFromKey("usetheme"),{TYPEBOOL,"usetheme","",useTheme->LFSTK_getValue(),0}},
{prefs.LFSTK_hashFromKey("panelcolour"),{TYPESTRING,"panelcolour",panelColourEdit->LFSTK_getCStr(),false,0}},
*/
int panelHeight=16;
int panelWidth=-1;
const monitorStruct *mons=NULL;
int onMonitor=0;
int panelPos=PANELCENTRE;
int panelGravity=PANELNORTH;
bool useTheme=true;
const char *panelColour="";
const char *panelTextColour="";
bool noButtons=false;
int queueID;
msgBuffer buffer;
const char *desktopTheme=NULL;
// char *panelID="";
bool realMainLoop=true;
int refreshRate=1;
int iconSize=16;
//panel window
LFSTK_applicationClass *apc=NULL;
LFSTK_windowClass *mainwind=NULL;
int rightOffset=0;
int leftOffset=0;
int launcherSide=NOLAUNCHERS;
//atoms
Atom WM_STATE=None;
Atom NET_WM_WINDOW_TYPE_NORMAL=None;
Atom NET_WM_STATE_HIDDEN=None;
Atom NET_WM_WINDOW_TYPE_DIALOG=None;
Atom NET_WM_DESKTOP=None;
Atom NET_WM_WINDOW_TYPE=None;
Atom NET_WM_STATE=None;
Atom NET_WM_NAME=None;
Atom UTF8_STRING=None;
const char *possibleError="Unknown";
void setSizes(int *x,int *y,int *w,int *h,int *size,int *grav,bool fromleft)
{
*w=panelHeight;
*h=panelHeight;
*size=(*w)-12;
switch(*grav)
{
case PANELNORTH:
case PANELSOUTH:
if(fromleft==true)
{
*grav=NorthWestGravity;
*x=*x;
}
else
{
*grav=NorthEastGravity;
*x=*x-*w+1;
}
*y=0;
break;
case PANELEAST:
case PANELWEST:
if(fromleft==true)
{
*grav=NorthWestGravity;
*y=*x;
}
else
{
*grav=SouthWestGravity;
*y=*x-*h+1;
}
*x=0;
break;
}
}
void sendNotify(const char *name,const char *message)//TODO//could be better
{
#ifdef _GOTNOTIFYSEND_
char *command;
asprintf(&command,"notify-send -u low -t 2000 -i stock_dialog-info \"%s\" \"%s ...\" &",name,message);
system(command);
free(command);
#endif
}
void dropDesktopFile(const char *data,launcherList *launcher)
{
char *cleanstr;
char *command=NULL;
char *ptr;
std::istringstream stream(data);
std::string line;
while(std::getline(stream,line))
{
cleanstr=apc->globalLib->LFSTK_cleanString((const char*)line.c_str());
if((strrchr(cleanstr,'.')!=NULL) && (strcmp(strrchr(cleanstr,'.'),".desktop")==0))
{
asprintf(&command,"mkdir -p '%s/launchers-DOCK';cp -nP '%s' '%s/launchers-DOCK'",apc->configDir,cleanstr,apc->configDir);
ptr=strrchr(cleanstr,'/');
sendNotify("Adding launcher ",++ptr);
system(command);
free(command);
apc->exitValue=0;
apc->mainLoop=false;
free(cleanstr);
return;
}
if(launcher!=NULL)
{
if(launcher->entry.inTerm==false)
asprintf(&command,"%s \"%s\" &",launcher->entry.exec,cleanstr);
else
asprintf(&command,"%s %s \"%s\" &",prefs.LFSTK_getCString("termcommand"),launcher->entry.exec,cleanstr);
sendNotify("Running ",launcher->entry.exec);
system(command);
free(cleanstr);
free(command);
}
}
}
void setGadgetDetails(LFSTK_gadgetClass *gadget)
{
if(useTheme==false)
{
gadget->LFSTK_setAlpha(1.0);
gadget->LFSTK_setTile(NULL,0);
gadget->LFSTK_setColourName(NORMALCOLOUR,panelColour);
gadget->LFSTK_setFontColourName(NORMALCOLOUR,panelTextColour,true);
if(noButtons==true)
{
gadget->gadgetDetails.bevel=BEVELNONE;
gadget->LFSTK_setColourName(PRELIGHTCOLOUR,panelColour);
gadget->LFSTK_setColourName(ACTIVECOLOUR,panelColour);
gadget->LFSTK_setColourName(INACTIVECOLOUR,panelColour);
}
}
}

View File

@ -0,0 +1,117 @@
/*
*
* ©K. D. Hedger. Sun 20 Sep 14:41:04 BST 2015 keithdhedger@gmail.com
* This file (globals.h) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include "config.h"
#include <lfstk/LFSTKGlobals.h>
#include "callbacks.h"
#include "clock.h"
#include "slider.h"
#ifndef _GLOBALS_
#define _GLOBALS_
#define WINHELPER DATADIR "/scripts/PanelHelperWinList"
#define BWIDTH 64
#define SPACING 10
#define WINDOWREFRESH 2
#define RCNAME "lfsdock"
#define REFRESHMULTI 4
enum PANELXPOS {PANELLEFT=-1,PANELCENTRE=-2,PANELRIGHT=-3};
enum PANELYPOS {PANELTOP=-1,PANELBOTTOM=-3};
enum PANELSIZE {PANELFULL=-1,PANELSHRINK=-2};
enum PANELGRAVITY {PANELABS=0,PANELNORTH,PANELEAST,PANELSOUTH,PANELWEST};
struct menuEntryStruct
{
char *name=NULL;
char *exec=NULL;
char *icon=NULL;
bool inTerm;
};
struct launcherList
{
launcherList *next=NULL;
LFSTK_buttonClass *bc=NULL;
char *icon=NULL;
menuEntryStruct entry;
};
enum {NOLAUNCHERS,LAUNCHERINLEFT,LAUNCHERINRITE};
//prefs
extern LFSTK_prefsClass prefs;
extern int panelHeight;
extern int panelWidth;
extern const monitorStruct *mons;
extern int onMonitor;
extern int panelPos;
extern int panelGravity;
extern bool useTheme;
extern const char *panelColour;
extern const char *panelTextColour;
extern bool noButtons;
extern int queueID;
extern msgBuffer buffer;
extern bool realMainLoop;
extern const char *desktopTheme;
// const char *panelID;
extern int refreshRate;
extern int iconSize;
//panel window
extern LFSTK_applicationClass *apc;
extern LFSTK_windowClass *mainwind;
extern int rightOffset;
extern int leftOffset;
extern int launcherSide;
//atoms
extern Atom WM_STATE;
extern Atom NET_WM_WINDOW_TYPE_NORMAL;
extern Atom NET_WM_STATE_HIDDEN;
extern Atom NET_WM_WINDOW_TYPE_DIALOG;
extern Atom NET_WM_DESKTOP;
extern Atom NET_WM_WINDOW_TYPE;
extern Atom NET_WM_STATE;
extern Atom NET_WM_NAME;
extern Atom UTF8_STRING;
extern const char *possibleError;
void printError(const char *err);
void setSizes(int *x,int *y,int *w,int *h,int *size,int *grav,bool fromleft);
void dropDesktopFile(const char *data,launcherList *launcher);
void sendNotify(const char *message1,const char *message2);
void setGadgetDetails(LFSTK_gadgetClass *gadget);
#endif

View File

@ -0,0 +1,172 @@
/*
*
* ©K. D. Hedger. Wed 28 Oct 19:47:41 GMT 2015 keithdhedger@gmail.com
* This file (launchers.cpp) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ftw.h>
#include <stdio.h>
#include <string>
#include <glib.h>
#include "launchers.h"
launcherList *ll=NULL;
void addALAuncher(const char *fpath,menuEntryStruct *entry)
{
size_t start_pos=0;
std::string from;
std::string str;
bool goodkey;
GKeyFile *kf=g_key_file_new();
char *execstring;
entry->icon=NULL;
entry->name=NULL;
entry->exec=NULL;
entry->inTerm=false;
goodkey=g_key_file_load_from_file(kf,fpath,G_KEY_FILE_NONE,NULL);
if(goodkey==true)
{
entry->name=g_key_file_get_string(kf,"Desktop Entry",G_KEY_FILE_DESKTOP_KEY_NAME,NULL);
entry->icon=g_key_file_get_string(kf,"Desktop Entry",G_KEY_FILE_DESKTOP_KEY_ICON,NULL);
entry->inTerm=g_key_file_get_boolean(kf,"Desktop Entry",G_KEY_FILE_DESKTOP_KEY_TERMINAL,NULL);
execstring=g_key_file_get_string(kf,"Desktop Entry",G_KEY_FILE_DESKTOP_KEY_EXEC,NULL);
str=execstring;
from="%f";
while((start_pos=str.find(from,start_pos))!=std::string::npos)
str.replace(start_pos, from.length(),"");
from="%U";
start_pos=0;
while((start_pos=str.find(from,start_pos))!=std::string::npos)
str.replace(start_pos, from.length(),"");
entry->exec=strdup(str.c_str());
free(execstring);
}
g_key_file_free(kf);
}
int launcherBuildCB(const char *fpath,const struct stat *sb,int typeflag)
{
menuEntryStruct entry;
char *icon=NULL;
launcherList *newlist=NULL;
launcherList *looplist=NULL;
if(typeflag!=FTW_F)
return(0);
entry.icon=NULL;
entry.name=NULL;
entry.exec=NULL;
entry.inTerm=false;
addALAuncher(fpath,&entry);
if((entry.name!=NULL) && (entry.exec!=NULL))
{
newlist=new launcherList;
newlist->entry=entry;
newlist->next=NULL;
newlist->bc=NULL;
newlist->icon=entry.icon;
if(ll!=NULL)
{
looplist=ll;
while(looplist->next!=NULL)
looplist=looplist->next;
looplist->next=newlist;
}
else
ll=newlist;
}
else
{
if(entry.name!=NULL)
free(entry.name);
if(entry.exec!=NULL)
free(entry.exec);
if(entry.icon!=NULL)
free(entry.icon);
if(icon!=NULL)
free(icon);
}
return(0);
}
int addLaunchers(int x,int y,int grav,bool fromleft)
{
char *launchers;
launcherList *loopll;
ll=NULL;
char *icon=NULL;
int xpos=x;
int ypos=y;
int width=0;
int height=0;
int thisgrav=grav;
int iconsize=16;
int maxwidth=0;
int sx,sy;
asprintf(&launchers,"%s/launchers-DOCK",apc->configDir);
ftw(launchers,launcherBuildCB,16);
setSizes(&xpos,&ypos,&width,&height,&iconsize,&thisgrav,fromleft);
maxwidth=width;
sx=xpos;
sy=ypos;
loopll=ll;
while(loopll!=NULL)
{
icon=NULL;
loopll->bc=new LFSTK_buttonClass(mainwind,"",sx,sy,width,height,thisgrav);
loopll->bc->LFSTK_setMouseCallBack(NULL,launcherCB,(void*)loopll);
loopll->bc->LFSTK_setGadgetDropCallBack(gadgetDrop,(void*)loopll);
loopll->bc->gadgetAcceptsDnD=true;
if((loopll->icon!=NULL) && (desktopTheme!=NULL))
icon=apc->globalLib->LFSTK_findThemedIcon(desktopTheme,loopll->icon,"");
if(icon!=NULL)
loopll->bc->LFSTK_setImageFromPath(icon,LEFT,true);
else
loopll->bc->LFSTK_setImageFromPath(DATADIR "/pixmaps/command.png",LEFT,true);
setGadgetDetails(loopll->bc);
if(icon!=NULL)
free(icon);
loopll=loopll->next;
if((grav==PANELNORTH) || (grav==PANELSOUTH))
{
if(fromleft==false)
sx-=width;
else
sx+=width;
}
else
sy+=height;
maxwidth+=width;
}
free(launchers);
return(maxwidth-width);
}

View File

@ -0,0 +1,31 @@
/*
*
* ©K. D. Hedger. Wed 28 Oct 19:47:48 GMT 2015 keithdhedger@gmail.com
* This file (launchers.h) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _LAUNCHERS_
#define _LAUNCHERS_
#include "globals.h"
#include "callbacks.h"
extern launcherList *ll;
int addLaunchers(int x,int y,int grav,bool fromleft);
#endif

View File

@ -0,0 +1,298 @@
/*
*
* ©K. D. Hedger. Mon 7 Sep 13:20:24 BST 2015 keithdhedger@gmail.com
* This file (lfswmprefs.cpp) is part of LFSApplications.
* LFSApplications is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation,either version 3 of the License,or
* at your option) any later version.
* LFSApplications is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSApplications. If not,see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/msg.h>
#include "globals.h"
#include "clock.h"
#include "launchers.h"
#include "slider.h"
#define RCNAME "lfsdock"
#define REFRESHMULTI 4
void loadPrefs(const char *env)
{
prefs.LFSTK_loadVarsFromFile(env);
panelHeight=prefs.LFSTK_getInt(prefs.LFSTK_hashFromKey("panelheight"));
panelWidth=prefs.LFSTK_getInt(prefs.LFSTK_hashFromKey("panelwidth"));
onMonitor=prefs.LFSTK_getInt(prefs.LFSTK_hashFromKey("onmonitor"));
panelPos=prefs.LFSTK_getInt(prefs.LFSTK_hashFromKey("panelpos"));
panelGravity=prefs.LFSTK_getInt(prefs.LFSTK_hashFromKey("panelgrav"));
useTheme=prefs.LFSTK_getBool(prefs.LFSTK_hashFromKey("usetheme"));
panelColour=prefs.LFSTK_getCString(prefs.LFSTK_hashFromKey("panelcolour"));
panelTextColour=prefs.LFSTK_getCString(prefs.LFSTK_hashFromKey("textcolour"));
noButtons=prefs.LFSTK_getBool(prefs.LFSTK_hashFromKey("nobuttons"));
}
void addLeftGadgets(void)
{
int offset=leftOffset;
for(int j=0; j<prefs.LFSTK_getStringObject("gadgetsleft")->length();j++)
{
switch(prefs.LFSTK_getStringObject("gadgetsleft")->at(j))
{
case 'C':
offset+=addClock(offset,mons->y,NorthWestGravity);
break;
case 'S':
offset+=panelHeight;
break;
case 'l':
if(launcherSide==NOLAUNCHERS)
{
launcherSide=LAUNCHERINLEFT;
offset+=addLaunchers(offset,mons->y,panelGravity,true);
}
else
printError("Duplicate launcher widget");
break;
case 's':
offset+=addSlider(offset,mons->y,panelGravity,true);
break;
}
}
offset++;
leftOffset=offset;
}
int errHandler(Display *dpy,XErrorEvent *e)
{
char buf[128];
buf[0]=0;
XGetErrorText(dpy,e->error_code,buf,sizeof buf);
fprintf(stderr,"Xlib Error: %s - %s\n",buf,possibleError);
return 0;
}
void printError(const char *err)
{
fprintf(stderr,">>>%s<<<\n",err);
}
bool windowDrop(LFSTK_windowClass *lwc,void* ud)
{
char *cleanstr=NULL;
if(lwc!=NULL)
{
if(lwc->droppedData.type=DROPURI)
dropDesktopFile((const char*)lwc->droppedData.data,NULL);
}
return(true);
}
int main(int argc,char **argv)
{
char *env;
XEvent event;
int psize;
int thold;
int px,py;
timeval tv={0,0};
int key=666;
int refreshmulti=0;
prefs.prefsMap={
{prefs.LFSTK_hashFromKey("panelheight"),{TYPEINT,"panelheight","",false,0}},
{prefs.LFSTK_hashFromKey("panelwidth"),{TYPEINT,"panelwidth","",false,0}},
{prefs.LFSTK_hashFromKey("onmonitor"),{TYPEINT,"onmonitor","",false,0}},
{prefs.LFSTK_hashFromKey("termcommand"),{TYPESTRING,"termcommand","xterm -e ",false,0}},
{prefs.LFSTK_hashFromKey("logoutcommand"),{TYPESTRING,"logoutcommand","xterm",false,0}},
{prefs.LFSTK_hashFromKey("restartcommand"),{TYPESTRING,"restartcommand","xterm",false,0}},
{prefs.LFSTK_hashFromKey("shutdowncommand"),{TYPESTRING,"shutdowncommand","xterm",false,0}},
{prefs.LFSTK_hashFromKey("gadgetsright"),{TYPESTRING,"gadgetsright","L",false,0}},
{prefs.LFSTK_hashFromKey("gadgetsleft"),{TYPESTRING,"gadgetsleft","l",false,0}},
{prefs.LFSTK_hashFromKey("panelpos"),{TYPEINT,"panelpos","",false,0}},
{prefs.LFSTK_hashFromKey("panelgrav"),{TYPEINT,"panelgrav","",false,0}},
{prefs.LFSTK_hashFromKey("usetheme"),{TYPEBOOL,"usetheme","",false,0}},
{prefs.LFSTK_hashFromKey("nobuttons"),{TYPEBOOL,"nobuttons","",false,0}},
{prefs.LFSTK_hashFromKey("panelcolour"),{TYPESTRING,"panelcolour","",false,0}},
{prefs.LFSTK_hashFromKey("textcolour"),{TYPESTRING,"textcolour","black",false,0}}
};
realMainLoop=true;
XSetErrorHandler(errHandler);
while(realMainLoop==true)
{
panelPos=PANELCENTRE;
apc=new LFSTK_applicationClass();
apc->LFSTK_addWindow(NULL,NULL);
mainwind=apc->mainWindow;
mainwind->LFSTK_initDnD(true);
mainwind->LFSTK_setWindowDropCallBack(windowDrop,(void*)0xdeadbeef);
WM_STATE=XInternAtom(mainwind->app->display,"WM_STATE",False);
NET_WM_WINDOW_TYPE_NORMAL=XInternAtom(mainwind->app->display,"_NET_WM_WINDOW_TYPE_NORMAL",False);
NET_WM_STATE_HIDDEN=XInternAtom(mainwind->app->display,"_NET_WM_STATE_HIDDEN",False);
NET_WM_WINDOW_TYPE_DIALOG=XInternAtom(mainwind->app->display,"_NET_WM_WINDOW_TYPE_DIALOG",False);
NET_WM_DESKTOP=XInternAtom(mainwind->app->display,"_NET_WM_DESKTOP",False);
NET_WM_WINDOW_TYPE=XInternAtom(mainwind->app->display,"_NET_WM_WINDOW_TYPE",False);
NET_WM_STATE=XInternAtom(mainwind->app->display,"_NET_WM_STATE",False);
NET_WM_NAME=XInternAtom(mainwind->app->display,"_NET_WM_NAME",False);
UTF8_STRING=XInternAtom(mainwind->app->display,"UTF8_STRING",False);
env=mainwind->globalLib->LFSTK_oneLiner("sed -n '2p' %s/lfsappearance.rc",apc->configDir);
key=atoi(env);
freeAndNull(&env);
apc->LFSTK_setTimer(refreshRate);
apc->LFSTK_setTimerCallBack(timerCB,NULL);
if((queueID=msgget(key,IPC_CREAT|0660))==-1)
fprintf(stderr,"Can't create message queue\n");
iconSize=32;
asprintf(&env,"%s/%s.rc",apc->configDir,RCNAME);
loadPrefs(env);
desktopTheme=mainwind->globalLib->desktopIconTheme.c_str();
mons=apc->LFSTK_getMonitorData(onMonitor);
rightOffset=0;
leftOffset=0;
if(useTheme==false)
{
mainwind->LFSTK_setTile(NULL,0);
mainwind->LFSTK_setWindowColourName(NORMALCOLOUR,panelColour);
}
addLeftGadgets();
if((leftOffset==0) && (rightOffset==0))
{
fprintf(stderr,"Not using empty panel ...\n");
exit(0);
}
psize=leftOffset+abs(rightOffset);
px=mons->x;
py=mons->y;
switch(panelGravity)
{
case PANELSOUTH:
py=mons->y+mons->h-panelHeight;
case PANELNORTH:
switch(panelWidth)
{
case PANELFULL:
panelWidth=mons->w;
panelPos=PANELLEFT;
break;
case PANELSHRINK:
panelWidth=psize;
break;
}
switch(panelPos)
{
case PANELLEFT:
px=mons->x;
break;
case PANELCENTRE:
px=((mons->w/2)-(psize/2))+mons->x;
break;
case PANELRIGHT:
px=mons->x+mons->w-psize;
break;
}
break;
case PANELEAST:
px=mons->x+mons->w-panelHeight;
case PANELWEST:
switch(panelWidth)
{
case PANELFULL:
panelWidth=panelHeight;
panelHeight=mons->h;
panelPos=PANELLEFT;
break;
case PANELSHRINK:
panelWidth=panelHeight;
panelHeight=psize;
break;
default:
thold=panelWidth;
panelWidth=panelHeight;
panelHeight=thold;
break;
}
switch(panelPos)
{
case PANELLEFT:
py=mons->y;
break;
case PANELCENTRE:
py=((mons->h/2)-(panelHeight/2))+mons->y;
break;
case PANELRIGHT:
py=mons->y+mons->h-panelHeight;
break;
}
break;
}
mainwind->LFSTK_resizeWindow(panelWidth,panelHeight,true);
mainwind->LFSTK_moveWindow(px,py,true);
mainwind->LFSTK_showWindow(true);
mainwind->LFSTK_setKeepAbove(true);
int retval=apc->LFSTK_runApp();
free(env);
launcherList *freell;
while(ll!=NULL)
{
freell=ll;
if(ll->icon!=NULL)
free(ll->icon);
if(ll->entry.name!=NULL)
free(ll->entry.name);
if(ll->entry.exec!=NULL)
free(ll->entry.exec);
ll=ll->next;
delete freell;
}
free(iconL);
free(iconM);
free(iconH);
clockButton=NULL;
launcherSide=NOLAUNCHERS;
delete apc;
}
cairo_debug_reset_static_data();
return 0;
}

View File

@ -0,0 +1,225 @@
/*
*
* ©K. D. Hedger. Thu 3 Jan 12:11:08 GMT 2019 keithdhedger@gmail.com
* This file (slider.cpp) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <alsa/asoundlib.h>
#include "globals.h"
LFSTK_scrollBarClass *vsb=NULL;
LFSTK_windowClass *scwindow=NULL;
bool windowVisible=false;
LFSTK_toggleButtonClass *volumeButton;
char *iconH=NULL;
char *iconM=NULL;
char *iconL=NULL;
int oldVolVal=-1;
char label[32];
void setLabel(void)
{
int value=(int)(((double)vsb->LFSTK_getValue()/64.0)*100.0);
sprintf(label,"Vol %i%%",value);
volumeButton->LFSTK_setLabel((const char*)label);
setIcon();
volumeButton->LFSTK_clearWindow();
}
int getAlsaVolume(bool setvol,int volume)
{
long value=-1;
snd_mixer_t *handle;
snd_mixer_selem_id_t *sid;
snd_mixer_elem_t *elem;
const char *card="default";
const char *selem_name="Master";
snd_mixer_open(&handle,0);
snd_mixer_attach(handle,card);
snd_mixer_selem_register(handle,NULL,NULL);
snd_mixer_load(handle);
snd_mixer_selem_id_malloc(&sid);
snd_mixer_selem_id_set_index(sid,0);
snd_mixer_selem_id_set_name(sid,selem_name);
elem=snd_mixer_find_selem(handle,sid);
if(setvol==true)
snd_mixer_selem_set_playback_volume_all(elem,volume);
else
snd_mixer_selem_get_playback_volume(elem,SND_MIXER_SCHN_UNKNOWN,&value);
snd_mixer_detach(handle,card);
snd_mixer_close(handle);
snd_mixer_selem_id_free(sid);
return(value);
}
void setIcon(void)
{
int vol=vsb->LFSTK_getValue();
if(vol<21)
volumeButton->LFSTK_setImageFromPath(iconL,TOOLBAR,true);
if((vol>21) && (vol<41))
volumeButton->LFSTK_setImageFromPath(iconM,TOOLBAR,true);
if(vol>42)
volumeButton->LFSTK_setImageFromPath(iconH,TOOLBAR,true);
}
bool sliderCB(void *p,void* ud)
{
LFSTK_toggleButtonClass *bc=static_cast<LFSTK_toggleButtonClass*>(p);
geometryStruct geom;
int x,y;
Window dw;
if(p!=NULL)
{
if(bc->LFSTK_getValue()==1)
{
bc->LFSTK_getGeomWindowRelative(&geom,apc->rootWindow);
switch(panelGravity)
{
case PANELNORTH:
scwindow->LFSTK_moveWindow(geom.x,geom.y+geom.h,true);
break;
case PANELSOUTH:
scwindow->LFSTK_moveWindow(geom.x,geom.y-SCROLLBARWIDTH,true);
break;
case PANELEAST:
scwindow->LFSTK_moveWindow(geom.x-SCROLLBARWIDTH,geom.y,true);
break;
case PANELWEST:
scwindow->LFSTK_moveWindow(geom.x+geom.w,geom.y,true);
break;
}
scwindow->LFSTK_showWindow(true);
scwindow->LFSTK_redrawAllGadgets();
apc->windows->at(apc->LFSTK_findWindow(scwindow)).showing=true;
}
else
{
scwindow->LFSTK_hideWindow();
apc->windows->at(apc->LFSTK_findWindow(scwindow)).showing=false;
}
bc->LFSTK_clearWindow();
}
return(true);
}
bool valChanged(void *p,void* ud)
{
LFSTK_scrollBarClass *sb=NULL;
char *command;
char *vol;
int volume=-1;
if(p!=NULL)
{
sb=static_cast<LFSTK_scrollBarClass*>(p);
if(sb!=NULL)
{
getAlsaVolume(true,sb->LFSTK_getValue());
setLabel();
}
}
return(true);
}
void updateSlider(void)
{
int volume;
volume=getAlsaVolume(false,-1);
if(oldVolVal!=volume)
{
vsb->LFSTK_setValue(volume);
oldVolVal=vsb->LFSTK_getValue();
setLabel();
}
}
int addSlider(int x,int y,int grav,bool fromleft)
{
int xpos=x;
int ypos=y;
int width=0;
int height=0;
int thisgrav=grav;
int iconsize=16;
char *label=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL);
getAlsaVolume(false,-1);
setSizes(&xpos,&ypos,&width,&height,&iconsize,&thisgrav,fromleft);
volumeButton=new LFSTK_toggleButtonClass(mainwind,label,xpos,ypos,width,height,thisgrav);
volumeButton->LFSTK_setToggleStyle(TOGGLENORMAL);
volumeButton->LFSTK_setMouseCallBack(NULL,sliderCB,(void*)volumeButton->LFSTK_getLabel());
setGadgetDetails(volumeButton);//TODO//
iconH=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-high","");
iconM=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-medium","");
iconL=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-low","");
char *vol=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'");
windowInitStruct *win;
int w,h;
win=new windowInitStruct;
win->x=100;
win->y=100;
bool direction=false;
if((panelGravity==PANELWEST) || (panelGravity==PANELEAST))
{
w=16;
h=100;
direction=true;
}
else
{
w=100;
h=16;
direction=false;
}
win->w=w;
win->h=h;
apc->LFSTK_addToolWindow(win);
scwindow=apc->windows->back().window;
vsb=new LFSTK_scrollBarClass(scwindow,direction,0,0,w,h,BUTTONGRAV);
vsb->LFSTK_setMouseCallBack(NULL,valChanged,NULL);
vsb->LFSTK_setScale(0,64);
vsb->LFSTK_setValue(atoi(vol));
vsb->reverse=direction;
setIcon();
free(vol);
free(label);
return(width);
}

View File

@ -0,0 +1,41 @@
/*
*
* ©K. D. Hedger. Thu 3 Jan 12:10:58 GMT 2019 keithdhedger@gmail.com
* This file (slider.h) is part of LFSPanel.
* LFSPanel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SLIDER_
#define _SLIDER_
#define SLIDERWIDTH 100
#define SLIDERLABEL "Vol"
extern LFSTK_windowClass *scwindow;
extern bool windowVisible;
extern LFSTK_toggleButtonClass *volumeButton;
extern LFSTK_scrollBarClass *vsb;
extern char *iconH;
extern char *iconM;
extern char *iconL;
extern int oldVolVal;
void setIcon(void);
int addSlider(int x,int y,int grav,bool fromleft);
void updateSlider(void);
int getAlsaVolume(bool setvol,int volume);
#endif

2
LFSDock/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
SUBDIRS = LFSDock/app

10
LFSDock/autogen.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
./remakesourcelist
aclocal
autoheader
touch NEWS README AUTHORS ChangeLog
automake --add-missing --copy
autoconf
./configure $@

74
LFSDock/configure.ac Normal file
View File

@ -0,0 +1,74 @@
AC_INIT([LFSDock],[0.1.0],[PROJ],[LFSPanel])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
AM_INIT_AUTOMAKE
AC_PROG_CC
X11_MODULES="x11 >= 1.6.2"
PKG_CHECK_MODULES(X11, $X11_MODULES)
AC_SUBST(X11_CFLAGS)
AC_SUBST(X11_LIBS)
ALSA_MODULES="alsa >= 1.1.5"
PKG_CHECK_MODULES(ALSA, $ALSA_MODULES)
AC_SUBST(ALSA_CFLAGS)
AC_SUBST(ALSA_LIBS)
XFT_MODULES="xft >= 2.3.1"
PKG_CHECK_MODULES(XFT, $XFT_MODULES)
AC_SUBST(XFT_CFLAGS)
AC_SUBST(XFT_LIBS)
LIBGLIB_MODULES="glib-2.0 >= 2.60.0"
PKG_CHECK_MODULES(LIBGLIB, $LIBGLIB_MODULES)
AC_SUBST(LIBGLIB_LIBS)
AC_SUBST(LIBGLIB_CFLAGS)
CAIRO_MODULES="cairo >= 1.12.16"
PKG_CHECK_MODULES(CAIRO, $CAIRO_MODULES)
AC_SUBST(CAIRO_LIBS)
AC_SUBST(CAIRO_CFLAGS)
LFSTK_MODULES="lfstk >= 0.5.1"
PKG_CHECK_MODULES(LFSTK, $LFSTK_MODULES)
AC_SUBST(LFSTK_LIBS)
AC_SUBST(LFSTK_CFLAGS)
AC_CHECK_PROG(NOTIFYSEND, notify-send ,true,false)
if test $NOTIFYSEND = false; then
AC_MSG_NOTICE([No notify-send program found, install for lancher notification ...])
else
AC_ARG_ENABLE(notify,AS_HELP_STRING([--enable-notify],[Enable notifications]),[enable_notify=$enableval],[enable_notify="yes"])
if test "$enable_notify" = "yes"; then
AC_DEFINE([_GOTNOTIFYSEND_], [], [send notify])
AC_MSG_NOTICE([Enabling notifications ...])
else
AC_MSG_NOTICE([Disabling notifications ...])
fi
fi
AC_MSG_CHECKING(whether to build debug functions)
AC_ARG_ENABLE(debug,AS_HELP_STRING([--enable-debug],[Enable debug code]),
[enable_debug=$enableval],
[enable_debug="no"])
AC_MSG_RESULT($enable_debug)
if test "$enable_debug" = "yes"; then
AC_DEFINE([_ENABLEDEBUG_], [], [Enable debug code])
fi
AC_MSG_CHECKING(whether to warn about debug functions)
AC_ARG_ENABLE(warn-debug,AS_HELP_STRING([--enable-warn-debug],[Enable warn debug code]),
[enable_warn_debug=$enableval],
[enable_warn_debug="no"])
AC_MSG_RESULT($enable_warn_debug)
if test "$enable_warn_debug" = "yes"; then
AC_DEFINE([_WARN_ENABLEDEBUG_], [], [Enable warn debug code])
fi
AC_CONFIG_FILES([Makefile LFSDock/app/Makefile])
AC_OUTPUT

BIN
LFSDock/lfsdock.mpz Normal file

Binary file not shown.

6
LFSDock/remakesourcelist Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
shopt -s nullglob
cd "LFSDock/src"
csrclst=$(echo "../src/*.c" "../src/*.cpp")
echo COMMONSRC = $csrclst > ../sources