├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── pack ├── cpack_debs.cmake └── create_appimage.sh ├── res ├── anim │ └── loading.gif ├── images │ ├── appimage.svg │ ├── application-x-executable.svg │ ├── dialog-information.svg │ └── document-download.svg └── res.qrc ├── src ├── CMakeLists.txt ├── config │ ├── CMakeLists.txt │ ├── FirstRunConfig.cpp │ ├── FirstRunConfig.h │ ├── GreeterDialog.cpp │ ├── GreeterDialog.h │ ├── GreeterDialog.ui │ ├── UserAppsMonitorConfig.cpp │ ├── UserAppsMonitorConfig.h │ ├── main.cpp │ └── org.appimage.desktop-integration-tool.desktop ├── core │ ├── CMakeLists.txt │ ├── Deployer.cpp │ ├── Deployer.h │ ├── Executor.cpp │ ├── Executor.h │ ├── Registry.cpp │ ├── Registry.h │ ├── Validator.cpp │ ├── Validator.h │ └── test │ │ ├── CMakeLists.txt │ │ ├── TestRegistry.cpp │ │ ├── data │ │ ├── appimages │ │ │ ├── echo-x86_64-8.25.AppImage │ │ │ ├── fake_appimage │ │ │ └── printf_binary │ │ ├── applications │ │ │ └── appimagekit_e660685f087766d437de39ef24d9d64c-echo.desktop │ │ ├── icons │ │ │ └── appimagekit_e660685f087766d437de39ef24d9d64c_utilities-terminal.svg │ │ └── user_apps_monitor.conf │ │ └── main.cpp ├── first_run │ ├── CMakeLists.txt │ ├── gui │ │ ├── DeploymentDialog.cpp │ │ ├── DeploymentDialog.h │ │ ├── DeploymentDialog.ui │ │ ├── UiController.cpp │ │ ├── UiController.h │ │ ├── UnsecureAppimageDialog.cpp │ │ ├── UnsecureAppimageDialog.h │ │ ├── UnsecureAppimageDialog.ui │ │ ├── ValidationDialog.cpp │ │ ├── ValidationDialog.h │ │ └── ValidationDialog.ui │ ├── main.cpp │ └── org.appimage.first_run.desktop └── user_apps_monitor │ ├── CMakeLists.txt │ ├── Monitor.cpp │ ├── Monitor.h │ ├── main.cpp │ └── org.appimage.user_app_monitor.desktop └── third-party ├── gtest.cmake └── libappimage.cmake /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | moc_*.h 24 | qrc_*.cpp 25 | ui_*.h 26 | Makefile* 27 | *build-* 28 | 29 | # QtCreator 30 | 31 | *.autosave 32 | 33 | # QtCtreator Qml 34 | *.qmlproject.user 35 | *.qmlproject.user.* 36 | 37 | # QtCtreator CMake 38 | CMakeLists.txt.user* 39 | 40 | # Clion 41 | .idea 42 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: gcc 3 | sudo: required 4 | dist: trusty 5 | addons: 6 | apt: 7 | sources: 8 | - ubuntu-toolchain-r-test 9 | - sourceline: ppa:beineri/opt-qt-5.10.1-trusty 10 | - sourceline: deb http://ftp.de.debian.org/debian/ jessie main contrib non-free 11 | packages: 12 | - qt510base 13 | - librsvg2-bin 14 | - libfuse-dev 15 | - desktop-file-utils 16 | - patchelf 17 | notifications: 18 | email: false 19 | slack: 20 | secure: srgFCmnctYePogQx1BtGM1Kk4pX4A5t0fBBE/3zvxY78bYS17QiNXvHaCkl6+n+xwKU8WkPeFT1mnSEond0QmAnjPVKMLZDnOzrBwkGm6zWVrxsMolJ7dG6IcPftiwbtK8pLZvnOGy63MrVqsrcZ5kfR4UcDeim1iaScDviFo6O/YDbyNhkq65JiwULembDqsCzJ9Vqqcc4dMsbtCSfJJh+L1dEbOhKEEhdLSuDoDKeAEg2TKaBY5aZr1hxZstepkFs7AkeEm6Ys6d07Z10klJgnaDSPQBSIyGiq42NOXgHpJyUAOXbHg2H1H7qWm++3dJOhYhKJwM+wfDWXVUcklDFYrgPDIdi4Y/9L7Jgyncc1qMg3xV5tGGg+3mWors9tlvLOPFEYLWvK413LeeTsbOZDdIWpSLtil+8eNLKd2rRVDLPobw1K8Vru4zE4yJU/D+TG4b+st27yIgc95zbA6fMJ78k72+y8ko2Sl3HXvVdRP1XAf1QmiZnxkIjo1ebPd4w3O5qbfcNxmRE3pcLmCzvyrNioCmZLipc7XJCCyGyPWH3EBLDvwhdqg3oUpHD3UOVkq5MDoA58vlvJwfD/SQEadXI/8vCliep6ehFFLDgZiiUcXHkFI5+NKFZRGG+jns9rM3r0BeJraZHJh6byqF2tEF5r+8uQvFMjiYgQNgQ= 21 | script: 22 | - source /opt/qt*/bin/qt*-env.sh 23 | - cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr 24 | - make -j$(nproc) 25 | - cpack 26 | - pack/create_appimage.sh 27 | after_success: 28 | - curl --upload-file *first-run*.deb https://transfer.sh/ 29 | - curl --upload-file *user-apps-monitor*.deb https://transfer.sh/ 30 | - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh 31 | - bash upload.sh apppimage-desktop-integration*deb AppImage_Desktop_Integration_Tool-*.AppImage* 32 | branches: 33 | except: 34 | - 35 | - "/^(?i:continuous)/" 36 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | project(appimage-desktop-integration) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | add_subdirectory(src) 7 | 8 | include(pack/cpack_debs.cmake) 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Appimage Desktop Integration Tools [![Build Status](https://travis-ci.org/nomad-desktop/appimage-desktop-integration.svg?branch=master)](https://travis-ci.org/nomad-desktop/appimage-desktop-integration) 2 | 3 | Optional set of tools to assist users at verifying, activating, deploying and removing applications packaged as AppImage. 4 | 5 | 6 | ## Premise: 7 | - AppImage applications _trust_ is defined by the presence (or not) of the executable bit. 8 | - A **non-executable** AppImage file is an _untrusted_ (read: potentially dangerous) application. It should only be executed by a sandboxing utility (for example firejail). 9 | - An executable AppImage file is (with explicit permission from the user) a _trusted_ and safe application. 10 | - AppImage applications desktop integration is defined by the location of the file in `/Applications` or 11 | `/opt/Applications`. Such applications will be considered as "deployed". This means that it will be added to the desktop 12 | menu by coping its ".Desktop" file and icon to their respective XDG locations. 13 | - An AppImage file in `/Applications` is available only for the current user. 14 | - An AppImage file in `/opt/Applications` is available for all users. 15 | - A **non-executable** AppImage file in` /Applications` or `/opt/Applications` is still considered _untrusted_ its ".Desktop" file will be deployed but it must be modified to execute the application inside a sandboxing utility. 16 | 17 | 18 | ## Workflow 19 | A. Executing an AppImage: 20 | 1. Download a binary file. 21 | 2. Open it in your file browser (or in the terminal with `xdg-open`). 22 | 3. Wait for the signature verification to be completed. 23 | 4. Click _Trust_. 24 | 5. Click _Run_. 25 | 26 | B. Executing an AppImage in sandbox: 27 | 1. Download binary file. 28 | 2. Open it in your file browser (or in the terminal with `xdg-open`) 29 | 3. Wait for the signature verification to be completed. 30 | 5. Click _Run in Sandbox_. 31 | 32 | C. Deploy AppImage (using the first run utility): 33 | 1. Download binary file. 34 | 2. Open it in your file browser (or in the terminal with `xdg-open`) 35 | 3. Wait for the signature verification to be completed. 36 | 5. Click _Deploy_. 37 | 38 | D. Deploy AppImage (using the Applications dir): 39 | 1. Download binary file. 40 | 2. Copy it to `/Applications`. 41 | 3. Wait for the signature verification to be completed. 42 | 43 | E. Remove AppImage 44 | 1. Remoge AppImage file. 45 | 46 | 47 | ## AppImage First Run 48 | 49 | This aims to ease the verification and integration of newly downloaded appimages. The user is warned about the danger of using unreliable binaries. It allows to: 50 | 51 | - To deploy the applications .desktop file and icons. 52 | - To test the application by executing it once. 53 | - To trust (set executable permission to the file) 54 | 55 | ![appimagekitr](https://raw.githubusercontent.com/azubieta/appimage-desktop-integration/screenshots/screenshots/first_run_unsecure_appimage.png) 56 | 57 | 58 | ## User Applications Monitor 59 | 60 | This aims to allow simple integration of appimages by monitoring a "desktop integrated" `Applications` folder, where 61 | the users can just copy the applications that they'd want and have them available from start menus and as mime-type handlers. 62 | 63 | ## AppImage Desktop Integration configuration UI 64 | 65 | Provides a simple interface to deploy and monitor the mentioned tools. 66 | 67 | ![appimagekitr](https://github.com/azubieta/appimage-desktop-integration/blob/screenshots/screenshots/config.png?raw=true) 68 | 69 | # Issues 70 | If you find problems with the contents of this repository please create an issue. 71 | 72 | ©2018 Nitrux Latinoamericana S.C. 73 | -------------------------------------------------------------------------------- /pack/cpack_debs.cmake: -------------------------------------------------------------------------------- 1 | # required for DEB-DEFAULT to work as intended 2 | cmake_minimum_required(VERSION 3.6) 3 | 4 | set(PROJECT_VERSION 1.0) 5 | set(CPACK_GENERATOR "DEB") 6 | 7 | set(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION}) 8 | 9 | # determine Git commit ID 10 | execute_process( 11 | COMMAND git rev-parse --short HEAD 12 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 13 | OUTPUT_VARIABLE GIT_COMMIT 14 | OUTPUT_STRIP_TRAILING_WHITESPACE 15 | ) 16 | 17 | message("GIT_COMMIT: ${GIT_COMMIT}") 18 | set(CPACK_DEBIAN_PACKAGE_RELEASE "git${GIT_COMMIT}") 19 | 20 | if (DEFINED ENV{ARCH}) 21 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE $ENV{ARCH}) 22 | if (CPACK_DEBIAN_PACKAGE_ARCHITECTURE MATCHES "i686") 23 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386") 24 | endif () 25 | endif () 26 | 27 | message("CPACK_DEBIAN_PACKAGE_ARCHITECTURE: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") 28 | 29 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alexis Lopez Zubieta") 30 | set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/azubieta/appimage-desktop-integration") 31 | set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) 32 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") 33 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") 34 | 35 | set(CPACK_DEBIAN_FIRST-RUN_PACKAGE_DEPENDS "libqt5core5a, libqt5widgets5, libappimage, libarchive13, libc6 (>= 2.4), libglib2.0-0, zlib1g, fuse") 36 | set(CPACK_COMPONENT_FIRST-RUN_DESCRIPTION "First run utility\n Use it to handle newly downloaded appimages. Allow to verify and deploy desktop integration files.") 37 | 38 | 39 | set(CPACK_DEBIAN_USER-APPS-MONITOR_PACKAGE_DEPENDS "libappimage, libarchive13, libc6 (>= 2.4), libglib2.0-0, zlib1g, fuse") 40 | set(CPACK_COMPONENT_USER-APPS-MONITOR_DESCRIPTION " 41 | Monitor appimage files.\n Monitor appimage files in HOME/Applications and /opt/applications to create or remove proper desktop integration files.") 42 | 43 | 44 | set(CPACK_COMPONENTS_ALL first-run user-apps-monitor config) 45 | set(CPACK_DEB_COMPONENT_INSTALL ON) 46 | 47 | include(CPack) -------------------------------------------------------------------------------- /pack/create_appimage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | build_scripts_dir=`dirname $0` 4 | source_dir=`dirname $build_scripts_dir` 5 | 6 | DESTDIR=appdir make install 7 | cp ${source_dir}/res/images/appimage.svg appdir 8 | 9 | patchelf --set-rpath '$ORIGIN/../lib/' appdir/usr/bin/appimage_first_run 10 | patchelf --set-rpath '$ORIGIN/../lib/' appdir/usr/bin/user_apps_monitor 11 | 12 | wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" 13 | chmod a+x linuxdeployqt-continuous-x86_64.AppImage 14 | 15 | unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH 16 | 17 | export VERSION=$(git rev-parse --short HEAD) # linuxdeployqt uses this for naming the file 18 | 19 | ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/org.appimage.desktop-integration-tool.desktop -bundle-non-qt-libs -appimage 20 | -------------------------------------------------------------------------------- /res/anim/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nitrux/appimage-desktop-integration/44f721783ec90327de03c30e97abd6cf0806c0de/res/anim/loading.gif -------------------------------------------------------------------------------- /res/images/appimage.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 30 | 32 | 36 | 40 | 41 | 51 | 53 | 57 | 61 | 62 | 72 | 74 | 78 | 82 | 83 | 94 | 96 | 100 | 104 | 105 | 116 | 118 | 122 | 126 | 127 | 137 | 139 | 143 | 147 | 148 | 158 | 160 | 164 | 168 | 169 | 179 | 181 | 185 | 189 | 190 | 198 | 200 | 204 | 208 | 212 | 213 | 214 | 233 | 235 | 236 | 238 | image/svg+xml 239 | 241 | 242 | 243 | 244 | 245 | 249 | 253 | 257 | 264 | 272 | 279 | 280 | 281 | 290 | 294 | 298 | 302 | 311 | 315 | 319 | 320 | 321 | -------------------------------------------------------------------------------- /res/images/dialog-information.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 25 | 29 | 33 | 37 | 38 | 48 | 59 | 70 | 71 | 94 | 97 | 102 | 107 | 112 | 117 | 122 | 127 | 132 | 137 | 138 | 140 | 141 | 143 | image/svg+xml 144 | 146 | 147 | 148 | 149 | 150 | 155 | 399 | 405 | 411 | 417 | 423 | 429 | 434 | 435 | 436 | -------------------------------------------------------------------------------- /res/images/document-download.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 28 | 29 | 52 | 56 | 63 | 70 | 77 | 84 | 85 | 87 | 88 | 90 | image/svg+xml 91 | 93 | 94 | 95 | 96 | 97 | 102 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /res/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | anim/loading.gif 4 | images/appimage.svg 5 | images/dialog-information.svg 6 | images/application-x-executable.svg 7 | images/document-download.svg 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # LibAppimage 2 | include(../third-party/libappimage.cmake) 3 | install(FILES ${libappimage_PATH} DESTINATION lib COMPONENT libappimage) 4 | 5 | # Qt 6 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 7 | set(CMAKE_AUTOMOC ON) 8 | 9 | find_package(Qt5Core) 10 | 11 | # Targets 12 | add_subdirectory(config) 13 | add_subdirectory(core) 14 | add_subdirectory(first_run) 15 | add_subdirectory(user_apps_monitor) -------------------------------------------------------------------------------- /src/config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(CMAKE_AUTOUIC ON) 2 | set(CMAKE_AUTORCC ON) 3 | 4 | find_package(Qt5 COMPONENTS Gui Widgets) 5 | 6 | add_executable(appimage-desktop-integration-config 7 | main.cpp 8 | GreeterDialog.h 9 | GreeterDialog.cpp 10 | GreeterDialog.ui 11 | FirstRunConfig.cpp 12 | FirstRunConfig.h 13 | UserAppsMonitorConfig.h 14 | UserAppsMonitorConfig.cpp 15 | ) 16 | 17 | target_include_directories(appimage-desktop-integration-config PRIVATE 18 | PRIVATE ${CMAKE_SOURCE_DIR}/src/core 19 | ) 20 | 21 | target_link_libraries(appimage-desktop-integration-config Qt5::Core Qt5::Gui Qt5::Widgets) 22 | 23 | install(TARGETS appimage-desktop-integration-config RUNTIME DESTINATION bin COMPONENT config) 24 | install(FILES org.appimage.desktop-integration-tool.desktop DESTINATION share/applications COMPONENT config) -------------------------------------------------------------------------------- /src/config/FirstRunConfig.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 3/21/18. 3 | // 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "FirstRunConfig.h" 9 | 10 | bool FirstRunConfig::isEnabled() { 11 | const auto configPaths = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation); 12 | for (const QString applicationsDir: configPaths) { 13 | QDir dir(applicationsDir); 14 | auto entries = dir.entryList({"org.appimage.desktop-integration-first-run.desktop"}); 15 | if (!entries.isEmpty()) 16 | return true; 17 | } 18 | 19 | return false; 20 | } 21 | 22 | void FirstRunConfig::enable() { 23 | auto appimage = qgetenv("APPIMAGE"); 24 | QString filePath = getDesktopFilePath(); 25 | 26 | QFile file(filePath); 27 | if (file.open(QIODevice::WriteOnly)) { 28 | file.write("[Desktop Entry]\n" 29 | "Type=Application\n" 30 | "Icon=appimage\n" 31 | "MimeType=application/x-iso9660-appimage;application/vnd.appimage;\n" 32 | "Categories=System;\n" 33 | "Name=Appimage First Run Utility\n" 34 | "Comment=First run utility to verify and deploy desktop integration files for Appimages.\n" 35 | "NoDisplay=true\n"); 36 | file.write("Exec=" + appimage + " --open %F\n" 37 | "TryExec=" + appimage + "\n"); 38 | 39 | file.close(); 40 | } 41 | } 42 | 43 | QString FirstRunConfig::getDesktopFilePath() const { 44 | auto filePath = QDir::homePath() + "/.local/share/applications/org.appimage.desktop-integration-first-run.desktop"; 45 | return filePath; 46 | } 47 | 48 | void FirstRunConfig::disable() { 49 | QFile::remove(getDesktopFilePath()); 50 | } 51 | -------------------------------------------------------------------------------- /src/config/FirstRunConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 3/21/18. 3 | // 4 | 5 | #ifndef APPPIMAGE_DESKTOP_INTEGRATION_FIRSTRUNCONFIG_H 6 | #define APPPIMAGE_DESKTOP_INTEGRATION_FIRSTRUNCONFIG_H 7 | 8 | 9 | class FirstRunConfig { 10 | public: 11 | bool isEnabled(); 12 | 13 | void enable(); 14 | 15 | void disable(); 16 | 17 | private: 18 | QString getDesktopFilePath() const; 19 | }; 20 | 21 | 22 | #endif //APPPIMAGE_DESKTOP_INTEGRATION_FIRSTRUNCONFIG_H 23 | -------------------------------------------------------------------------------- /src/config/GreeterDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "GreeterDialog.h" 2 | #include "ui_GreeterDialog.h" 3 | #include "UserAppsMonitorConfig.h" 4 | 5 | GreeterDialog::GreeterDialog(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::GreeterDialog) 8 | { 9 | ui->setupUi(this); 10 | connect(&ticker, &QTimer::timeout, this, &GreeterDialog::updateMessages); 11 | ticker.setInterval(1000); 12 | ticker.start(); 13 | 14 | pastMonitorStatus = UserAppsMonitorConfig::isRunning(); 15 | updateMessages(); 16 | } 17 | 18 | GreeterDialog::~GreeterDialog() 19 | { 20 | delete ui; 21 | } 22 | 23 | void GreeterDialog::on_pushButtonClose_released() 24 | { 25 | close(); 26 | } 27 | 28 | void GreeterDialog::on_pushButtonDisableAll_released() 29 | { 30 | if (firstRunConfig.isEnabled()) 31 | firstRunConfig.disable(); 32 | 33 | if (UserAppsMonitorConfig::isEnabled()) 34 | UserAppsMonitorConfig::disable(); 35 | 36 | if (UserAppsMonitorConfig::isRunning()) 37 | UserAppsMonitorConfig::stop(); 38 | } 39 | 40 | void GreeterDialog::on_pushButtonEnableAll_released() 41 | { 42 | if (!firstRunConfig.isEnabled()) 43 | firstRunConfig.enable(); 44 | 45 | if (!UserAppsMonitorConfig::isEnabled()) 46 | UserAppsMonitorConfig::enable(); 47 | 48 | if (!UserAppsMonitorConfig::isRunning()) 49 | UserAppsMonitorConfig::start(); 50 | } 51 | 52 | void GreeterDialog::updateMessages() 53 | { 54 | bool firstRunEnabled = firstRunConfig.isEnabled(); 55 | 56 | bool monitorEnabled = UserAppsMonitorConfig::isEnabled(); 57 | bool monitorRunning = UserAppsMonitorConfig::isRunning(); 58 | 59 | ui->checkBoxFirstRun->setChecked(firstRunEnabled); 60 | 61 | ui->checkBoxMonitorAutostart->setChecked(monitorEnabled); 62 | 63 | ui->pushButtonMonitorStatus->setEnabled(true); 64 | if (monitorRunning) { 65 | ui->label_MonitorStatus->setText(tr("The application dir monitor is running")); 66 | ui->pushButtonMonitorStatus->setText(tr("Stop")); 67 | } else { 68 | ui->label_MonitorStatus->setText(tr("The application dir monitor is stopped")); 69 | ui->pushButtonMonitorStatus->setText(tr("Start")); 70 | } 71 | } 72 | 73 | 74 | void GreeterDialog::on_pushButtonMonitorStatus_released() 75 | { 76 | ui->pushButtonMonitorStatus->setEnabled(false); 77 | 78 | if (UserAppsMonitorConfig::isRunning()) { 79 | UserAppsMonitorConfig::stop(); 80 | ui->label_MonitorStatus->setText(tr("The application dir monitor stop requested")); 81 | } else { 82 | UserAppsMonitorConfig::start(); 83 | ui->label_MonitorStatus->setText(tr("The application dir monitor start requested")); 84 | } 85 | } 86 | 87 | void GreeterDialog::on_checkBoxMonitorAutostart_stateChanged(int arg1) 88 | { 89 | if (arg1) 90 | UserAppsMonitorConfig::enable(); 91 | else 92 | UserAppsMonitorConfig::disable(); 93 | } 94 | 95 | void GreeterDialog::on_checkBoxFirstRun_stateChanged(int arg1) 96 | { 97 | if (arg1) 98 | firstRunConfig.enable(); 99 | else 100 | firstRunConfig.disable(); 101 | } 102 | -------------------------------------------------------------------------------- /src/config/GreeterDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef GREETERDIALOG_H 2 | #define GREETERDIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | #include "FirstRunConfig.h" 8 | 9 | namespace Ui { 10 | class GreeterDialog; 11 | } 12 | 13 | class GreeterDialog : public QDialog 14 | { 15 | Q_OBJECT 16 | 17 | QTimer ticker; 18 | bool pastMonitorStatus; 19 | public: 20 | explicit GreeterDialog(QWidget *parent = 0); 21 | ~GreeterDialog(); 22 | 23 | private slots: 24 | void on_pushButtonClose_released(); 25 | 26 | void on_pushButtonDisableAll_released(); 27 | 28 | void on_pushButtonEnableAll_released(); 29 | 30 | void on_checkBoxMonitorAutostart_stateChanged(int arg1); 31 | 32 | void on_checkBoxFirstRun_stateChanged(int arg1); 33 | 34 | void on_pushButtonMonitorStatus_released(); 35 | 36 | void updateMessages(); 37 | 38 | private: 39 | Ui::GreeterDialog *ui; 40 | FirstRunConfig firstRunConfig; 41 | }; 42 | 43 | #endif // GREETERDIALOG_H 44 | -------------------------------------------------------------------------------- /src/config/GreeterDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GreeterDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 432 10 | 371 11 | 12 | 13 | 14 | Appimage Desktop Integration Tool 15 | 16 | 17 | 18 | 19 | 20 | First Run Assistant 21 | 22 | 23 | 24 | 25 | 26 | Allows to verify integrity and authenticity of untrusted AppImages. Also allows its desktop integration. 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | Qt::LeftToRight 37 | 38 | 39 | Active 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Applications Directory 50 | 51 | 52 | 53 | 54 | 55 | 56 | 100 57 | 16777215 58 | 59 | 60 | 61 | Start 62 | 63 | 64 | false 65 | 66 | 67 | false 68 | 69 | 70 | 71 | 72 | 73 | 74 | The application dir monitor is <b>stopped</b> 75 | 76 | 77 | 78 | 79 | 80 | 81 | Monitor the $HOME/Applications directory in order to create or remove the required desktop integration files for the AppImage files contained there. 82 | 83 | 84 | true 85 | 86 | 87 | 88 | 89 | 90 | 91 | Start at login 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | Close 104 | 105 | 106 | 107 | 108 | 109 | 110 | Qt::Horizontal 111 | 112 | 113 | 114 | 40 115 | 20 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | Disable All 124 | 125 | 126 | 127 | 128 | 129 | 130 | Enable All 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /src/config/UserAppsMonitorConfig.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 3/22/18. 3 | // 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "UserAppsMonitorConfig.h" 10 | #include "FirstRunConfig.h" 11 | 12 | bool UserAppsMonitorConfig::isRunning() { 13 | return getPID() != -1; 14 | } 15 | 16 | int UserAppsMonitorConfig::getPID() { 17 | QProcess ps; 18 | ps.start("ps -o pid= -C user_apps_monitor"); 19 | ps.closeWriteChannel(); 20 | ps.waitForFinished(); 21 | 22 | QString result = ps.readAll().trimmed(); 23 | if (result.isEmpty()) 24 | return -1; 25 | else 26 | return result.toInt(); 27 | } 28 | 29 | void UserAppsMonitorConfig::start() { 30 | auto appimage = qgetenv("APPDIR"); 31 | auto monitorPath = appimage + "/usr/bin/user_apps_monitor"; 32 | 33 | qWarning() << monitorPath; 34 | QProcess::startDetached(monitorPath); 35 | } 36 | 37 | void UserAppsMonitorConfig::stop() { 38 | int pid = getPID(); 39 | 40 | if (pid > 0) 41 | QProcess::startDetached("/bin/kill", {QString::number(pid, 10)}); 42 | } 43 | 44 | bool UserAppsMonitorConfig::isEnabled() { 45 | bool xdgAutoStart = QFile::exists(getXDGPath()); 46 | bool configAutoStart = QFile::exists(getDesktopFilePath()); 47 | 48 | return xdgAutoStart != configAutoStart; 49 | } 50 | 51 | void UserAppsMonitorConfig::enable() { 52 | auto appimage = qgetenv("APPIMAGE"); 53 | QString filePath = getDesktopFilePath(); 54 | 55 | QString xdgPath = getXDGPath(); 56 | 57 | if (QFile::exists(xdgPath)) 58 | QFile::remove(filePath); 59 | else 60 | createDesktopFile(appimage, filePath); 61 | } 62 | 63 | void UserAppsMonitorConfig::createDesktopFile(const QByteArray &appimage, const QString &filePath) { 64 | QFile file(filePath); 65 | if (file.open(QIODevice::WriteOnly)) { 66 | file.write("[Desktop Entry]\n" 67 | "Type=Application\n" 68 | "Icon=appimage\n" 69 | "Categories=System;\n" 70 | "Name=Appimage User Applications Monitor\n" 71 | "Comment=Monitor appimage files in HOME/Applications and /opt/applications to create or " 72 | "remove proper desktop integration files.\n" 73 | "NoDisplay=true\n"); 74 | file.write("Exec=" + appimage + " --monitor\n" 75 | "TryExec=" + appimage + "\n"); 76 | 77 | file.close(); 78 | } 79 | } 80 | 81 | QString UserAppsMonitorConfig::getDesktopFilePath() { 82 | auto filePath = QDir::homePath() + "/.config/autostart/" + getDesktopFileName(); 83 | return filePath; 84 | } 85 | 86 | void UserAppsMonitorConfig::disable() { 87 | const auto path = getDesktopFilePath(); 88 | QString xdgPath = getXDGPath(); 89 | 90 | if (QFile::exists(xdgPath)) 91 | createDesktopFile("", path); 92 | else 93 | QFile::remove(getDesktopFilePath()); 94 | } 95 | 96 | QString UserAppsMonitorConfig::getXDGPath() { 97 | const auto xdgPath = "/etc/xdg/autostart/" + getDesktopFileName(); 98 | return xdgPath; 99 | } 100 | 101 | const QString 102 | UserAppsMonitorConfig::getDesktopFileName() { return "org.appimage.desktop-integration-apps-dir-monitor.desktop"; } 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/config/UserAppsMonitorConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 3/22/18. 3 | // 4 | 5 | #ifndef APPPIMAGE_DESKTOP_INTEGRATION_USERAPPSMONITORCONFIG_H 6 | #define APPPIMAGE_DESKTOP_INTEGRATION_USERAPPSMONITORCONFIG_H 7 | 8 | 9 | class UserAppsMonitorConfig { 10 | public: 11 | static bool isRunning(); 12 | static int getPID(); 13 | 14 | static void start(); 15 | static void stop(); 16 | 17 | 18 | 19 | static bool isEnabled(); 20 | 21 | static void enable(); 22 | 23 | static QString getDesktopFilePath() ; 24 | 25 | static void disable(); 26 | 27 | static const QString getDesktopFileName(); 28 | 29 | static void createDesktopFile(const QByteArray &appimage, const QString &filePath) ; 30 | 31 | static QString getXDGPath() ; 32 | }; 33 | 34 | 35 | #endif //APPPIMAGE_DESKTOP_INTEGRATION_USERAPPSMONITORCONFIG_H 36 | -------------------------------------------------------------------------------- /src/config/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "GreeterDialog.h" 9 | 10 | 11 | QCommandLineParser *createCommandLineParser(const QCoreApplication &app); 12 | 13 | void startMonitor(); 14 | 15 | void openAppimage(const QString &target); 16 | 17 | void showConfig(GreeterDialog *dialog); 18 | 19 | int main(int argc, char **argv) { 20 | QApplication app(argc, argv); 21 | QApplication::setApplicationName("appimage-desktop-integration-tool"); 22 | 23 | QCommandLineParser *parser = createCommandLineParser(app); 24 | const QStringList args = parser->positionalArguments(); 25 | 26 | if (parser->isSet("monitor")) { 27 | startMonitor(); 28 | return 0; 29 | } else if (parser->isSet("open")) { 30 | QString path = parser->value("open"); 31 | openAppimage(path); 32 | 33 | return 0; 34 | } else { 35 | GreeterDialog *dialog; 36 | showConfig(dialog); 37 | return app.exec(); 38 | } 39 | } 40 | 41 | void showConfig(GreeterDialog *dialog) { 42 | dialog = new GreeterDialog(); 43 | dialog->show(); 44 | } 45 | 46 | void openAppimage(const QString &target) { 47 | auto appimage = qgetenv("APPDIR"); 48 | auto firstRunPath = appimage + "/usr/bin/appimage_first_run"; 49 | 50 | QProcess::startDetached(firstRunPath, {target}); 51 | } 52 | 53 | void startMonitor() { 54 | if (!UserAppsMonitorConfig::isRunning()) 55 | UserAppsMonitorConfig::start(); 56 | } 57 | 58 | QCommandLineParser *createCommandLineParser(const QCoreApplication &app) { 59 | QCommandLineParser *parser = new QCommandLineParser(); 60 | parser->setApplicationDescription(QObject::tr("AppImage Desktop Integration tool")); 61 | parser->addHelpOption(); 62 | 63 | parser->addOption({{"c", "config"}, "Show configuration dialog"}); 64 | parser->addOption({{"m", "monitor"}, "Watch AppImage files at $HOME/Applications and /opt/Applications"}); 65 | parser->addOption({{"o", "open"}, "Open the AppImage file at .", "path"}); 66 | 67 | 68 | parser->process(app); 69 | return parser; 70 | } 71 | -------------------------------------------------------------------------------- /src/config/org.appimage.desktop-integration-tool.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | 4 | Exec=appimage-desktop-integration-config 5 | TryExec=appimage-desktop-integration-config 6 | 7 | Icon=appimage 8 | 9 | Categories=System; 10 | 11 | Name=AppImage Desktop Integration Tool 12 | Comment=Verify and deploy AppImages files in your system by means of a first run wizard or just by coping them to $HOME/Applications. 13 | -------------------------------------------------------------------------------- /src/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(appimage_dektop_integration OBJECT 2 | Registry.h 3 | Registry.cpp 4 | Validator.h 5 | Validator.cpp 6 | Deployer.h 7 | Deployer.cpp 8 | Executor.h 9 | Executor.cpp 10 | ) 11 | 12 | target_compile_options(appimage_dektop_integration PUBLIC -fPIC -fexceptions) 13 | target_include_directories(appimage_dektop_integration PUBLIC 14 | ${libappimage_INCLUDE_DIRECTORIES} 15 | ${Qt5Core_INCLUDE_DIRS} ) 16 | 17 | add_subdirectory(test) 18 | 19 | add_dependencies(appimage_dektop_integration libappimage) 20 | -------------------------------------------------------------------------------- /src/core/Deployer.cpp: -------------------------------------------------------------------------------- 1 | #include "Deployer.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | Deployer::Deployer(QObject *parent) : QObject(parent) 11 | { 12 | userApplicationsDir = QDir::home().filePath("Applications"); 13 | systemApplicationsDir = "/usr/bin/"; 14 | } 15 | 16 | 17 | QString Deployer::getUserDeploymentPath(const QString &path) 18 | { 19 | QFileInfo fi(path); 20 | QString newPath = userApplicationsDir + "/" + fi.completeBaseName(); 21 | 22 | return newPath; 23 | } 24 | void Deployer::trustAppimage(const QString &path) { 25 | auto permissions = QFile::permissions(path); 26 | QFile::setPermissions(path, permissions | QFileDevice::ExeUser); 27 | } 28 | 29 | void Deployer::untrustAppimage(const QString &path) 30 | { 31 | auto permissions = QFile::permissions(path); 32 | auto noExec = ~(QFileDevice::ExeUser 33 | | QFileDevice::ExeGroup 34 | | QFileDevice::ExeOther 35 | | QFileDevice::ExeOwner); 36 | 37 | permissions = permissions & noExec; 38 | QFile::setPermissions(path, permissions); 39 | } 40 | 41 | void Deployer::deployUserwide(const QString &path) 42 | { 43 | Deployer::path = path; 44 | emit deploying(); 45 | 46 | QString newPath = getUserDeploymentPath(path); 47 | QFile::copy(path, newPath); 48 | 49 | if (!QFile::exists(newPath)) { 50 | emit failDeploy(); 51 | return; 52 | } 53 | 54 | int result = appimage_register_in_system(newPath.toLocal8Bit(), true); 55 | if (result) 56 | emit failDeploy(); 57 | else 58 | emit successDeploy(); 59 | } 60 | 61 | void Deployer::deploySystemwide(const QString &path) 62 | { 63 | Deployer::path = path; 64 | emit deploying(); 65 | emit failDeploy(); 66 | } 67 | 68 | void Deployer::cancelDeploy() 69 | { 70 | QString newPath = getUserDeploymentPath(path); 71 | QFile::remove(newPath); 72 | } 73 | -------------------------------------------------------------------------------- /src/core/Deployer.h: -------------------------------------------------------------------------------- 1 | #ifndef DEPLOYER_H 2 | #define DEPLOYER_H 3 | 4 | #include 5 | 6 | class Deployer : public QObject 7 | { 8 | Q_OBJECT 9 | QString getUserDeploymentPath(const QString &path); 10 | 11 | QString userApplicationsDir; 12 | QString systemApplicationsDir; 13 | 14 | QString path; 15 | public: 16 | explicit Deployer(QObject *parent = nullptr); 17 | 18 | signals: 19 | void deploying(); 20 | void successDeploy(); 21 | void failDeploy(); 22 | 23 | public slots: 24 | void trustAppimage(const QString &path); 25 | void untrustAppimage(const QString &path); 26 | 27 | void deployUserwide(const QString &path); 28 | void deploySystemwide(const QString &path); 29 | void cancelDeploy(); 30 | }; 31 | 32 | #endif // DEPLOYER_H 33 | -------------------------------------------------------------------------------- /src/core/Executor.cpp: -------------------------------------------------------------------------------- 1 | #include "Executor.h" 2 | 3 | #include 4 | #include 5 | 6 | Executor::Executor(QObject *parent) : QObject(parent) 7 | { 8 | 9 | } 10 | 11 | void Executor::execute(const QString &path) 12 | { 13 | auto permissions = QFile::permissions(path); 14 | QFile::setPermissions(path, permissions | QFileDevice::ExeUser); 15 | 16 | startDetached(path); 17 | 18 | QFile::setPermissions(path, permissions); 19 | } 20 | 21 | void Executor::executeIsolated(const QString &path) 22 | { 23 | } 24 | 25 | void Executor::startDetached(const QString &path, QStringList arguments) 26 | { 27 | QFileInfo fi(path); 28 | bool started = QProcess::startDetached(fi.absoluteFilePath(), arguments, fi.absolutePath()); 29 | if (started) 30 | emit executed(); 31 | else 32 | emit failure(); 33 | } 34 | -------------------------------------------------------------------------------- /src/core/Executor.h: -------------------------------------------------------------------------------- 1 | #ifndef EXECUTOR_H 2 | #define EXECUTOR_H 3 | 4 | #include 5 | 6 | class Executor : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit Executor(QObject *parent = nullptr); 11 | 12 | signals: 13 | void executed(); 14 | void failure(); 15 | 16 | public slots: 17 | void execute(const QString &path); 18 | void executeIsolated(const QString &path); 19 | 20 | private: 21 | void startDetached(const QString &path, QStringList arguments = {}); 22 | }; 23 | 24 | #endif // EXECUTOR_H 25 | -------------------------------------------------------------------------------- /src/core/Registry.cpp: -------------------------------------------------------------------------------- 1 | #include "Registry.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | Registry::Registry(QObject *parent) : QObject(parent) 11 | { 12 | dataLocations = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); 13 | } 14 | 15 | void Registry::setDataLocations(const QStringList &dataLocations) 16 | { 17 | Registry::dataLocations = dataLocations; 18 | } 19 | 20 | QSet Registry::getDeployedAppimageHashes() 21 | { 22 | QStringList desktopEntries = getDesktopEntriesPaths(); 23 | QStringList icons = getIconsPaths(); 24 | 25 | QStringList paths; 26 | paths.append(desktopEntries); 27 | paths.append(icons); 28 | 29 | return getHashesFromPaths(paths); 30 | } 31 | 32 | QStringList Registry::getDesktopEntriesPaths() 33 | { 34 | QStringList entries; 35 | for (const QString &l : dataLocations) { 36 | QDir d(l+"/applications"); 37 | if (d.exists()) 38 | entries.append(getEntriesAbsolutePaths(d, {"appimagekit*.desktop"})); 39 | else 40 | qWarning() << "Applications dir doesn't exist: " << d.absolutePath() ; 41 | } 42 | 43 | return entries; 44 | } 45 | 46 | QStringList Registry::getIconsPaths() 47 | { 48 | QStringList entries; 49 | for (const QString &l : dataLocations) { 50 | QDir d(l+"/icons"); 51 | if (d.exists()) 52 | entries.append(getEntriesAbsolutePaths(d, {"appimagekit_*.png", "appimagekit_*.svg"})); 53 | else 54 | qWarning() << "Icons dir doesn't exist: " << d.absolutePath() ; 55 | } 56 | 57 | return entries; 58 | } 59 | 60 | 61 | 62 | QSet Registry::getHashesFromPaths(QStringList entries) 63 | { 64 | QSet hashes; 65 | for (const QString &entry: entries) 66 | hashes << extractHashFromDesktopIntegrationFile(entry); 67 | 68 | return hashes; 69 | } 70 | 71 | QString Registry::extractHashFromDesktopIntegrationFile(const QString &entry) { return entry.section("/", -1).mid(12, 32); } 72 | 73 | QStringList Registry::getEntriesAbsolutePaths(QDir d, const QStringList &filters) 74 | { 75 | QStringList paths; 76 | 77 | const QStringList &dirEntryList = d.entryList(filters); 78 | 79 | for (const QString &entry : dirEntryList) 80 | paths.append(d.absoluteFilePath(entry)); 81 | 82 | return paths; 83 | } 84 | 85 | void Registry::setAppimageLocations(const QStringList &locations) { 86 | Registry::appimagesLocations = locations; 87 | } 88 | 89 | QStringList Registry::getAppimagesPaths() { 90 | QStringList entries; 91 | for (const QString &l : appimagesLocations) { 92 | QDir d(l); 93 | if (d.exists()) { 94 | for (const QString &entry : d.entryList(QDir::NoDotAndDotDot | QDir::Files)) { 95 | const QString path = d.absoluteFilePath(entry); 96 | int type = appimage_get_type(path.toStdString().c_str(), false); 97 | if (type > 0) 98 | entries << path; 99 | } 100 | 101 | } 102 | else 103 | qWarning() << "Icons dir doesn't exist: " << d.absolutePath() ; 104 | } 105 | 106 | return entries; 107 | } 108 | 109 | QStringList Registry::getApplicationsWithoutDesktopIntegration() { 110 | const auto appimages = getAppimagesPaths(); 111 | const auto deployedAppimagesHashes = getDeployedAppimageHashes(); 112 | 113 | QStringList list; 114 | for (const QString &path: appimages) { 115 | if (!isDeployed(deployedAppimagesHashes, path)) 116 | list.append(path); 117 | } 118 | 119 | return list; 120 | } 121 | 122 | bool Registry::isDeployed(const QSet &deployedAppimagesHashes, const QString &path) const { 123 | const QString hash = appimage_get_md5(path.toStdString().c_str()); 124 | bool deployed = deployedAppimagesHashes.contains(hash); 125 | return deployed; 126 | } 127 | 128 | QStringList Registry::getOrphanDesktopIntegrationFiles() { 129 | const auto appimages = getAppimagesPaths(); 130 | const auto hashes = getAppimageHashes(appimages); 131 | 132 | QStringList desktopEntries = getDesktopEntriesPaths(); 133 | QStringList icons = getIconsPaths(); 134 | 135 | QStringList list; 136 | list << extractOrphanFiles(hashes, desktopEntries); 137 | list << extractOrphanFiles(hashes, icons); 138 | 139 | return list; 140 | } 141 | 142 | QStringList Registry::extractOrphanFiles(const QSet &hashes, const QStringList &desktopEntries) const { 143 | QStringList list; 144 | 145 | for (const QString &path: desktopEntries) { 146 | auto hash = extractHashFromDesktopIntegrationFile(path); 147 | if (!hashes.contains(hash)) { 148 | list << path; 149 | } 150 | } 151 | return list; 152 | } 153 | 154 | QSet Registry::getAppimageHashes(const QStringList &appimages) const { 155 | QSet hashes; 156 | for (const QString &path: appimages) { 157 | const QString hash = appimage_get_md5(path.toStdString().c_str()); 158 | hashes.insert(hash); 159 | } 160 | return hashes; 161 | } 162 | -------------------------------------------------------------------------------- /src/core/Registry.h: -------------------------------------------------------------------------------- 1 | #ifndef REGISTRY_H 2 | #define REGISTRY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Registry : public QObject 10 | { 11 | Q_OBJECT 12 | QStringList dataLocations; 13 | QStringList appimagesLocations; 14 | 15 | public: 16 | explicit Registry(QObject *parent = nullptr); 17 | 18 | void setDataLocations(const QStringList &dataLocations); 19 | void setAppimageLocations(const QStringList &locations); 20 | 21 | QStringList getDesktopEntriesPaths(); 22 | QStringList getIconsPaths(); 23 | QStringList getAppimagesPaths(); 24 | 25 | QStringList getApplicationsWithoutDesktopIntegration(); 26 | QStringList getOrphanDesktopIntegrationFiles(); 27 | 28 | static QString extractHashFromDesktopIntegrationFile(const QString &entry); 29 | 30 | private: 31 | QSet getDeployedAppimageHashes(); 32 | 33 | QSet getHashesFromPaths(QStringList entries); 34 | QStringList getEntriesAbsolutePaths(QDir d, const QStringList &filters); 35 | 36 | bool isDeployed(const QSet &deployedAppimagesHashes, const QString &path) const; 37 | 38 | QSet getAppimageHashes(const QStringList &appimages) const; 39 | 40 | QStringList extractOrphanFiles(const QSet &hashes, const QStringList &desktopEntries) const; 41 | }; 42 | 43 | #endif // REGISTRY_H 44 | -------------------------------------------------------------------------------- /src/core/Validator.cpp: -------------------------------------------------------------------------------- 1 | #include "Validator.h" 2 | 3 | #include 4 | 5 | Validator::Validator(QObject *parent) : QObject(parent) 6 | { 7 | 8 | } 9 | 10 | void Validator::setAppimage(const QString &path) 11 | { 12 | Validator::path = path; 13 | } 14 | 15 | void Validator::validate() 16 | { 17 | int res = appimage_get_type(path.toLocal8Bit(), true); 18 | if (res < 0) 19 | emit invalidAppimage(path); 20 | else { 21 | emit unsignedAppimage(path); 22 | emit finished(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/core/Validator.h: -------------------------------------------------------------------------------- 1 | #ifndef VALIDATOR_H 2 | #define VALIDATOR_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | class Validator : public QObject 9 | { 10 | Q_OBJECT 11 | QString path; 12 | public: 13 | explicit Validator(QObject *parent = nullptr); 14 | void setAppimage(const QString &path); 15 | 16 | signals: 17 | void finished(); 18 | void unsignedAppimage(const QString &path); 19 | void invalidAppimage(const QString &path); 20 | 21 | public slots: 22 | void validate(); 23 | }; 24 | 25 | #endif // VALIDATOR_H 26 | -------------------------------------------------------------------------------- /src/core/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | enable_testing() 2 | 3 | include(../../../third-party/gtest.cmake) 4 | 5 | add_executable(core_tests 6 | $ 7 | 8 | main.cpp 9 | TestRegistry.cpp 10 | ) 11 | 12 | target_include_directories(core_tests 13 | PRIVATE ${CMAKE_SOURCE_DIR}/src/core 14 | private ${gtest_INCLUDE_DIRS} 15 | PRIVATE ${Qt5Core_INCLUDE_DIRS} 16 | ) 17 | 18 | target_compile_definitions(core_tests 19 | PRIVATE TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/" 20 | ) 21 | 22 | target_link_libraries(core_tests 23 | libappimage 24 | Qt5::Core 25 | 26 | ${gtest_LIBRARIES} 27 | pthread # this must be last else it fails at linking 28 | ) 29 | 30 | add_dependencies(core_tests gtest) 31 | 32 | add_test(core_tests core_tests) -------------------------------------------------------------------------------- /src/core/test/TestRegistry.cpp: -------------------------------------------------------------------------------- 1 | #ifndef APPIMAGE_DESKTOP_INTEGRATION_TESTREGISTRY_H 2 | #define APPIMAGE_DESKTOP_INTEGRATION_TESTREGISTRY_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace NX_SOFTWARE_CENTER_TESTS { 10 | class TestRegistry : public testing::Test { 11 | public: 12 | TestRegistry() { 13 | registry.setDataLocations({TEST_DATA_DIR}); 14 | registry.setAppimageLocations({TEST_DATA_DIR"/appimages"}); 15 | } 16 | 17 | Registry registry; 18 | }; 19 | 20 | TEST_F(TestRegistry, getHashFromPath) { 21 | auto path = "/some/place/appimagekit_e660685f087766d437de39ef24d9d64c-echo.desktop"; 22 | auto result = Registry::extractHashFromDesktopIntegrationFile(path); 23 | 24 | ASSERT_EQ("e660685f087766d437de39ef24d9d64c", result.toLocal8Bit()); 25 | } 26 | 27 | TEST_F(TestRegistry, findDeployedDesktopFiles) { 28 | auto entries = registry.getDesktopEntriesPaths(); 29 | QDir dir(TEST_DATA_DIR"/applications"); 30 | for (const QString &entry: dir.entryList({"*.desktop"})) { 31 | const QString absolutePath = dir.absoluteFilePath(entry); 32 | ASSERT_TRUE(entries.contains(absolutePath)); 33 | } 34 | } 35 | 36 | TEST_F(TestRegistry, findDeployedIconsFiles) { 37 | auto entries = registry.getIconsPaths(); 38 | QDir dir(TEST_DATA_DIR"/icons"); 39 | for (const QString &entry: dir.entryList({"*.png"})) { 40 | const QString absolutePath = dir.absoluteFilePath(entry); 41 | ASSERT_TRUE(entries.contains(absolutePath)); 42 | } 43 | } 44 | 45 | TEST_F(TestRegistry, findDeployedAppimages) { 46 | auto entries = registry.getAppimagesPaths(); 47 | 48 | QDir dir(TEST_DATA_DIR"/appimages"); 49 | auto expected = dir.entryList({"*.AppImage"}, QDir::NoDotAndDotDot | QDir::Files); 50 | 51 | ASSERT_EQ(expected.size(), entries.size()); 52 | for (const QString &entry: expected) { 53 | const QString absolutePath = dir.absoluteFilePath(entry); 54 | ASSERT_TRUE(entries.contains(absolutePath)); 55 | } 56 | } 57 | 58 | TEST_F(TestRegistry, getApplicationsWithoutDesktopIntegration) { 59 | const QStringList list = registry.getApplicationsWithoutDesktopIntegration(); 60 | const auto expected = QStringList({TEST_DATA_DIR"appimages/echo-x86_64-8.25.AppImage"}); 61 | 62 | ASSERT_FALSE(list.isEmpty()); 63 | ASSERT_EQ(expected, list); 64 | } 65 | 66 | TEST_F(TestRegistry, getOrphanDesktopIntegrationFiles) { 67 | const auto list = registry.getOrphanDesktopIntegrationFiles(); 68 | const QStringList expected = { 69 | TEST_DATA_DIR"applications/appimagekit_e660685f087766d437de39ef24d9d64c-echo.desktop", 70 | TEST_DATA_DIR"icons/appimagekit_e660685f087766d437de39ef24d9d64c_utilities-terminal.svg"}; 71 | 72 | ASSERT_FALSE(list.isEmpty()); 73 | ASSERT_EQ(expected, list); 74 | } 75 | } 76 | 77 | 78 | #endif //APPIMAGE_DESKTOP_INTEGRATION_TESTREGISTRY_H 79 | -------------------------------------------------------------------------------- /src/core/test/data/appimages/echo-x86_64-8.25.AppImage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nitrux/appimage-desktop-integration/44f721783ec90327de03c30e97abd6cf0806c0de/src/core/test/data/appimages/echo-x86_64-8.25.AppImage -------------------------------------------------------------------------------- /src/core/test/data/appimages/fake_appimage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nitrux/appimage-desktop-integration/44f721783ec90327de03c30e97abd6cf0806c0de/src/core/test/data/appimages/fake_appimage -------------------------------------------------------------------------------- /src/core/test/data/appimages/printf_binary: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nitrux/appimage-desktop-integration/44f721783ec90327de03c30e97abd6cf0806c0de/src/core/test/data/appimages/printf_binary -------------------------------------------------------------------------------- /src/core/test/data/applications/appimagekit_e660685f087766d437de39ef24d9d64c-echo.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Echo 5 | Comment=Just echo. 6 | Exec=firejail --env=DESKTOPINTEGRATION=appimaged --noprofile --appimage '/home/alexis/Applications/echo-x86_64-8.25' 7 | Icon=appimagekit_e660685f087766d437de39ef24d9d64c_utilities-terminal 8 | Actions=FirejailProfile; 9 | X-AppImage-Comment=Generated by appimaged continuous 10 | X-AppImage-Identifier=e660685f087766d437de39ef24d9d64c 11 | 12 | [Desktop Action FirejailProfile] 13 | Name=Run without sandbox profile 14 | Exec=firejail --env=DESKTOPINTEGRATION=appimaged --private --appimage '/home/alexis/Applications/echo-x86_64-8.25' 15 | TryExec=firejail 16 | -------------------------------------------------------------------------------- /src/core/test/data/icons/appimagekit_e660685f087766d437de39ef24d9d64c_utilities-terminal.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 25 | 27 | image/svg+xml 28 | 30 | 31 | 32 | 33 | 34 | 61 | 66 | 70 | 74 | 78 | 82 | 86 | 90 | 94 | 95 | 97 | 100 | 104 | 108 | 109 | 118 | 128 | 138 | 148 | 158 | 168 | 169 | 173 | 237 | 245 | 249 | 253 | 261 | 267 | 273 | 280 | 287 | 291 | 298 | 305 | 312 | 319 | 320 | 321 | -------------------------------------------------------------------------------- /src/core/test/data/user_apps_monitor.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nitrux/appimage-desktop-integration/44f721783ec90327de03c30e97abd6cf0806c0de/src/core/test/data/user_apps_monitor.conf -------------------------------------------------------------------------------- /src/core/test/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int main(int argc, char **argv) 6 | { 7 | QCoreApplication app(argc, argv); 8 | 9 | testing::InitGoogleTest(&argc, argv); 10 | return RUN_ALL_TESTS(); 11 | } 12 | -------------------------------------------------------------------------------- /src/first_run/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(CMAKE_AUTOUIC ON) 2 | set(CMAKE_AUTORCC ON) 3 | 4 | find_package(Qt5 COMPONENTS Gui Widgets) 5 | 6 | add_executable(appimage_first_run 7 | main.cpp 8 | $ 9 | gui/ValidationDialog.h 10 | gui/ValidationDialog.cpp 11 | gui/ValidationDialog.ui 12 | gui/UiController.cpp 13 | gui/UiController.h 14 | gui/UnsecureAppimageDialog.h 15 | gui/UnsecureAppimageDialog.cpp 16 | gui/UnsecureAppimageDialog.ui 17 | gui/DeploymentDialog.h 18 | gui/DeploymentDialog.cpp 19 | gui/DeploymentDialog.ui 20 | ../../res/res.qrc) 21 | 22 | target_include_directories(appimage_first_run PRIVATE 23 | PRIVATE ${CMAKE_SOURCE_DIR}/src/core 24 | ${libappimage_INCLUDE_DIRECTORIES} 25 | ) 26 | 27 | target_link_libraries(appimage_first_run libappimage Qt5::Core Qt5::Gui Qt5::Widgets) 28 | 29 | add_dependencies(appimage_first_run libappimage) 30 | 31 | install(TARGETS appimage_first_run RUNTIME DESTINATION bin COMPONENT first-run) 32 | install(FILES org.appimage.first_run.desktop DESTINATION share/applications COMPONENT first-run) 33 | -------------------------------------------------------------------------------- /src/first_run/gui/DeploymentDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "DeploymentDialog.h" 2 | #include "ui_DeploymentDialog.h" 3 | 4 | #include 5 | 6 | DeploymentDialog::DeploymentDialog(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::DeploymentDialog) 9 | { 10 | ui->setupUi(this); 11 | 12 | QWidget *w = ui->pageBusy; 13 | ui->stackedWidget->setCurrentWidget(w); 14 | 15 | resizeToStackedWidgetContent(w); 16 | 17 | connect(ui->cancelButton_2, &QPushButton::released, this, &DeploymentDialog::reject); 18 | connect(ui->closeButton_2, &QPushButton::released, this, &DeploymentDialog::accept); 19 | connect(ui->closeButton_3, &QPushButton::released, this, &DeploymentDialog::accept); 20 | connect(ui->closeButton_4, &QPushButton::released, this, &DeploymentDialog::accept); 21 | } 22 | 23 | DeploymentDialog::~DeploymentDialog() 24 | { 25 | delete ui; 26 | } 27 | 28 | void DeploymentDialog::handleSuccessDelpoy() 29 | { 30 | QWidget *w = ui->pageSuccess; 31 | ui->stackedWidget->setCurrentWidget(w); 32 | 33 | resizeToStackedWidgetContent(w); 34 | } 35 | 36 | void DeploymentDialog::handleFailDelpoy() 37 | { 38 | QWidget *w = ui->pageFailDeployUser; 39 | ui->stackedWidget->setCurrentWidget(w); 40 | 41 | resizeToStackedWidgetContent(w); 42 | } 43 | 44 | void DeploymentDialog::resizeToStackedWidgetContent(QWidget *widget) 45 | { 46 | widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 47 | widget->adjustSize(); 48 | adjustSize(); 49 | } 50 | -------------------------------------------------------------------------------- /src/first_run/gui/DeploymentDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef DEPLOYMENTDIALOG_H 2 | #define DEPLOYMENTDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class DeploymentDialog; 8 | } 9 | 10 | class DeploymentDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit DeploymentDialog(QWidget *parent = 0); 16 | ~DeploymentDialog(); 17 | 18 | signals: 19 | void canceled(); 20 | 21 | public slots: 22 | void handleSuccessDelpoy(); 23 | void handleFailDelpoy(); 24 | 25 | private: 26 | Ui::DeploymentDialog *ui; 27 | void resizeToStackedWidgetContent(QWidget *widget); 28 | 29 | }; 30 | 31 | #endif // DEPLOYMENTDIALOG_H 32 | -------------------------------------------------------------------------------- /src/first_run/gui/DeploymentDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DeploymentDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 311 10 | 220 11 | 12 | 13 | 14 | Deploying Appimage 15 | 16 | 17 | 18 | :/images/document-download.svg:/images/document-download.svg 19 | 20 | 21 | 22 | 23 | 24 | 0 25 | 26 | 27 | 28 | 29 | 0 30 | 0 31 | 32 | 33 | 34 | 35 | 36 | 37 | 0 38 | 39 | 40 | 41 | 42 | 43 | 0 44 | 0 45 | 46 | 47 | 48 | 49 | 9 50 | 51 | 52 | 53 | Deploying application, please waith ... 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 7 62 | 63 | 64 | 65 | false 66 | 67 | 68 | 0 69 | 70 | 71 | 0 72 | 73 | 74 | true 75 | 76 | 77 | Qt::Horizontal 78 | 79 | 80 | false 81 | 82 | 83 | 84 | 85 | 86 | 87 | Qt::Vertical 88 | 89 | 90 | QSizePolicy::Fixed 91 | 92 | 93 | 94 | 20 95 | 4 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 0 106 | 107 | 108 | 109 | 110 | Qt::Vertical 111 | 112 | 113 | 114 | 20 115 | 40 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 0 125 | 0 126 | 127 | 128 | 129 | 130 | 100 131 | 16777215 132 | 133 | 134 | 135 | 136 | 8 137 | 138 | 139 | 140 | Qt::LeftToRight 141 | 142 | 143 | 144 | 145 | 146 | 147 | .. 148 | 149 | 150 | true 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 0 162 | 0 163 | 164 | 165 | 166 | 167 | 168 | 169 | 12 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | :/images/dialog-information.svg 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 0 186 | 0 187 | 188 | 189 | 190 | 191 | 11 192 | 193 | 194 | 195 | Unable to deploy the appimage! 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 0 206 | 0 207 | 208 | 209 | 210 | 211 | 300 212 | 300 213 | 214 | 215 | 216 | <html><head/><body><p>Please verify that you have write permissions at:<br/>XDG_USER_HOME/Applications<br/>XDG_USER_DATA/share/icons<br/>XDG_USER_DATA/share/applications/</p><p><br/></p><p>If you think this is an error please report it to <a href="https://github.com/AppImage/AppImageKit/issues"><span style=" text-decoration: underline; color:#007af4;">AppImageKit at Github</span></a></p></body></html> 217 | 218 | 219 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 220 | 221 | 222 | true 223 | 224 | 225 | 226 | 227 | 228 | 229 | 20 230 | 231 | 232 | 233 | 234 | Qt::Horizontal 235 | 236 | 237 | QSizePolicy::MinimumExpanding 238 | 239 | 240 | 241 | 40 242 | 20 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | Close 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 0 262 | 0 263 | 264 | 265 | 266 | 267 | 268 | 269 | 12 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | :/images/dialog-information.svg 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 0 286 | 0 287 | 288 | 289 | 290 | 291 | 11 292 | 293 | 294 | 295 | Unable to deploy the appimage! 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 0 306 | 0 307 | 308 | 309 | 310 | 311 | 300 312 | 300 313 | 314 | 315 | 316 | <html><head/><body><p>Please verify that you have write permissions at:<br/>/usr/bin<br/>/usr/share/icons<br/>/usr/share/applications/</p><p><br/></p><p>If you think this is an error please report it to <a href="https://github.com/AppImage/AppImageKit/issues"><span style=" text-decoration: underline; color:#007af4;">AppImageKit at Github</span></a></p></body></html> 317 | 318 | 319 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 320 | 321 | 322 | true 323 | 324 | 325 | 326 | 327 | 328 | 329 | 20 330 | 331 | 332 | 333 | 334 | Qt::Horizontal 335 | 336 | 337 | QSizePolicy::MinimumExpanding 338 | 339 | 340 | 341 | 40 342 | 20 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | Close 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 0 362 | 0 363 | 364 | 365 | 366 | 367 | 368 | 369 | 12 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | :/images/dialog-information.svg 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 0 386 | 0 387 | 388 | 389 | 390 | 391 | 11 392 | 393 | 394 | 395 | Application deployed successfully 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 20 405 | 406 | 407 | 408 | 409 | Qt::Horizontal 410 | 411 | 412 | QSizePolicy::MinimumExpanding 413 | 414 | 415 | 416 | 40 417 | 20 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | Close 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | -------------------------------------------------------------------------------- /src/first_run/gui/UiController.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 20/02/18. 3 | // 4 | #include 5 | #include 6 | 7 | #include "UiController.h" 8 | 9 | 10 | UiController::UiController(QObject *parent) : 11 | QObject(parent), validator(nullptr), deployer(nullptr), previousDialog(nullptr) {} 12 | 13 | void UiController::setValidator(Validator *validator) { 14 | UiController::validator = validator; 15 | } 16 | 17 | void UiController::setDeployer(Deployer *deployer) 18 | { 19 | UiController::deployer = deployer; 20 | } 21 | 22 | void UiController::setExecutor(Executor *executor) 23 | { 24 | UiController::executor = executor; 25 | } 26 | 27 | void UiController::exec() 28 | { 29 | Q_ASSERT(validator); 30 | Q_ASSERT(deployer); 31 | Q_ASSERT(executor); 32 | 33 | QObject::connect(validator, &Validator::invalidAppimage, 34 | &validationDialog, &ValidationDialog::showErrorPage); 35 | QObject::connect(validator, &Validator::finished, 36 | &validationDialog, &ValidationDialog::close); 37 | QObject::connect(validator, &Validator::unsignedAppimage, 38 | this, &UiController::handleUnsignedAppimage); 39 | 40 | validationDialog.showOpeningPage(); 41 | 42 | validator->validate(); 43 | } 44 | 45 | void UiController::cancel() { 46 | validationDialog.close(); 47 | unsecureAppimageDialog.close(); 48 | } 49 | 50 | void UiController::handleUnsignedAppimage(const QString &path) 51 | { 52 | unsecureAppimageDialog.setAppimage(path); 53 | unsecureAppimageDialog.show(); 54 | 55 | connect(&unsecureAppimageDialog, &UnsecureAppimageDialog::deployUserwide, 56 | deployer, &Deployer::deployUserwide); 57 | 58 | connect(&unsecureAppimageDialog, &UnsecureAppimageDialog::run, 59 | this, &UiController::handleRun); 60 | 61 | connect(&unsecureAppimageDialog, &UnsecureAppimageDialog::trust, 62 | deployer, &Deployer::trustAppimage); 63 | connect(&unsecureAppimageDialog, &UnsecureAppimageDialog::untrust, 64 | deployer, &Deployer::untrustAppimage); 65 | 66 | connect(deployer, &Deployer::deploying, 67 | this, &UiController::handleDeploying); 68 | } 69 | 70 | void UiController::handleDeploying() 71 | { 72 | previousDialog = &unsecureAppimageDialog; 73 | 74 | unsecureAppimageDialog.hide(); 75 | 76 | connect(deployer, &Deployer::successDeploy, 77 | &deploymentDialog, &DeploymentDialog::handleSuccessDelpoy); 78 | connect(deployer, &Deployer::failDeploy, 79 | &deploymentDialog, &DeploymentDialog::handleFailDelpoy); 80 | 81 | connect(&deploymentDialog, &DeploymentDialog::accepted, 82 | this, &UiController::handleDeploymentDialogAccepted); 83 | 84 | deploymentDialog.show(); 85 | } 86 | 87 | void UiController::showPreviousDialog() 88 | { 89 | if (previousDialog) 90 | previousDialog->show(); 91 | 92 | previousDialog = nullptr; 93 | } 94 | 95 | void UiController::handleDeploymentDialogAccepted() 96 | { 97 | showPreviousDialog(); 98 | } 99 | 100 | void UiController::handleDeploymentDialogRejected() 101 | { 102 | deployer->cancelDeploy(); 103 | showPreviousDialog(); 104 | } 105 | 106 | void UiController::handleRun(const QString &path) 107 | { 108 | connect(executor, &Executor::executed, this, &UiController::handleExecuted); 109 | connect(executor, &Executor::failure, this, &UiController::handleFailure); 110 | 111 | executor->execute(path); 112 | 113 | validationDialog.close(); 114 | unsecureAppimageDialog.close(); 115 | deploymentDialog.close(); 116 | } 117 | 118 | void UiController::handleExecuted() 119 | { 120 | exit(0); 121 | } 122 | 123 | void UiController::handleFailure() 124 | { 125 | QMessageBox msg; 126 | msg.setText(tr("There was an error while trying to execute the appimage")); 127 | msg.exec(); 128 | } 129 | -------------------------------------------------------------------------------- /src/first_run/gui/UiController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 20/02/18. 3 | // 4 | 5 | #ifndef APPIMAGE_DESKTOP_INTEGRATION_FIRSTRUNCONTROLLER_H 6 | #define APPIMAGE_DESKTOP_INTEGRATION_FIRSTRUNCONTROLLER_H 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "gui/ValidationDialog.h" 16 | #include "gui/UnsecureAppimageDialog.h" 17 | #include "gui/DeploymentDialog.h" 18 | 19 | class UiController : public QObject { 20 | Q_OBJECT 21 | QStackedWidget stackedWidget; 22 | 23 | Validator *validator; 24 | Deployer *deployer; 25 | Executor *executor; 26 | 27 | ValidationDialog validationDialog; 28 | UnsecureAppimageDialog unsecureAppimageDialog; 29 | DeploymentDialog deploymentDialog; 30 | QWidget *previousDialog; 31 | void showPreviousDialog(); 32 | 33 | public: 34 | UiController(QObject *parent = nullptr); 35 | 36 | void setValidator(Validator *validator); 37 | void setDeployer(Deployer *deployer); 38 | void setExecutor(Executor *executor); 39 | 40 | public slots: 41 | void exec(); 42 | void cancel(); 43 | 44 | protected slots: 45 | void handleUnsignedAppimage(const QString &path); 46 | void handleDeploying(); 47 | void handleDeploymentDialogAccepted(); 48 | void handleDeploymentDialogRejected(); 49 | void handleRun(const QString &path); 50 | void handleExecuted(); 51 | void handleFailure(); 52 | }; 53 | 54 | 55 | #endif //APPIMAGE_DESKTOP_INTEGRATION_FIRSTRUNCONTROLLER_H 56 | -------------------------------------------------------------------------------- /src/first_run/gui/UnsecureAppimageDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "UnsecureAppimageDialog.h" 2 | #include "ui_UnsecureAppimageDialog.h" 3 | 4 | #include 5 | #include 6 | 7 | UnsecureAppimageDialog::UnsecureAppimageDialog(QWidget *parent) : 8 | QDialog(parent), 9 | ui(new Ui::UnsecureAppimageDialog) 10 | { 11 | ui->setupUi(this); 12 | setupDeployOptionsMenu(); 13 | setupRunOptionsMenu(); 14 | } 15 | 16 | void UnsecureAppimageDialog::setupDeployOptionsMenu() 17 | { 18 | deploySystemAction = new QAction(QIcon(":/images/document-download.svg"), 19 | tr("Deploy System Wide"), this); 20 | connect(deploySystemAction, &QAction::triggered, [=](){ emit deploySystemwide(path); }); 21 | deploySystemAction->setEnabled(false); 22 | 23 | deployOptionsMenu = new QMenu(this); 24 | deployOptionsMenu->addAction(deploySystemAction); 25 | 26 | ui->deployOptionsButton->setMenu(deployOptionsMenu); 27 | } 28 | 29 | void UnsecureAppimageDialog::setupRunOptionsMenu() 30 | { 31 | runUnsecureAction = new QAction(QIcon(":/images/application-x-executable.svg"), 32 | tr("Run Unsecure"), this); 33 | connect(runUnsecureAction, &QAction::triggered, [=](){ emit run(path); }); 34 | 35 | runOptionsMenu = new QMenu(this); 36 | runOptionsMenu->addAction(runUnsecureAction); 37 | 38 | ui->runOptionsButton->setMenu(runOptionsMenu); 39 | } 40 | 41 | 42 | UnsecureAppimageDialog::~UnsecureAppimageDialog() 43 | { 44 | delete ui; 45 | 46 | delete runOptionsMenu; 47 | delete deployOptionsMenu; 48 | delete runUnsecureAction; 49 | delete deploySystemAction; 50 | } 51 | 52 | void UnsecureAppimageDialog::setAppimage(const QString &path) 53 | { 54 | UnsecureAppimageDialog::path = path; 55 | } 56 | 57 | void UnsecureAppimageDialog::on_runButton_clicked() 58 | { 59 | emit run(path); 60 | } 61 | 62 | void UnsecureAppimageDialog::on_closeButton_clicked() 63 | { 64 | reject(); 65 | } 66 | 67 | void UnsecureAppimageDialog::on_deployButton_clicked() 68 | { 69 | emit deployUserwide(path); 70 | } 71 | 72 | void UnsecureAppimageDialog::on_checkBox_toggled(bool checked) 73 | { 74 | ui->runButton->setEnabled(checked); 75 | if (checked) 76 | emit trust(path); 77 | else 78 | emit untrust(path); 79 | } 80 | -------------------------------------------------------------------------------- /src/first_run/gui/UnsecureAppimageDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef UNSECUREAPPIMAGEDIALOG_H 2 | #define UNSECUREAPPIMAGEDIALOG_H 3 | 4 | #include 5 | 6 | class QMenu; 7 | class QActions; 8 | namespace Ui { 9 | class UnsecureAppimageDialog; 10 | } 11 | 12 | class UnsecureAppimageDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | QString path; 16 | public: 17 | explicit UnsecureAppimageDialog(QWidget *parent = 0); 18 | ~UnsecureAppimageDialog(); 19 | 20 | void setAppimage(const QString &path); 21 | 22 | signals: 23 | void deployUserwide(const QString &path); 24 | void deploySystemwide(const QString &path); 25 | void run(const QString &path); 26 | void runIsolated(const QString &path); 27 | void trust(const QString &path); 28 | void untrust(const QString &path); 29 | 30 | private slots: 31 | void on_checkBox_toggled(bool checked); 32 | 33 | private slots: 34 | void on_deployButton_clicked(); 35 | void on_closeButton_clicked(); 36 | void on_runButton_clicked(); 37 | 38 | private: 39 | Ui::UnsecureAppimageDialog *ui; 40 | QMenu *runOptionsMenu; 41 | QMenu *deployOptionsMenu; 42 | QAction *runUnsecureAction; 43 | QAction *deploySystemAction; 44 | void setupDeployOptionsMenu(); 45 | void setupRunOptionsMenu(); 46 | }; 47 | 48 | #endif // UNSECUREAPPIMAGEDIALOG_H 49 | -------------------------------------------------------------------------------- /src/first_run/gui/UnsecureAppimageDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | UnsecureAppimageDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 483 10 | 380 11 | 12 | 13 | 14 | Unsigned Appimage 15 | 16 | 17 | 18 | 10 19 | 20 | 21 | 22 | 23 | Qt::Vertical 24 | 25 | 26 | QSizePolicy::Fixed 27 | 28 | 29 | 30 | 20 31 | 12 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 10 40 | 41 | 42 | 43 | 44 | 45 | 0 46 | 0 47 | 48 | 49 | 50 | 51 | 32 52 | 32 53 | 54 | 55 | 56 | 57 | 58 | 59 | :/images/dialog-information.svg 60 | 61 | 62 | true 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 0 71 | 0 72 | 73 | 74 | 75 | 76 | 11 77 | 75 78 | true 79 | 80 | 81 | 82 | The current appimage was not signed by its author. 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 0 93 | 0 94 | 95 | 96 | 97 | <html><head/><body><p>This makes impossible to verify its origin and integrity. Use it under your own risk.</p></body></html> 98 | 99 | 100 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 101 | 102 | 103 | true 104 | 105 | 106 | 12 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | Trust appimage (makes the appimage executable) 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | Qt::Horizontal 127 | 128 | 129 | 130 | 40 131 | 20 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 0 140 | 141 | 142 | 143 | 144 | Deploy 145 | 146 | 147 | 148 | :/images/document-download.svg:/images/document-download.svg 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 24 157 | 16777215 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 0 171 | 172 | 173 | 174 | 175 | false 176 | 177 | 178 | Executes the appimage 179 | 180 | 181 | Run 182 | 183 | 184 | 185 | :/images/application-x-executable.svg:/images/application-x-executable.svg 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 0 194 | 0 195 | 196 | 197 | 198 | 199 | 24 200 | 16777215 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | Close 214 | 215 | 216 | true 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /src/first_run/gui/ValidationDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "ValidationDialog.h" 2 | #include "ui_ValidationDialog.h" 3 | 4 | ValidationDialog::ValidationDialog(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::ValidationDialog) 7 | { 8 | ui->setupUi(this); 9 | showOpeningPage(); 10 | } 11 | 12 | ValidationDialog::~ValidationDialog() 13 | { 14 | delete ui; 15 | } 16 | 17 | 18 | void ValidationDialog::showOpeningPage() 19 | { 20 | QWidget *widget = ui->pageOpening; 21 | ui->stackedWidget->setCurrentWidget(widget); 22 | 23 | resizeToStackedWidgetContent(widget); 24 | show(); 25 | } 26 | 27 | void ValidationDialog::showErrorPage() 28 | { 29 | QWidget *widget = ui->pageError; 30 | ui->stackedWidget->setCurrentWidget(widget); 31 | resizeToStackedWidgetContent(widget); 32 | show(); 33 | } 34 | 35 | void ValidationDialog::resizeToStackedWidgetContent(QWidget *widget) 36 | { 37 | widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 38 | widget->adjustSize(); 39 | adjustSize(); 40 | } 41 | 42 | void ValidationDialog::on_closeButton_released() 43 | { 44 | reject(); 45 | } 46 | 47 | void ValidationDialog::on_cancelButton_released() 48 | { 49 | reject(); 50 | } 51 | -------------------------------------------------------------------------------- /src/first_run/gui/ValidationDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef VALIDATIONDIALOG_H 2 | #define VALIDATIONDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ValidationDialog; 8 | } 9 | 10 | class ValidationDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ValidationDialog(QWidget *parent = 0); 16 | ~ValidationDialog(); 17 | 18 | public slots: 19 | void showOpeningPage(); 20 | void showErrorPage(); 21 | 22 | private slots: 23 | void on_cancelButton_released(); 24 | void on_closeButton_released(); 25 | 26 | private: 27 | Ui::ValidationDialog *ui; 28 | void resizeToStackedWidgetContent(QWidget *widget); 29 | }; 30 | 31 | #endif // VALIDATIONDIALOG_H 32 | -------------------------------------------------------------------------------- /src/first_run/gui/ValidationDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ValidationDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 363 10 | 248 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 0 22 | 0 23 | 24 | 25 | 26 | Appimage Validation Utility 27 | 28 | 29 | 30 | :/images/appimage.svg:/images/appimage.svg 31 | 32 | 33 | 34 | 35 | 36 | 37 | 0 38 | 0 39 | 40 | 41 | 42 | 43 | 0 44 | 0 45 | 46 | 47 | 48 | 1 49 | 50 | 51 | 52 | 53 | 0 54 | 0 55 | 56 | 57 | 58 | 59 | 300 60 | 70 61 | 62 | 63 | 64 | 65 | 400 66 | 70 67 | 68 | 69 | 70 | 71 | 72 | 73 | 0 74 | 75 | 76 | 77 | 78 | 79 | 0 80 | 0 81 | 82 | 83 | 84 | 85 | 9 86 | 87 | 88 | 89 | Opening Appimage file, please waith ... 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 300 98 | 0 99 | 100 | 101 | 102 | 103 | 300 104 | 16777215 105 | 106 | 107 | 108 | 109 | 7 110 | 111 | 112 | 113 | false 114 | 115 | 116 | 0 117 | 118 | 119 | 0 120 | 121 | 122 | true 123 | 124 | 125 | Qt::Horizontal 126 | 127 | 128 | false 129 | 130 | 131 | 132 | 133 | 134 | 135 | Qt::Vertical 136 | 137 | 138 | QSizePolicy::Fixed 139 | 140 | 141 | 142 | 20 143 | 4 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 0 154 | 155 | 156 | 157 | 158 | Qt::Vertical 159 | 160 | 161 | QSizePolicy::Fixed 162 | 163 | 164 | 165 | 20 166 | 40 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 0 176 | 0 177 | 178 | 179 | 180 | 181 | 100 182 | 16777215 183 | 184 | 185 | 186 | 187 | 8 188 | 189 | 190 | 191 | Qt::LeftToRight 192 | 193 | 194 | 195 | 196 | 197 | 198 | .. 199 | 200 | 201 | true 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 0 213 | 0 214 | 215 | 216 | 217 | 218 | 0 219 | 0 220 | 221 | 222 | 223 | 224 | 16 225 | 226 | 227 | 228 | 229 | 12 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | :/images/dialog-information.svg 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 0 246 | 0 247 | 248 | 249 | 250 | 251 | 11 252 | 253 | 254 | 255 | Unable to open the appimage file! 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 0 266 | 0 267 | 268 | 269 | 270 | 271 | 300 272 | 300 273 | 274 | 275 | 276 | <html><head/><body><p>Please verify that the appimage file was downloaded properly. If you think this is an error please report it to <a href="https://github.com/AppImage/AppImageKit/issues"><span style=" text-decoration: underline; color:#007af4;">AppImageKit at Github</span></a></p></body></html> 277 | 278 | 279 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 280 | 281 | 282 | true 283 | 284 | 285 | 286 | 287 | 288 | 289 | 20 290 | 291 | 292 | 293 | 294 | Qt::Horizontal 295 | 296 | 297 | QSizePolicy::MinimumExpanding 298 | 299 | 300 | 301 | 40 302 | 20 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | Close 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | -------------------------------------------------------------------------------- /src/first_run/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "gui/UiController.h" 10 | 11 | 12 | QCommandLineParser *createCommandLineParser(const QCoreApplication &app); 13 | 14 | 15 | int main(int argc, char **argv) { 16 | QApplication app(argc, argv); 17 | QApplication::setApplicationName("appimage-first-run"); 18 | 19 | QCommandLineParser *parser = createCommandLineParser(app); 20 | const QStringList args = parser->positionalArguments(); 21 | 22 | Validator validator; 23 | Deployer deployer; 24 | Executor executor; 25 | 26 | UiController controller; 27 | 28 | if (!args.isEmpty()) { 29 | const QString target = args.first(); 30 | 31 | validator.setAppimage(target); 32 | 33 | controller.setValidator(&validator); 34 | controller.setDeployer(&deployer); 35 | controller.setExecutor(&executor); 36 | 37 | controller.exec(); 38 | } else 39 | parser->showHelp(1); 40 | 41 | delete parser; 42 | return app.exec(); 43 | } 44 | 45 | QCommandLineParser *createCommandLineParser(const QCoreApplication &app) { 46 | QCommandLineParser *parser = new QCommandLineParser(); 47 | parser->setApplicationDescription(QObject::tr("AppImage verification and deployment utility")); 48 | parser->addHelpOption(); 49 | 50 | parser->addPositionalArgument("appimage", QObject::tr("The AppImage file to execute.")); 51 | parser->process(app); 52 | return parser; 53 | } 54 | -------------------------------------------------------------------------------- /src/first_run/org.appimage.first_run.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | 4 | Exec=appimage_first_run 5 | TryExec=appimage_first_run 6 | 7 | Icon=appimage 8 | 9 | MimeType=application/x-iso9660-appimage;application/vnd.appimage; 10 | Categories=System; 11 | 12 | Name=AppImage First Run Utility 13 | Comment=First run utility to verify and deploy desktop integration files for AppImages. 14 | 15 | NoDisplay=true -------------------------------------------------------------------------------- /src/user_apps_monitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(CMAKE_AUTOUIC ON) 2 | set(CMAKE_AUTORCC ON) 3 | 4 | find_package(Qt5 COMPONENTS Gui Widgets) 5 | 6 | add_executable(user_apps_monitor 7 | main.cpp 8 | $ 9 | Monitor.h 10 | Monitor.cpp 11 | ) 12 | 13 | target_include_directories(user_apps_monitor 14 | PRIVATE ${libappimage_INCLUDE_DIRECTORIES} 15 | PRIVATE ${CMAKE_SOURCE_DIR}/src/core 16 | ) 17 | 18 | target_link_libraries(user_apps_monitor libappimage Qt5::Core) 19 | 20 | add_dependencies(user_apps_monitor libappimage) 21 | 22 | install(TARGETS user_apps_monitor RUNTIME DESTINATION bin COMPONENT user-apps-monitor) 23 | install(FILES org.appimage.user_app_monitor.desktop DESTINATION /etc/xdg/autostart COMPONENT user-apps-monitor) -------------------------------------------------------------------------------- /src/user_apps_monitor/Monitor.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 3/1/18. 3 | // 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include "Monitor.h" 12 | 13 | void Monitor::setRegistry(Registry *registry) { 14 | Monitor::registry = registry; 15 | } 16 | 17 | void Monitor::setWatcher(QFileSystemWatcher *watcher) { 18 | Q_ASSERT(watcher); 19 | 20 | Monitor::watcher = watcher; 21 | } 22 | 23 | Monitor::Monitor(QObject *parent) : QObject(parent) {} 24 | 25 | void Monitor::sanitizeMenuEntries() { 26 | qDebug() << "Sanitizing menu entries: "; 27 | const auto list = registry->getOrphanDesktopIntegrationFiles(); 28 | for (const QString &path: list) { 29 | QFile::remove(path); 30 | qDebug() << "Deleting: " << path; 31 | } 32 | qDebug() << "Sanitize completed"; 33 | } 34 | 35 | void Monitor::deployMissingEntries() { 36 | qDebug() << "Deploy missing menu entries: "; 37 | const auto list = registry->getApplicationsWithoutDesktopIntegration(); 38 | for (const QString &path: list) { 39 | int result = appimage_register_in_system(path.toLocal8Bit(), true); 40 | if (result) 41 | qWarning() << "Unable to create menu entries for: " << path; 42 | } 43 | qDebug() << "Deploy completed"; 44 | } 45 | 46 | void Monitor::startWatch() { 47 | connect(watcher, &QFileSystemWatcher::directoryChanged, this, &Monitor::handleDirectoryChanged); 48 | } 49 | 50 | void Monitor::handleDirectoryChanged(const QString &) { 51 | sanitizeMenuEntries(); 52 | deployMissingEntries(); 53 | } 54 | -------------------------------------------------------------------------------- /src/user_apps_monitor/Monitor.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by alexis on 3/1/18. 3 | // 4 | 5 | #ifndef APPIMAGE_DESKTOP_INTEGRATION_MONITOR_H 6 | #define APPIMAGE_DESKTOP_INTEGRATION_MONITOR_H 7 | 8 | #include 9 | 10 | class Registry; 11 | class QFileSystemWatcher; 12 | 13 | class Monitor : public QObject { 14 | Q_OBJECT 15 | Registry *registry; 16 | QFileSystemWatcher *watcher; 17 | 18 | public: 19 | Monitor(QObject *parent = nullptr); 20 | 21 | void setRegistry(Registry *registry); 22 | 23 | void setWatcher(QFileSystemWatcher *watcher); 24 | 25 | 26 | void sanitizeMenuEntries(); 27 | 28 | void deployMissingEntries(); 29 | 30 | void startWatch(); 31 | 32 | protected slots: 33 | void handleDirectoryChanged(const QString &path); 34 | }; 35 | 36 | 37 | #endif //APPIMAGE_DESKTOP_INTEGRATION_MONITOR_H 38 | -------------------------------------------------------------------------------- /src/user_apps_monitor/main.cpp: -------------------------------------------------------------------------------- 1 | //de empleo 2 | // Created by alexis on 2/23/18. 3 | // 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include "Monitor.h" 12 | #include "Deployer.h" 13 | 14 | int main(int argc, char **argv) { 15 | QCoreApplication app(argc, argv); 16 | QCoreApplication::setApplicationName("user-apps-monitor"); 17 | 18 | QFileSystemWatcher watcher; 19 | const QStringList watchPaths = { 20 | "/opt", 21 | QDir::homePath() + "/Applications" 22 | }; 23 | 24 | watcher.addPaths(watchPaths); 25 | 26 | Registry r; 27 | r.setDataLocations(QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation)); 28 | r.setAppimageLocations(watchPaths); 29 | 30 | Monitor m; 31 | m.setRegistry(&r); 32 | m.setWatcher(&watcher); 33 | 34 | m.sanitizeMenuEntries(); 35 | m.deployMissingEntries(); 36 | 37 | m.startWatch(); 38 | return app.exec(); 39 | } 40 | -------------------------------------------------------------------------------- /src/user_apps_monitor/org.appimage.user_app_monitor.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | 4 | Exec=user_apps_monitor 5 | TryExec=user_apps_monitor 6 | 7 | Icon=appimage 8 | 9 | Categories=System; 10 | 11 | Name=AppImage User Applications Monitor 12 | Comment="Monitor AppImage files in HOME/Applications and /opt/applications to create or remove proper desktop integration files." 13 | 14 | NoDisplay=true -------------------------------------------------------------------------------- /third-party/gtest.cmake: -------------------------------------------------------------------------------- 1 | message(STATUS "Downloading and building GTest") 2 | 3 | include(ExternalProject) 4 | 5 | ExternalProject_Add(gtest 6 | GIT_REPOSITORY https://github.com/google/googletest.git 7 | GIT_TAG release-1.8.0 8 | UPDATE_COMMAND "" # make sure CMake won't try to updateRepository updates unnecessarily and hence rebuild the dependency every time 9 | CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX= /googletest 10 | ) 11 | 12 | ExternalProject_Get_Property(gtest SOURCE_DIR) 13 | ExternalProject_Get_Property(gtest INSTALL_DIR) 14 | set(gtest_SOURCE_DIR "${SOURCE_DIR}") 15 | set(gtest_INSTALL_DIR "${INSTALL_DIR}") 16 | mark_as_advanced(gtest_SOURCE_DIR gtest_INSTALL_DIR) 17 | 18 | set(gtest_INCLUDE_DIRS "${gtest_INSTALL_DIR}/include/") 19 | set(gtest_LIBRARIES_DIR "${gtest_INSTALL_DIR}/lib") 20 | set(gtest_LIBRARIES "${gtest_LIBRARIES_DIR}/libgtest.a" "${gtest_LIBRARIES_DIR}/libgtest_main.a") 21 | -------------------------------------------------------------------------------- /third-party/libappimage.cmake: -------------------------------------------------------------------------------- 1 | message(STATUS "Downloading and building LibAppImage") 2 | 3 | find_package(AppImageKit QUIET) 4 | 5 | if ( NOT AppImageKit_FOUND) 6 | include(ExternalProject) 7 | 8 | ExternalProject_Add(AppImageKit 9 | GIT_REPOSITORY https://github.com/AppImage/AppImageKit.git 10 | GIT_TAG appimagetool/master 11 | GIT_SUBMODULES "" 12 | CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} 13 | BUILD_COMMAND make gtest libappimage 14 | INSTALL_COMMAND make install DESTDIR= 15 | ) 16 | 17 | ExternalProject_Get_Property(AppImageKit INSTALL_DIR) 18 | set(AppImageKit_INSTALL_DIR ${INSTALL_DIR}) 19 | 20 | set(libappimage_PATH ${AppImageKit_INSTALL_DIR}${CMAKE_INSTALL_PREFIX}/lib/libappimage.so) 21 | set(libappimage_INCLUDE_DIRECTORIES ${AppImageKit_INSTALL_DIR}${CMAKE_INSTALL_PREFIX}/include/) 22 | 23 | 24 | add_library(libappimage SHARED IMPORTED) 25 | 26 | set_target_properties(libappimage PROPERTIES 27 | IMPORTED_LOCATION ${libappimage_PATH} 28 | INCLUDE_DIRECTORIES ${libappimage_INCLUDE_DIRECTORIES} 29 | INTERFACE_LINK_LIBRARIES "glib-2.0" 30 | ) 31 | 32 | add_dependencies(libappimage AppImageKit) 33 | endif(NOT AppImageKit_FOUND) 34 | --------------------------------------------------------------------------------