├── LICENSE
├── Makefile
├── README.md
├── debian
├── changelog
├── compat
├── control
├── copyright
├── kdesk-dbg.install
├── kdesk.install
├── libkdesk-dev.install
└── rules
├── doc
└── config
│ ├── .kdeskrc
│ ├── install-snake.lnk
│ ├── install-updater.lnk
│ └── terminal.lnk
├── src
├── Makefile
├── background.cpp
├── background.h
├── configuration.cpp
├── configuration.h
├── desktop.cpp
├── desktop.h
├── grid.cpp
├── grid.h
├── icon.cpp
├── icon.h
├── kdesk-blur
│ ├── Makefile
│ ├── kdesk-blur.cpp
│ └── kdesk-blur.h
├── kdesk-eglsaver
│ ├── Makefile
│ ├── README.md
│ ├── bitmap_homefolder.raw
│ ├── bitmap_minecraft.raw
│ ├── bitmap_pong.raw
│ ├── cube_texture_and_coords.h
│ ├── hid.cpp
│ ├── hid.h
│ └── kdesk-eglsaver.c
├── kfbsaver
│ ├── Makefile
│ ├── README
│ └── kfbsaver.cpp
├── libkdesk-hourglass
│ ├── Makefile
│ ├── kdesk-hourglass-app.cpp
│ ├── kdesk-hourglass.cpp
│ ├── kdesk-hourglass.h
│ ├── python
│ │ ├── __init__.py
│ │ └── hourglass.py
│ ├── sn_callbacks.cpp
│ ├── testdynlib.cpp
│ ├── testlib.py
│ ├── testmodule.py
│ └── testshared.cpp
├── logging.h
├── main.cpp
├── main.h
├── sound.cpp
├── sound.h
├── ssaver.cpp
├── ssaver.h
└── version.h
└── tests
├── configurations
└── kdeskrc_test
└── test_configuration.py
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile - builds kdesk
3 | #
4 | # Please read README.md file for differences on release and debug builds
5 | #
6 |
7 | all: kdesk
8 |
9 | kdesk:
10 | cd src/libkdesk-hourglass && make all
11 |
12 | cd src && make -B
13 | cd src && make debug -B
14 |
15 | cd src/kdesk-eglsaver && make all
16 | cd src/kdesk-blur && make all
17 |
18 | debug:
19 | cd src/libkdesk-hourglass && make all
20 | cd src && make debug -B
21 | cd src/kdesk-eglsaver && make debug
22 | cd src/kdesk-blur && make debug
23 |
24 | kano-debber:
25 | mkdir -p /home/user/.kdesktop
26 | cp doc/config/.kdeskrc /home/user/
27 | cp doc/config/*.lnk /home/user/.kdesktop/
28 |
29 | sed -i.bak 's/@pcmanfm --desktop --profile LXDE/@kdesk/' /etc/xdg/lxsession/LXDE/autostart
30 |
31 | chown -R user:user /home/user/.kdesk*
32 | cd src && make all
33 | cd src/kdesk-blur && make all
34 | cd src/libkdesk-hourglass && make all
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Kano Desktop manager - kdesk
2 |
3 |
4 | Kano Desktop Manager, aka *kdesk*, is a lightweight desktop manager optimized for Kano OS and other Debian-based systems, including the desktop background image, icons, and egl screensaver.
5 |
6 | We’ve created the utility from scratch, with inspiration taken from other desktop managers, especially [idesk](https://github.com/neagix/idesk) and [vdesk](http://xvnkb.sourceforge.net/?menu=vdesk&lang=en).
7 |
8 | Features:
9 | * optimized connection with the notify library for Openbox window manager and others, so the hourglass start-up feature works seamlessly
10 | * 100% customizable background, icons, screensaver
11 | * efficient screensaver with low CPU usage
12 |
13 | Check all the detailed information in the [wiki](https://github.com/KanoComputing/kdesk/wiki)
14 |
15 |
16 | [Introduction](https://github.com/KanoComputing/kdesk/wiki/Introduction)
17 | [Development](https://github.com/KanoComputing/kdesk/wiki/Development)
18 | [Collaboration](https://github.com/KanoComputing/kdesk/wiki/Collaboration)
19 |
20 |
21 | ### Localization
22 |
23 | kdesk supports localization of two icon file types: `Icon` and `IconHover`.
24 |
25 | In your `lnk` icon files, simply set a path to the default international version of the asset,
26 | and kdesk will try to find the localized version of it on the fly, the lnk file will not be modified.
27 | For example, provided your LANG is set to `es_AR.UTF-8`:
28 |
29 | ```
30 | Icon: /usr/share/my-app/icons/app.png
31 | IconHover: /usr/share/my-app/hovers/app-hover.png
32 | ```
33 |
34 | Would be translated by kdesk to:
35 |
36 | ```
37 | Icon: /usr/share/my-app/icons/i18n/es_AR/app.png
38 | IconHover: /usr/share/my-app/hovers/i18n/es_AR/app-hover.png
39 | ```
40 |
41 | If the localized icon file cannot be found, kdesk will fallback to load the original one.
42 | The `es_AR` will be obtained by querying the `LANG` environment variable, you can easily force it to test new locales.
43 | Testing the configuration on the debug version will tell you which icons are localized or missing:
44 |
45 | ```
46 | LANG=zh_TW.Big5 ./kdesk-dbg -t | grep i18n
47 | ```
48 |
--------------------------------------------------------------------------------
/debian/changelog:
--------------------------------------------------------------------------------
1 | kdesk (4.0.1-0) unstable; urgency=low
2 |
3 | * Fixed a memory leak that stopped screen saver from working
4 |
5 | -- Team Kano Tue, 29 May 2018 15:27:00 +0100
6 |
7 | kdesk (4.0.0-0) unstable; urgency=low
8 |
9 | * Build for Debian Stretch
10 | * Added flag -m to disable MIT-SHM XServer extension
11 |
12 | -- Team Kano Tue, 22 May 2018 14:46:00 +0100
13 |
14 | kdesk (1.6-3) unstable; urgency=low
15 |
16 | * Added support for localizing desktop icons
17 |
18 | -- Team Kano Mon, 20 Feb 2017 15:33:00 +0100
19 |
20 | kdesk (1.5-3) unstable; urgency=low
21 |
22 | * Added screen saver run mode with hooks, and no icons loaded
23 |
24 | -- Team Kano Thu, 26 May 2016 17:58:00 +0100
25 |
26 | kdesk (1.4-3) unstable; urgency=low
27 |
28 | * Added automatic conversion and caching of SVG icons
29 |
30 | -- Team Kano Mon, 18 Jan 2016 14:17:00 +0100
31 |
32 | kdesk (1.3-3) unstable; urgency=low
33 |
34 | * Added command to find icon positions on the desktop (-j)
35 |
36 | -- Team Kano Fri, 8 Jan 2016 12:35:00 +0000
37 |
38 | kdesk (1.3-2) unstable; urgency=low
39 |
40 | * Roll back to the grid to accomodate 7 icons per row
41 |
42 | -- Team Kano Fri, 13 Feb 2015 10:29:00 +0000
43 |
44 | kdesk (1.3-1) unstable; urgency=low
45 |
46 | * The grid can now accomodate 8 icons per row
47 |
48 | -- Team Kano Tue, 9 Dec 2014 10:29:00 +0000
49 |
50 | kdesk (1.1-9) unstable; urgency=low
51 |
52 | * kdesk-hourglass provides a new API based on the app command line only
53 |
54 | -- Team Kano Wed, 12 Nov 2014 15:20:00 +0000
55 |
56 | kdesk (1.1-8) unstable; urgency=low
57 |
58 | * kdesk now maintains a file with the number of icons on the desktop
59 |
60 | -- Team Kano Tue, 15 Jul 2014 18:29:15 +0001
61 |
62 | kdesk (1.1-07) unstable; urgency=low
63 |
64 | * Making the kdesk package replace idesk
65 |
66 | -- Team Kano Mon, 17 Mar 2014 11:05:10 +0000
67 |
68 | kdesk (1.1-06) unstable; urgency=low
69 |
70 | * Package rebuilt, updated to revision 2a6ea088.
71 |
72 | -- Team Kano Mon, 10 Mar 2014 17:36:51 +0000
73 |
74 | kdesk (1.1-05) unstable; urgency=low
75 |
76 | * Package rebuilt, updated to revision 2a6ea088.
77 |
78 | -- Team Kano Mon, 10 Mar 2014 17:27:29 +0000
79 |
80 | kdesk (1.1-04) unstable; urgency=low
81 |
82 | * Package rebuilt, updated to revision 3c2e8089.
83 |
84 | -- Team Kano Mon, 10 Mar 2014 17:14:47 +0000
85 |
86 | kdesk (1.1-03) unstable; urgency=low
87 |
88 | * Package rebuilt, updated to revision 3c2e8089.
89 |
90 | -- Team Kano Mon, 10 Mar 2014 17:01:37 +0000
91 |
92 | kdesk (1.1-02) unstable; urgency=low
93 |
94 | * Package rebuilt, updated to revision d5e09a42.
95 |
96 | -- Team Kano Fri, 07 Mar 2014 21:06:14 +0000
97 |
98 | kdesk (1.1-01) unstable; urgency=low
99 |
100 | * Package rebuilt, updated to revision a9a7cfc0.
101 |
102 | -- Team Kano Fri, 07 Mar 2014 14:56:58 +0000
103 |
104 | kdesk (1.1-00) unstable; urgency=low
105 |
106 | * Initial release.
107 |
108 | -- Team Kano Wed, 13 Sep 2013 15:10:03 +0000
109 |
--------------------------------------------------------------------------------
/debian/compat:
--------------------------------------------------------------------------------
1 | 9
2 |
--------------------------------------------------------------------------------
/debian/control:
--------------------------------------------------------------------------------
1 | Source: kdesk
2 | Maintainer: Team Kano
3 | Section: x11
4 | Priority: optional
5 | Standards-Version: 1.1.0
6 | Build-Depends: libx11-dev, libxft-dev, libimlib2-dev, libstartup-notification0-dev, libxss-dev, libraspberrypi-dev, debhelper (>=9.0.0), g++-4.7
7 |
8 | Package: kdesk
9 | Architecture: any
10 | Depends: libkdesk-dev (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends}, libstartup-notification0, libxss1, librsvg2-bin
11 | Provides: idesk
12 | Conflicts: idesk
13 | Replaces: idesk
14 | Description: Kanux desktop icon manager
15 | This package provides the Kanux graphical desktop facade.
16 | It presents the Kanux background along with all Kano-Make icons organized
17 | so you can follow all learning experience apps: Make Pong, Minecraft, Video
18 | and surf the rest of system applications directly from the desktop
19 |
20 | Package: libkdesk-dev
21 | Architecture: any
22 | Depends: ${misc:Depends}, ${shlibs:Depends}, libstartup-notification0, python
23 | Description: Kanux desktop hourglass developer library
24 | This package contains the library, include file and sample source code
25 | to provide your applications with an hourglass for desktop lengthy tasks.
26 |
27 | Package: kdesk-dbg
28 | Architecture: any
29 | Depends: libkdesk-dev (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends}, libstartup-notification0, libxss1
30 | Description: Kanux desktop icon manager (Debug version)
31 |
--------------------------------------------------------------------------------
/debian/copyright:
--------------------------------------------------------------------------------
1 | Files: *
2 | Copyright: 2014-2016 Kano Computing Ltd.
3 | License: GPL-2+
4 |
--------------------------------------------------------------------------------
/debian/kdesk-dbg.install:
--------------------------------------------------------------------------------
1 | src/kdesk-dbg /usr/bin
2 |
--------------------------------------------------------------------------------
/debian/kdesk.install:
--------------------------------------------------------------------------------
1 | src/kdesk /usr/bin
2 | src/kdesk-blur/kdesk-blur /usr/bin
3 | src/kdesk-eglsaver/kdesk-eglsaver /usr/bin
4 |
--------------------------------------------------------------------------------
/debian/libkdesk-dev.install:
--------------------------------------------------------------------------------
1 | src/libkdesk-hourglass/libkdesk-hourglass.so /usr/lib
2 | src/libkdesk-hourglass/kdesk-hourglass.h /usr/include/
3 | src/libkdesk-hourglass/testlib.py /usr/share/doc/kdesk
4 | src/libkdesk-hourglass/testmodule.py /usr/share/doc/kdesk
5 | src/libkdesk-hourglass/testdynlib.cpp /usr/share/doc/kdesk
6 | src/libkdesk-hourglass/testshared.cpp /usr/share/doc/kdesk
7 | src/libkdesk-hourglass/python/* /usr/lib/python2.7/dist-packages/kdesk
8 | src/libkdesk-hourglass/kdesk-hourglass-app /usr/bin
9 |
--------------------------------------------------------------------------------
/debian/rules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/make -f
2 |
3 | %:
4 | dh $@
5 |
6 | override_dh_auto_build:
7 | # FIXME: The chroot environment should handle these links
8 | ln -sfv -r /opt/vc/lib/libbrcmEGL.so /opt/vc/lib/libEGL.so
9 | ln -sfv -r /opt/vc/lib/libbrcmGLESv2.so /opt/vc/lib/libGLESv2.so
10 | make kdesk
11 |
12 | override_dh_strip:
13 | # don't strip symbols off libkdesk-hourglass.so
14 | # FIXME: find a better way to resolve this issue
15 |
16 | override_dh_shlibdeps:
17 | # same rules apply as for override_dh_strip, so we provide exported library symbols
18 |
--------------------------------------------------------------------------------
/doc/config/.kdeskrc:
--------------------------------------------------------------------------------
1 | table Config
2 |
3 | FontName: Bariol
4 | FontSize: 10
5 | FontColor: #FFFFFF
6 | ToolTip.FontSize: 10
7 | ToolTip.FontName: Bariol
8 | ToolTip.ForeColor: #0000FF
9 | ToolTip.BackColor: #FFFFFF
10 | ToolTip.CaptionOnHover: false
11 | ToolTip.CaptionPlacement: Right
12 | Locked: true
13 |
14 | EnableSound: false
15 | #SoundWelcome: /usr/share/kano-media/sounds/kano_boot_up.wav
16 | #SoundLaunchApp: /usr/share/kano-media/sounds/kano_open_app.wav
17 | #SoundDisabledIcon: /usr/share/kano-media/sounds/kano_error.wav
18 |
19 | ScreenSaverTimeout: 0
20 | #ScreenSaverProgram: /usr/bin/kdesk-eglsaver
21 |
22 | OneClick: true
23 |
24 | Transparency: 255
25 | Shadow: true
26 | ShadowColor: #000000
27 | ShadowX: 1
28 | ShadowY: 1
29 | Bold: true
30 | ClickDelay: 300
31 | IconStartDelay: 5000
32 | IconSnap: true
33 | IconTitleGap: 20
34 | SnapWidth: 10
35 | SnapHeight: 10
36 | SnapOrigin: BottomRight
37 | SnapShadow: false
38 | SnapShadowTrans: 200
39 | CaptionOnHover: false
40 | CaptionPlacement: bottom
41 | FillStyle: None
42 | Background.Delay: 0
43 | Background.Source: /
44 |
45 | ScreenMedResWidth: 1900
46 | Background.File-medium: /usr/share/lxde/wallpapers/kanux-background-1024.png
47 | Background.File-4-3: /usr/share/lxde/wallpapers/kanux-background-4-3.jpg
48 | Background.File-16-9: /usr/share/lxde/wallpapers/kanux-background-16-9.jpg
49 | Background.Mode: scale
50 | Background.Color: #C2CCFF
51 | end
52 |
53 | table Actions
54 | # Lock: control right doubleClk
55 | # Reload: middle doubleClk
56 | # Drag: left hold
57 | # EndDrag: left singleClk
58 |
59 | Execute[0]: left doubleClk
60 |
61 | # Execute[1]: right doubleClk
62 | end
63 |
--------------------------------------------------------------------------------
/doc/config/install-snake.lnk:
--------------------------------------------------------------------------------
1 | table Icon
2 | Caption: Snake
3 | Command: lxterminal -e "sudo /home/user/install-snake.sh"
4 | Singleton: true
5 | Icon: /usr/share/icons/kano/snake.png
6 | HoverXOffset: 0
7 | Width: 64
8 | Height: 64
9 | Relative-To: top-left
10 | X: 30
11 | Y: 30
12 | end
13 |
--------------------------------------------------------------------------------
/doc/config/install-updater.lnk:
--------------------------------------------------------------------------------
1 | table Icon
2 | Caption: Updater
3 | Command: lxterminal -e "sudo /home/user/install-updater.sh"
4 | Singleton: true
5 | Icon: /usr/share/icons/kano/updater.png
6 | HoverXOffset: 0
7 | Width: 65
8 | Height: 65
9 | Relative-To: top-left
10 | X: 120
11 | Y: 30
12 | end
13 |
--------------------------------------------------------------------------------
/doc/config/terminal.lnk:
--------------------------------------------------------------------------------
1 | table Icon
2 | Caption: Shell
3 | Command: lxterminal
4 | AppID: lxtermina[l]
5 | Singleton: true
6 | Icon: /usr/share/icons/gnome/48x48/apps/terminal.png
7 | HoverXOffset: 0
8 | Width: 50
9 | Height: 50
10 | Relative-To: top-left
11 | X: 220
12 | Y: 30
13 | end
14 |
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Build kano-desktop
3 | #
4 | # $ make - Builds the release version
5 | # $ make debug - Debug version (kdesk-dbg binary)
6 | #
7 | #
8 |
9 | DEBUGGING:=
10 |
11 | LIBS:=-lXft -lImlib2 -lstdc++ -lpthread -lX11 -lXss -L`pwd`/libkdesk-hourglass -lkdesk-hourglass
12 | XFTINC:=-I/usr/include/freetype2
13 | HOURGLASSINCS= -I`pwd`/libkdesk-hourglass
14 |
15 | CFLAGS=-std=c++11
16 |
17 | TARGET=kdesk
18 |
19 | .PHONY: clean
20 |
21 | all: $(TARGET)
22 |
23 | debug:
24 | make all DEBUGGING="-ggdb -DDEBUG" TARGET=kdesk-dbg
25 |
26 | # the linkage
27 | $(TARGET): main.o icon.o grid.o background.o configuration.o desktop.o sound.o ssaver.o
28 | $(CXX) $(LIBS) $^ -o $(TARGET)
29 |
30 | # the compilation
31 | icon.o: icon.cpp icon.h logging.h configuration.h grid.h
32 | $(CXX) -c $(CFLAGS) $(DEBUGGING) $(XFTINC) icon.cpp
33 |
34 | grid.o: grid.cpp grid.h
35 | $(CXX) -c $(CFLAGS) $(DEBUGGING) $(XFTINC) grid.cpp
36 |
37 | main.o: main.cpp main.h configuration.h logging.h version.h ssaver.h
38 | $(CXX) -c $(CFLAGS) $(DEBUGGING) $(XFTINC) main.cpp
39 |
40 | background.o: background.cpp logging.h sound.h
41 | $(CXX) -c $(CFLAGS) $(DEBUGGING) background.cpp
42 |
43 | configuration.o: configuration.cpp configuration.h logging.h main.h
44 | $(CXX) -c $(CFLAGS) $(DEBUGGING) configuration.cpp
45 |
46 | desktop.o: desktop.cpp desktop.h logging.h configuration.h sound.h grid.h
47 | $(CXX) -c $(CFLAGS) $(DEBUGGING) $(XFTINC) $(HOURGLASSINCS) desktop.cpp
48 |
49 | sound.o: sound.cpp sound.h
50 | $(CXX) -c $(CFLAGS) $(DEBUGGING) sound.cpp
51 |
52 | ssaver.o: ssaver.cpp ssaver.h
53 | $(CXX) -c $(CFLAGS) $(DEBUGGING) ssaver.cpp
54 |
55 | clean:
56 | -rm *o kdesk kdesk-dbg
57 |
--------------------------------------------------------------------------------
/src/background.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // background.cpp - Class to draw an icon on the desktop
3 | //
4 | // Copyright (C) 2013-2014 Kano Computing Ltd.
5 | // License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
6 | //
7 | // An app to show and bring life to Kano-Make Desktop Icons.
8 | //
9 |
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | #include "configuration.h"
18 | #include "background.h"
19 | #include "logging.h"
20 |
21 | Background::Background (Configuration *loaded_conf)
22 | {
23 | running = false;
24 | pconf = loaded_conf;
25 | }
26 |
27 | Background::~Background (void)
28 | {
29 | }
30 |
31 | bool Background::setup(Display *display)
32 | {
33 | int i, screen;
34 |
35 | // Setup X resources
36 | screen = DefaultScreen (display);
37 | vis = DefaultVisual (display, screen);
38 | cm = DefaultColormap (display, screen);
39 | root = RootWindow (display, screen);
40 | XSelectInput (display, root, StructureNotifyMask);
41 |
42 | deskw = DisplayWidth(display, screen);
43 | deskh = DisplayHeight(display, screen);
44 |
45 | // Bind resources to Imlib2
46 | imlib_context_set_display(display);
47 | imlib_context_set_visual(vis);
48 | imlib_context_set_colormap(cm);
49 |
50 | pmap = XCreatePixmap (display, root, deskw, deskh, DefaultDepth (display, DefaultScreen (display)));
51 | if (!pmap) {
52 | log ("error creating pixmap for desktop background");
53 | return false;
54 | }
55 |
56 | return true;
57 | }
58 |
59 | bool Background::load (Display *display)
60 | {
61 | int i, w, h, nx, ny, nh, nw, tmp;
62 | float ratio, dist43, dist169;
63 | double factor;
64 | string background_file;
65 | Imlib_Image tmpimg, buffer;
66 | bool bsuccess=false;
67 |
68 | buffer = imlib_create_image (deskw, deskh);
69 | if (!buffer)
70 | {
71 | log ("error creating an image surface for the background");
72 | }
73 | else
74 | {
75 | ratio = (deskw *1.0) / (deskh);
76 | dist43 = std::abs (ratio - 4.0/3.0);
77 | dist169 = std::abs (ratio - 16.0/9);
78 |
79 | // Decide which image to load depending on screen resolution and aspect/ratio
80 | unsigned int midreswidth=pconf->get_config_int ("screenmedreswidth");
81 | if (midreswidth > 0 && deskw < midreswidth) {
82 | // If a minimal medium resolution is specified, and
83 | // the screen resolution falls below this setting, then
84 | // Take the middle resolution wallpaper image
85 | background_file = pconf->get_config_string ("background.file-medium");
86 | log1 ("loading medium resolution wallpaper image", background_file);
87 | }
88 | else {
89 | //
90 | // Otherwise we are on a high resolution screen,
91 | // display the appropiate wallpaper based on the screen aspect/ratio.
92 | //
93 | if (dist43 < dist169) {
94 | background_file = pconf->get_config_string ("background.file-4-3");
95 | log1 ("loading 4:3 wallpaper image", background_file);
96 | }
97 | else {
98 | background_file = pconf->get_config_string ("background.file-16-9");
99 | log1 ("loading 16:9 wallpaper image", background_file);
100 | }
101 | }
102 |
103 | image = imlib_load_image_without_cache(background_file.c_str());
104 | if (!image) {
105 | log1 ("error loading background", background_file);
106 | }
107 | else {
108 | // Prepare imlib2 drawing spaces
109 | imlib_context_set_image(buffer);
110 | imlib_context_set_color(0,0,0,0);
111 | imlib_image_fill_rectangle(0, 0, deskw, deskh);
112 | imlib_context_set_blend(1);
113 |
114 | imlib_context_set_image(image);
115 | w = imlib_image_get_width();
116 | h = imlib_image_get_height();
117 | if (!(tmpimg = imlib_clone_image())) {
118 | log ("error cloning the desktop background image");
119 | }
120 | else {
121 | imlib_context_set_image(tmpimg);
122 | imlib_context_set_image(buffer);
123 |
124 | int screen_num = DefaultScreen(display);
125 | int nw = DisplayWidth(display, screen_num);
126 | int nh = DisplayHeight(display, screen_num);
127 |
128 | imlib_blend_image_onto_image(tmpimg, 0, 0, 0, w, h, 0, 0, nw, nh);
129 | imlib_context_set_image(tmpimg);
130 | imlib_free_image();
131 |
132 | imlib_context_set_blend(0);
133 | imlib_context_set_image(buffer);
134 | imlib_context_set_drawable(root);
135 | imlib_render_image_on_drawable(0, 0);
136 | imlib_context_set_drawable(pmap);
137 | imlib_render_image_on_drawable(0, 0);
138 | XSetWindowBackgroundPixmap(display, root, pmap);
139 |
140 | // Apply the background to the root window
141 | // so it stays permanently even if kdesk quits (-w parameter)
142 | XClearWindow (display, root);
143 | XFlush (display);
144 |
145 | // Free imlib and Xlib image resources
146 | imlib_context_set_image(buffer);
147 | imlib_free_image();
148 | imlib_context_set_image(image);
149 | imlib_free_image();
150 |
151 | XFreePixmap(display, pmap);
152 |
153 | bsuccess = true;
154 | log1 ("desktop background created successfully", image);
155 | }
156 | }
157 | }
158 |
159 | return bsuccess;
160 | }
161 |
162 | int Background::refresh_background(Display *display)
163 | {
164 | Window root_return, parent_return, *children_return;
165 | unsigned int nchildren_return=0;
166 |
167 | // Enumerate all top level windows and request a repaint
168 | // to refresh transparent areas with the new background.
169 | if (XQueryTree(display, root, &root_return, &parent_return, &children_return, &nchildren_return))
170 | {
171 | for (int i=0; i < nchildren_return; i++)
172 | {
173 | // clear the window area
174 | XClearWindow (display, children_return[i]);
175 |
176 | // repaint
177 | XEvent exppp;
178 | memset(&exppp, 0x00, sizeof(exppp));
179 | exppp.type = Expose;
180 | exppp.xexpose.window = children_return[i];
181 | XSendEvent (display, children_return[i], False, ExposureMask, &exppp);
182 | XFlush(display);
183 | }
184 | }
185 |
186 | return nchildren_return;
187 | }
188 |
--------------------------------------------------------------------------------
/src/background.h:
--------------------------------------------------------------------------------
1 | //
2 | // background.cpp - Class to draw an icon on the desktop
3 | //
4 | // Copyright (C) 2013-2014 Kano Computing Ltd.
5 | // License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
6 | //
7 | // An app to show and bring life to Kano-Make Desktop Icons.
8 | //
9 |
10 | class Background
11 | {
12 | private:
13 | Configuration *pconf;
14 | Window root;
15 | Visual *vis;
16 | Colormap cm;
17 | Pixmap pmap;
18 | Imlib_Image image;
19 | unsigned int deskw, deskh;
20 |
21 | public:
22 | bool running;
23 |
24 | public:
25 | Background (Configuration *loaded_conf);
26 | virtual ~Background (void);
27 |
28 | bool setup (Display *display);
29 | bool load (Display *display);
30 | bool draw (Display *display);
31 | int refresh_background(Display *display);
32 |
33 | };
34 |
--------------------------------------------------------------------------------
/src/configuration.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // config.cpp
3 | //
4 | // Copyright (C) 2013-2014 Kano Computing Ltd.
5 | // License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
6 | //
7 | // An app to show and bring life to Kano-Make Desktop Icons.
8 | //
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | #include "main.h"
19 | #include "configuration.h"
20 | #include "logging.h"
21 |
22 | // Name of the reserved icon filename which will always
23 | // be positioned at the last cell of the grid
24 | char *kdesk_plus_icon_filename=NULL;
25 |
26 |
27 | Configuration::Configuration()
28 | {
29 | numicons=0;
30 | }
31 |
32 | Configuration::~Configuration()
33 | {
34 | }
35 |
36 | bool Configuration::load_conf(const char *filename)
37 | {
38 | string token, value;
39 | struct stat file_status;
40 |
41 | // Check that configuration is a regular file
42 | stat (filename, &file_status);
43 | if (!S_ISREG(file_status.st_mode)) {
44 | return false;
45 | }
46 |
47 | // Open it for reading
48 | ifile.open (filename, std::ifstream::in);
49 | if (ifile.fail()) {
50 | return false;
51 | }
52 |
53 | // separate parameter - value tokens
54 | // in the form "Parameter: Value", one per line
55 | while (ifile >> token)
56 | {
57 | if (token == "FontName:") {
58 | ifile >> value;
59 | configuration["fontname"] = value;
60 | }
61 |
62 | if (token == "FontColor:") {
63 | ifile >> value;
64 | configuration["fontcolor"] = value;
65 | }
66 |
67 | if (token == "FontSize:") {
68 | ifile >> value;
69 | configuration["fontsize"] = value;
70 | }
71 |
72 | if (token == "SubtitleFontSize:") {
73 | ifile >> value;
74 | configuration["subtitlefontsize"] = value;
75 | }
76 |
77 | if (token == "Bold:") {
78 | ifile >> value;
79 | configuration["bold"] = value;
80 | }
81 |
82 | if (token == "Shadow:") {
83 | ifile >> value;
84 | configuration["shadow"] = value;
85 | }
86 |
87 | if (token == "ShadowColor:") {
88 | ifile >> value;
89 | configuration["shadowcolor"] = value;
90 | }
91 |
92 | if (token == "ShadowX:") {
93 | ifile >> value;
94 | configuration["shadowx"] = value;
95 | }
96 |
97 | if (token == "ShadowY:") {
98 | ifile >> value;
99 | configuration["shadowy"] = value;
100 | }
101 |
102 | if (token == "Background.File-4-3:") {
103 | value = get_spaced_value();
104 | configuration["background.file-4-3"] = value;
105 | }
106 |
107 | if (token == "Background.File-16-9:") {
108 | value = get_spaced_value();
109 | configuration["background.file-16-9"] = value;
110 | }
111 |
112 | if (token == "ClickDelay:") {
113 | ifile >> value;
114 | configuration["clickdelay"] = value;
115 | }
116 |
117 | if (token == "DefaultDesktopIcon:") {
118 | // Points to a png filename to be used if any lnk icons are not found.
119 | ifile >> value;
120 | configuration["defaultdesktopicon"] = value;
121 | }
122 |
123 | if (token == "IconStartDelay:") {
124 | ifile >> value;
125 | configuration["iconstartdelay"] = value;
126 | }
127 |
128 | if (token == "IconTitleGap:") {
129 | ifile >> value;
130 | configuration["icontitlegap"] = value;
131 | }
132 |
133 | if (token == "IconGapHorz:") {
134 | ifile >> value;
135 | configuration["icongaphorz"] = value;
136 | }
137 |
138 | if (token == "IconGapVert:") {
139 | ifile >> value;
140 | configuration["icongapvert"] = value;
141 | }
142 |
143 | if (token == "Transparency:") {
144 | ifile >> value;
145 | configuration["transparency"] = value;
146 | }
147 |
148 | if (token == "EnableSound:") {
149 | ifile >> value;
150 | configuration["enablesound"] = value;
151 | }
152 |
153 | if (token == "SoundWelcome:") {
154 | ifile >> value;
155 | configuration["soundwelcome"] = value;
156 | }
157 |
158 | if (token == "SoundLaunchApp:") {
159 | ifile >> value;
160 | configuration["soundlaunchapp"] = value;
161 | }
162 |
163 | if (token == "SoundDisabledIcon:") {
164 | ifile >> value;
165 | configuration["sounddisabledicon"] = value;
166 | }
167 |
168 | if (token == "Background.Delay:") {
169 | ifile >> value;
170 | configuration["background.delay"] = value;
171 | }
172 |
173 | if (token == "ScreenSaverTimeout:") {
174 | ifile >> value;
175 | configuration["screensavertimeout"] = value;
176 | log1("found ScreenSaverTimeout:", value)
177 | }
178 |
179 | if (token == "ScreenSaverProgram:") {
180 | ifile >> value;
181 | configuration["screensaverprogram"] = value;
182 | log1("found ScreenSaverProgram:", value)
183 | }
184 |
185 | if (token == "OneClick:") {
186 | ifile >> value;
187 | configuration["oneclick"] = value;
188 | }
189 |
190 | if (token == "ScreenMedResWidth:") {
191 | ifile >> value;
192 | configuration["screenmedreswidth"] = value;
193 | }
194 |
195 | if (token == "Background.File-medium:") {
196 | value = get_spaced_value();
197 | configuration["background.file-medium"] = value;
198 | }
199 |
200 | if (token == "MouseHoverIcon:") {
201 | ifile >> value;
202 | configuration["mousehovericon"] = value;
203 | }
204 |
205 | if (token == "IconHook:") {
206 | ifile >> value;
207 | configuration["iconhook"] = value;
208 | }
209 |
210 | if (token == "GridWidth:") {
211 | ifile >> value;
212 | configuration["gridwidth"] = value;
213 | }
214 |
215 | if (token == "GridHeight:") {
216 | ifile >> value;
217 | configuration["gridheight"] = value;
218 | }
219 |
220 | if (token == "GridIconWidth:") {
221 | ifile >> value;
222 | configuration["gridiconwidth"] = value;
223 | }
224 |
225 | if (token == "GridIconHeight:") {
226 | ifile >> value;
227 | configuration["gridiconheight"] = value;
228 | }
229 |
230 | if (token == "MaximizeSingleton:") {
231 | ifile >> value;
232 | configuration["maximizesingleton"] = value;
233 | }
234 |
235 | if (token == "ImageCacheSize:") {
236 | ifile >> value;
237 | configuration["imagecachesize"] = value;
238 | }
239 |
240 | if (token == "LastGridIcon:") {
241 | ifile >> value;
242 | configuration["lastgridicon"] = value;
243 |
244 | // This icon filename will be used to make sure
245 | // it is the last icon to position in the grid
246 | kdesk_plus_icon_filename = (char *) configuration["lastgridicon"].c_str();
247 | }
248 |
249 | }
250 |
251 | ifile.close();
252 | return true;
253 | }
254 |
255 | /*
256 | * If icon_filename is a svg file, it is rasterized into a png thanks to the svrg-convert tool,
257 | * saved in the user's home cache directory, and replaced automatically. The path to the cached
258 | * png file is returned. If the icon is already cached, the complete filename will be returned.
259 | *
260 | * For regular raster icons, if it cannot be found, a default one will be provided (DefaulDesktopIcon
261 | * in the .kdeskrc file). The same rule will apply if an error ocurrs converting svg files.
262 | *
263 | * If no conversion / default icon is needed, an empty string will be provided.
264 | *
265 | * This function assumes that the icon filenames are suffixed with correct extensions in lowercase (.svg, .png)
266 | *
267 | */
268 | string Configuration::convert_svg(string icon_filename)
269 | {
270 | string svg_extension=".svg";
271 | string converted;
272 |
273 | if (svg_extension.size() > icon_filename.size())
274 | return converted;
275 |
276 | // if this is a SVG file, proceed with cache a converted version
277 | if (std::equal(svg_extension.rbegin(), svg_extension.rend(), icon_filename.rbegin())) {
278 |
279 | log1("converting svg icon", icon_filename);
280 |
281 | // Locate the png file in the cache directory
282 | converted=string(getenv("HOME"));
283 | converted += "/";
284 | converted += CACHE_DIRECTORY_ICONS;
285 | converted += "/";
286 |
287 | // Extract the filename without the path
288 | const char *pathless=NULL;
289 | if (strchr(icon_filename.c_str(), '/')) {
290 | size_t i = icon_filename.find_last_of(string("/"));
291 | pathless = &icon_filename.c_str()[i+1];
292 | }
293 | else {
294 | // Icon files without a path should never happen, but just in case
295 | pathless=icon_filename.c_str();
296 | }
297 | converted += pathless;
298 |
299 | // replace filename extension svg to png
300 | size_t i = converted.find_last_of(string(".svg"));
301 | if (i != std::string::npos) {
302 | converted.replace(i - 3, 4, ".png");
303 |
304 | // is the png already cached, and is it up-to-date?
305 | struct stat info_original, info_cached;
306 | int rc_original = stat(icon_filename.c_str(), &info_original);
307 | int not_cached = stat(converted.c_str(), &info_cached);
308 |
309 | if (not_cached || ! S_ISREG(info_cached.st_mode) || ! info_cached.st_size ||
310 | // Timestamp comparision between original and cached
311 | (!rc_original && !not_cached && info_original.st_mtime > info_cached.st_mtime))
312 | {
313 | // ok, let's convert and cache it now
314 | string cmdline = SVG_PNG_CONVERTER;
315 | cmdline = SVG_PNG_CONVERTER;
316 | cmdline += " ";
317 | cmdline += icon_filename;
318 | cmdline += " --format png --output ";
319 | cmdline += converted;
320 | log1("svg conversion command", cmdline);
321 | int rc=system(cmdline.c_str());
322 |
323 | // make sure it has actually been converted succesfully
324 | memset(&info_cached, 0, sizeof(info_cached));
325 | not_cached = stat(converted.c_str(), &info_cached);
326 | if (not_cached || ! S_ISREG(info_cached.st_mode) || ! info_cached.st_size) {
327 | converted=configuration["defaultdesktopicon"];
328 | log2("error converting svg, providing a default icon - rc,icon",
329 | WEXITSTATUS(rc), converted);
330 | }
331 | else {
332 | // enforce the cached file access times
333 | struct timeval access_time;
334 | memset(&access_time, 0, sizeof(access_time));
335 | utimes(converted.c_str(), &access_time);
336 | }
337 | }
338 | else {
339 | log1("svg icon is already cached", converted);
340 | }
341 | }
342 | else {
343 | converted=configuration["defaultdesktopicon"];
344 | log1("could not find .svg extension, providing a default icon", converted);
345 | }
346 | }
347 | else {
348 | // For regular icons, provide a default icon if it cannot be found
349 | struct stat info;
350 | int icon_not_found = stat(icon_filename.c_str(), &info);
351 | if (icon_not_found || ! S_ISREG(info.st_mode) || ! info.st_size) {
352 | converted=configuration["defaultdesktopicon"];
353 | log2("icon not found, providing a default one (original, default)", icon_filename, converted);
354 | }
355 | }
356 |
357 | return converted;
358 | }
359 |
360 | /*
361 | * localize_icon()
362 | *
363 | * Try to find a localized version of the icon filename. Otherwise return the default one.
364 | * It works by querying the LANG environment variable, so it's easy to test.
365 | *
366 | * Example, given LANG is set to "es_AR.UTF-8":
367 | *
368 | * /usr/share/kano-desktop/icons/myicon.png ... would become:
369 | * /usr/share/kano-desktop/icons/i18n/es_AR/myicon.png
370 | *
371 | */
372 | string Configuration::localize_icon(string icon_filename)
373 | {
374 | // Obtain current locale, return original file if unavailable
375 | char *current_locale = getenv("LANG");
376 | if (!current_locale || !strlen(current_locale))
377 | return icon_filename;
378 | else {
379 | char *dot = strchr(current_locale, '.');
380 | if (dot)
381 | *dot = 0x00;
382 | }
383 |
384 | // Construct the path to new localized asset file
385 | std::size_t path_ext = icon_filename.find_last_of("/\\");
386 | std::string localized = icon_filename.substr(0, path_ext);
387 | std::string filename = icon_filename.substr(path_ext + 1);
388 |
389 | localized += "/i18n/";
390 | localized += current_locale;
391 | localized += "/";
392 | localized += filename;
393 |
394 | // If new localized icon cannot be found, return original one
395 | struct stat file_status;
396 | memset(&file_status, 0x00, sizeof(file_status));
397 | int rc=stat (localized.c_str(), &file_status);
398 | if (rc != 0 || !S_ISREG(file_status.st_mode)) {
399 | log1("i18n localized icon not found", localized);
400 | return icon_filename;
401 | }
402 |
403 | log1("i18n setting localized icon", localized);
404 | return localized;
405 | }
406 |
407 | bool Configuration::parse_icon (const char *directory, string fname, int iconid)
408 | {
409 | bool bsuccess=false;
410 | string lnk_extension = ".lnk";
411 | string fpath;
412 |
413 | // Only read kano-desktop LNK files.
414 | if (! (std::equal(lnk_extension.rbegin(), lnk_extension.rend(), fname.rbegin()))) {
415 | return false;
416 | }
417 |
418 | // open the icon file and parse arguments
419 | fpath = directory;
420 | fpath += "/";
421 | fpath += fname.c_str();
422 | ifile.open (fpath.c_str(), std::ifstream::in);
423 | if (!ifile.is_open()) {
424 | log1 ("could not open icon file", fpath);
425 | }
426 | else {
427 | log1 ("parsing icon file", fpath);
428 |
429 | // Process line-by-line tokens
430 | // In the form "Parameter: some values"
431 | icons[iconid]["filename"] = fname;
432 | std::string line;
433 | while (std::getline(ifile, line))
434 | {
435 | std::istringstream iss(line);
436 | std::string temp, value, token;
437 |
438 | // Collect the key name aka "token"
439 | iss >> token;
440 |
441 | // Then collect the token's value, up to EOL
442 | while (!iss.eof()) {
443 | iss >> temp;
444 | value += temp;
445 | if (!iss.eof()) value += " ";
446 | }
447 |
448 | if (token == "AppID:") {
449 | icons[iconid]["appid"] = value;
450 | }
451 |
452 | if (token == "Command:") {
453 | icons[iconid]["command"] = value;
454 | }
455 |
456 | if (token == "Icon:") {
457 |
458 | // find a localized icon asset
459 | string localized=localize_icon(value);
460 |
461 | // SVG icons are converted to png and cached.
462 | string converted=convert_svg(localized);
463 | if (converted.length()) {
464 | icons[iconid]["icon"] = converted;
465 | }
466 | else {
467 | icons[iconid]["icon"] = localized;
468 | }
469 | }
470 |
471 | if (token == "IconHover:") {
472 |
473 | // find a localized icon asset
474 | string localized=localize_icon(value);
475 |
476 | // SVG icons are converted to png and cached.
477 | string converted=convert_svg(localized);
478 | if (converted.length()) {
479 | icons[iconid]["iconhover"] = converted;
480 | }
481 | else {
482 | icons[iconid]["iconhover"] = localized;
483 | }
484 | }
485 |
486 | if (token == "IconStamp:") {
487 | icons[iconid]["iconstamp"] = value;
488 |
489 | // SVG icons are converted to png and cached.
490 | string converted=convert_svg(value);
491 | if (converted.length()) {
492 | icons[iconid]["iconstamp"] = converted;
493 | }
494 | else {
495 | icons[iconid]["iconstamp"] = value;
496 | }
497 | }
498 |
499 | if (token == "IconStatus:") {
500 |
501 | // SVG icons are converted to png and cached.
502 | string converted=convert_svg(value);
503 | if (converted.length()) {
504 | icons[iconid]["iconstatus"] = converted;
505 | }
506 | else {
507 | icons[iconid]["iconstatus"] = value;
508 | }
509 | }
510 |
511 | if (token == "HoverTransparent:") {
512 | icons[iconid]["hovertransparent"] = value;
513 | }
514 |
515 | if (token == "HoverXOffset:") {
516 | icons[iconid]["hoverxoffset"] = value;
517 | }
518 |
519 | if (token == "HoverYOffset:") {
520 | icons[iconid]["hoveryoffset"] = value;
521 | }
522 |
523 | if (token == "Caption:") {
524 |
525 | // caption supports environment variable expansion
526 | if (value[0] == '$') {
527 | value = getenv (&value[1]);
528 | }
529 |
530 | icons[iconid]["caption"] = value;
531 | }
532 |
533 | if (token == "Message:") {
534 | icons[iconid]["message"] = value;
535 | }
536 |
537 | if (token == "HAlign:") {
538 | icons[iconid]["halign"] = value;
539 | }
540 |
541 | if (token == "X:") {
542 | icons[iconid]["x"] = value;
543 | }
544 |
545 | if (token == "Y:") {
546 | icons[iconid]["y"] = value;
547 | }
548 |
549 | if (token == "Width:") {
550 | icons[iconid]["width"] = value;
551 | }
552 |
553 | if (token == "Height:") {
554 | icons[iconid]["height"] = value;
555 | }
556 |
557 | if (token == "Singleton:") {
558 | icons[iconid]["singleton"] = value;
559 | }
560 |
561 | if (token == "Relative-To:") {
562 | icons[iconid]["relative-to"] = value;
563 | }
564 |
565 | if (token == "Transparency:") {
566 | icons[iconid]["transparency"] = value;
567 | }
568 | }
569 |
570 | ifile.close();
571 | bsuccess = true;
572 | }
573 |
574 | return bsuccess;
575 | }
576 |
577 | bool Configuration::load_icons(const char *directory)
578 | {
579 | struct dirent **files;
580 | int numfiles, count;
581 | string last_grid_icon_file;
582 | char last_grid_icon_dir[256]={0};
583 |
584 | // Make sure we have a cache directory, where we keep svg converted icons
585 | struct stat info;
586 | string cache_directory=string(getenv("HOME"));
587 | cache_directory += "/";
588 | cache_directory += CACHE_DIRECTORY_ICONS;
589 |
590 | int dirstat = stat(cache_directory.c_str(), &info);
591 | if (dirstat || ! S_ISDIR(info.st_mode)) {
592 | log1("Creating kdesk cache directory", cache_directory);
593 | string cmd_create_cache=string("mkdir -p ");
594 | cmd_create_cache += cache_directory;
595 | system(cmd_create_cache.c_str());
596 | }
597 |
598 | // Read kano-desktop distributed icons first
599 | log1 ("Loading icons from directory", directory);
600 | numfiles = scandir (directory, &files, 0, 0);
601 | for (count=0; count < numfiles && numicons <= MAX_ICONS; count++)
602 | {
603 | string f = files[count]->d_name;
604 | if (kdesk_plus_icon_filename && !strcmp(f.c_str(), kdesk_plus_icon_filename)) {
605 | last_grid_icon_file=f;
606 | strcpy(last_grid_icon_dir, directory);
607 | continue;
608 | }
609 |
610 | if (parse_icon (directory, f, numicons) == true) {
611 | numicons++;
612 | }
613 | }
614 |
615 | // Read icons located at the user's home directory
616 | char *env_display = getenv ("HOME");
617 | string kdesk_homedir = env_display + string("/");
618 | kdesk_homedir += DIR_KDESKTOP_USER;
619 | log1 ("Loading icons from homedir", kdesk_homedir);
620 | numfiles = scandir (kdesk_homedir.c_str(), &files, 0, 0);
621 | for (count=0; count < numfiles && numicons <= MAX_ICONS; count++)
622 | {
623 | string f = files[count]->d_name;
624 | if (kdesk_plus_icon_filename && !strcmp(f.c_str(), kdesk_plus_icon_filename)) {
625 | last_grid_icon_file=f;
626 | strcpy(last_grid_icon_dir, kdesk_homedir.c_str());
627 | continue;
628 | }
629 |
630 | if (parse_icon (kdesk_homedir.c_str(), f, numicons) == true) {
631 |
632 | // Put a mark that this is a user-defined icon
633 | icons[numicons]["usericon"] = "true";
634 |
635 | numicons++;
636 | }
637 | }
638 |
639 | if (last_grid_icon_file.length()) {
640 | log1 ("Adding a last_grid_icon: ", last_grid_icon_file);
641 |
642 | // add the last grid icon at the end of the list
643 | if (parse_icon (last_grid_icon_dir, last_grid_icon_file, numicons) == true) {
644 | numicons++;
645 | }
646 | }
647 |
648 | log2 ("Number of icons loaded, max permitted", numicons, MAX_ICONS);
649 | return (bool) (count > 0);
650 | }
651 |
652 | string Configuration::get_config_string(string item)
653 | {
654 | string value = configuration[item];
655 | return value;
656 | }
657 |
658 | unsigned int Configuration::get_config_int(string item)
659 | {
660 | string value = configuration[item];
661 | return atoi(value.c_str());
662 | }
663 |
664 | std::string Configuration::get_icon_string(int iconid, std::string key)
665 | {
666 | string value = icons[iconid][key];
667 | return value;
668 | }
669 |
670 | int Configuration::get_icon_int(int iconid, std::string key)
671 | {
672 | string value = icons[iconid][key];
673 | return atoi(value.c_str());
674 | }
675 |
676 | int Configuration::get_numicons(void)
677 | {
678 | return numicons;
679 | }
680 |
681 | std::string Configuration::get_spaced_value(void)
682 | {
683 | std::string value;
684 |
685 | // get the value until end of line
686 | std::getline (ifile, value);
687 |
688 | // trim leading and trailing spaces
689 | value.erase (0, value.find_first_not_of (' '));
690 | value.erase (value.find_last_not_of (' ') + 1);
691 |
692 | return value;
693 | }
694 |
695 | void Configuration::dump()
696 | {
697 | log ("dumping MAP configuration values");
698 | std::map::iterator it;
699 | for (it=configuration.begin(); it != configuration.end(); ++it)
700 | {
701 | log2 ("configuration item", it->first, it->second);
702 | }
703 |
704 | log1 ("dumping all loaded icons:", numicons);
705 | for (int c=0; c < numicons; c++) {
706 | log1 ("dumping icon file:", icons[c]["filename"]);
707 | for (it=icons[c].begin(); it != icons[c].end(); ++it)
708 | {
709 | log2 ("icon key", it->first, it->second);
710 | }
711 | }
712 | }
713 |
714 | void Configuration::reset(void)
715 | {
716 | // Erase each key->value pair for the global configuration map
717 | configuration.erase(configuration.begin(), configuration.end());
718 |
719 | // Then clear the map list
720 | configuration.clear();
721 | reset_icons();
722 | }
723 |
724 | void Configuration::reset_icons(void)
725 | {
726 | for (int c=0; c < numicons; c++) {
727 | // Erase each key->value entry for all the icons
728 | icons[c].erase(icons[c].begin(), icons[c].end());
729 | }
730 |
731 | icons.clear();
732 | numicons = 0;
733 | }
734 |
735 |
--------------------------------------------------------------------------------
/src/configuration.h:
--------------------------------------------------------------------------------
1 | //
2 | // config.h
3 | //
4 | // Copyright (C) 2013-2014 Kano Computing Ltd.
5 | // License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
6 | //
7 | // An app to show and bring life to Kano-Make Desktop Icons.
8 | //
9 |
10 | #include
11 | #include
12 | #include