Skip to content

Commit 35e537d

Browse files
committed
Mostly finished main code.
1 parent 4185d89 commit 35e537d

File tree

8 files changed

+1076
-5
lines changed

8 files changed

+1076
-5
lines changed

CONCEPT

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@
1212
- commandline is like
1313
lxkeys global desktop2 <-- show bound key(s) for action desktop2
1414
lxkeys app <-- show all keys bound to applications
15-
lxkeys app xfrun4 Alt+F2,Win+Enter "Execute a command" <-- bind a key
15+
lxkeys app xfrun4 Alt+F2,Win+Return "Execute a command" <-- bind a key
16+
lxkeys show Win+Space <-- show which action/application is bound to the key
17+
- commandline action syntax:
18+
action1[:attr1=val1:attr2=val2][&action2]
19+
- commandline exec syntax:
20+
exec line[&startupnotify=yes[:attr1=val1]][&action=val]
1621
- do special window parameters as well???

configure.ac

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
3030

3131
AM_GLIB_GNU_GETTEXT
3232

33-
# --enable-debug option
33+
# Handle --enable-debug option
3434
AC_ARG_ENABLE(debug,
3535
[AC_HELP_STRING([--enable-debug],
3636
[enable debug support @<:@default=no@:>@])],
@@ -54,6 +54,12 @@ else
5454
CPPFLAGS="$CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
5555
fi
5656

57+
dnl Test for required libraries
58+
pkg_modules="libfm >= 1.2.0 x11"
59+
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
60+
AC_SUBST(PACKAGE_CFLAGS)
61+
AC_SUBST(PACKAGE_LIBS)
62+
5763
dnl Fix invalid sysconfdir when --prefix=/usr
5864
if test `eval "echo $sysconfdir"` = /usr/etc
5965
then

plugins/Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ AM_LDFLAGS = \
1212

1313
## modules list
1414
pkglibdir = $(libdir)/lxkeys
15-
pkglib_LTLIBRARIES =
15+
pkglib_LTLIBRARIES = ob.la
1616

1717
## Openbox module
18-
#ob_SOURCES = ob/ob.c
18+
ob_la_SOURCES = openbox.c

plugins/openbox.c

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/*
2+
* Copyright (C) 2016 Andriy Grytsenko <andrej@rep.kiev.ua>
3+
*
4+
* This file is a part of LXKeys project.
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+
21+
#ifdef HAVE_CONFIG_H
22+
# include "config.h"
23+
#endif
24+
25+
#include "lxkeys.h"
26+
27+
#include <libfm/fm-extra.h>
28+
#include <glib/gi18n.h>
29+
30+
typedef struct {
31+
char *path;
32+
FmXmlFile *xml;
33+
GList *actions; /* no-exec actions */
34+
GList *execs; /* exec-only actions */
35+
//GList *available_wm_actions;
36+
//GList *available_app_actions;
37+
} ObXmlFile;
38+
39+
static FmXmlFileTag ObXmlFile_keyboard; /* section that we work on */
40+
static FmXmlFileTag ObXmlFile_keybind; /* subsection, for each binding */
41+
static FmXmlFileTag ObXmlFile_action; /* may be multiple for a binding */
42+
static FmXmlFileTag ObXmlFile_command; /* for <action name="Execute"> */
43+
static FmXmlFileTag ObXmlFile_execute; /* obsolete alias for command */
44+
45+
static gboolean tag_handler_keyboard(FmXmlFileItem *item, GList *children,
46+
char * const *attribute_names,
47+
char * const *attribute_values,
48+
guint n_attributes, gint line, gint pos,
49+
GError **error, gpointer user_data)
50+
{
51+
/* anything to do? */
52+
return TRUE;
53+
}
54+
55+
static gboolean tag_handler_keybind(FmXmlFileItem *item, GList *children,
56+
char * const *attribute_names,
57+
char * const *attribute_values,
58+
guint n_attributes, gint line, gint pos,
59+
GError **error, gpointer user_data)
60+
{
61+
/* decide where to put: execs or actions */
62+
/* create LXKeysApp or LXKeysGlobal */
63+
}
64+
65+
static gboolean tag_handler_action(FmXmlFileItem *item, GList *children,
66+
char * const *attribute_names,
67+
char * const *attribute_values,
68+
guint n_attributes, gint line, gint pos,
69+
GError **error, gpointer user_data)
70+
{
71+
72+
}
73+
74+
static gboolean tag_handler_command(FmXmlFileItem *item, GList *children,
75+
char * const *attribute_names,
76+
char * const *attribute_values,
77+
guint n_attributes, gint line, gint pos,
78+
GError **error, gpointer user_data)
79+
{
80+
}
81+
82+
static gpointer obcfg_load(gpointer config, GError **error)
83+
{
84+
ObXmlFile *cfg = (ObXmlFile *)config;
85+
86+
if (config) {
87+
/* just discard any changes if any exist */
88+
FmXmlFile *old_xml = cfg->xml;
89+
90+
cfg->xml = fm_xml_file_new(old_xml);
91+
g_object_unref(old_xml);
92+
} else {
93+
/* prepare data */
94+
cfg = g_new0(ObXmlFile, 1);
95+
cfg->xml = fm_xml_file_new(NULL);
96+
/* register handlers */
97+
ObXmlFile_keyboard = fm_xml_file_set_handler(cfg->xml, "keyboard",
98+
&tag_handler_keyboard, FALSE, NULL);
99+
ObXmlFile_keybind = fm_xml_file_set_handler(cfg->xml, "keybind",
100+
&tag_handler_keybind, FALSE, NULL);
101+
ObXmlFile_action = fm_xml_file_set_handler(cfg->xml, "action",
102+
&tag_handler_action, FALSE, NULL);
103+
ObXmlFile_command = fm_xml_file_set_handler(cfg->xml, "command",
104+
&tag_handler_command, FALSE, NULL);
105+
ObXmlFile_execute = fm_xml_file_set_handler(cfg->xml, "execute",
106+
&tag_handler_command, FALSE, NULL);
107+
108+
/* let try to detect rc.xml file currently in use:
109+
with Lubuntu it's lubuntu-rc.xml, with lxde session it's lxde-rc.xml */
110+
111+
}
112+
/* try to load ~/.config/openbox/$xml */
113+
114+
/* if it does not exist then try to load $XDG_SYSTEM_CONFDIR/openbox/rc.xml */
115+
116+
117+
return cfg;
118+
}
119+
120+
static gboolean obcfg_save(gpointer config, GError **error)
121+
{
122+
ObXmlFile *cfg = (ObXmlFile *)config;
123+
124+
/* save as ~/.config/openbox/$xml */
125+
}
126+
127+
static void obcfg_free(gpointer config)
128+
{
129+
ObXmlFile *cfg = (ObXmlFile *)config;
130+
131+
g_free(cfg->path);
132+
g_object_unref(cfg->xml);
133+
g_free(cfg);
134+
}
135+
136+
static GList *obcfg_get_wm_keys(gpointer config, const char *mask, GError **error)
137+
{
138+
}
139+
140+
static gboolean obcfg_set_wm_key(gpointer config, LXKeysGlobal *data, GError **error)
141+
{
142+
}
143+
144+
FM_DEFINE_MODULE(lxkeys, Openbox)
145+
146+
LXKeysPluginInit fm_module_init_lxkeys = {
147+
.load = obcfg_load,
148+
.save = obcfg_save,
149+
.free = obcfg_free,
150+
.get_wm_keys = obcfg_get_wm_keys,
151+
.set_wm_key = obcfg_set_wm_key
152+
// .get_wm_actions = obcfg_get_wm_actions,
153+
// .get_app_keys = obcfg_get_app_keys,
154+
// .set_app_key = obcfg_set_app_key
155+
};

po/POTFILES.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/lxkeys.c

po/lxkeys.pot

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3+
# This file is distributed under the same license as the PACKAGE package.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5+
#
6+
#, fuzzy
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: PACKAGE VERSION\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2016-03-06 22:10+0200\n"
12+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14+
"Language-Team: LANGUAGE <LL@li.org>\n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=CHARSET\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
20+
#: ../src/lxkeys.c:198
21+
#, c-format
22+
msgid "Usage: %s global [<action>] - show keys bound to action(s)\n"
23+
msgstr ""
24+
25+
#: ../src/lxkeys.c:199
26+
#, c-format
27+
msgid " %s global <action> <key> - bind a key to the action\n"
28+
msgstr ""
29+
30+
#: ../src/lxkeys.c:200
31+
#, c-format
32+
msgid " %s app [<exec>] - show keys bound to exec line\n"
33+
msgstr ""
34+
35+
#: ../src/lxkeys.c:201
36+
#, c-format
37+
msgid " %s app <exec> <key> - bind a key to some exec line\n"
38+
msgstr ""
39+
40+
#: ../src/lxkeys.c:202
41+
#, c-format
42+
msgid " %s app <exec> -- - unbind all keys from exec line\n"
43+
msgstr ""
44+
45+
#: ../src/lxkeys.c:203
46+
#, c-format
47+
msgid " %s show <key> - show the action bound to a key\n"
48+
msgstr ""
49+
50+
#: ../src/lxkeys.c:314
51+
msgid "empty option name."
52+
msgstr ""
53+
54+
#: ../src/lxkeys.c:317
55+
msgid "empty action name."
56+
msgstr ""
57+
58+
#: ../src/lxkeys.c:347
59+
#, c-format
60+
msgid "no matching option '%s' found for action '%s'."
61+
msgstr ""
62+
63+
#: ../src/lxkeys.c:351
64+
#, c-format
65+
msgid "no mathing action '%s' found for the WM configuration."
66+
msgstr ""
67+
68+
#: ../src/lxkeys.c:364
69+
#, c-format
70+
msgid "value '%s' is not supported for option '%s'."
71+
msgstr ""
72+
73+
#: ../src/lxkeys.c:368
74+
#, c-format
75+
msgid "value '%s' is not supported for action '%s'."
76+
msgstr ""
77+
78+
#: ../src/lxkeys.c:381
79+
#, c-format
80+
msgid "action '%s' does not support options."
81+
msgstr ""
82+
83+
#: ../src/lxkeys.c:445
84+
#, c-format
85+
msgid "LXKeys: sorry, cannot configure keys remotely.\n"
86+
msgstr ""
87+
88+
#: ../src/lxkeys.c:472
89+
#, c-format
90+
msgid "Window manager %s isn't supported now, sorry."
91+
msgstr ""
92+
93+
#: ../src/lxkeys.c:479
94+
msgid "Problems loading configuration: "
95+
msgstr ""
96+
97+
#: ../src/lxkeys.c:488
98+
#, c-format
99+
msgid "GUI type %s currently isn't supported."
100+
msgstr ""
101+
102+
#. invalid request
103+
#: ../src/lxkeys.c:504 ../src/lxkeys.c:578
104+
msgid "Invalid request: "
105+
msgstr ""
106+
107+
#: ../src/lxkeys.c:514 ../src/lxkeys.c:589
108+
msgid "Problems saving configuration: "
109+
msgstr ""
110+
111+
#: ../src/lxkeys.c:531
112+
msgid "ACTION(s)"
113+
msgstr ""
114+
115+
#: ../src/lxkeys.c:531 ../src/lxkeys.c:606
116+
msgid "KEY(s)"
117+
msgstr ""
118+
119+
#: ../src/lxkeys.c:606
120+
msgid "EXEC"
121+
msgstr ""
122+
123+
#: ../src/lxkeys.c:626
124+
msgid "Requested operation isn't supported."
125+
msgstr ""

0 commit comments

Comments
 (0)