├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile ├── README.md ├── README.translators.md ├── TODO ├── VERSION ├── development.txt ├── devilspie2.1 ├── devilspie2.desktop ├── doc └── examples │ ├── awesome.lua │ └── file-header.lua ├── po ├── Makefile ├── devilspie2.pot ├── fi.po ├── fr.po ├── it.po ├── ja.po ├── nl.po ├── pt_BR.po ├── ru.po └── sv.po └── src ├── compat.h ├── config.c ├── config.h ├── devilspie2.c ├── error_strings.c ├── error_strings.h ├── intl.h ├── script.c ├── script.h ├── script_functions.c ├── script_functions.h ├── xutils.c └── xutils.h /.gitignore: -------------------------------------------------------------------------------- 1 | bin/devilspie2 2 | build/ 3 | obj/devilspie2.o 4 | obj/script.o 5 | obj/script_functions.o 6 | obj/xutils.o 7 | obj/devilspie2.o 8 | obj/error_strings.o 9 | obj/config.o 10 | obj/gitversion.o 11 | devilspie2 12 | Makefile.dep 13 | po/*.mo 14 | src/#* 15 | src/gitversion.c 16 | sciteprojrc.lua 17 | *~ -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright © 2011-2019 Andreas Rönnquist. 3 | # Copyright © 2019-2021 Darren Salt. 4 | # This file is distributed under the same license 5 | # as the devilspie2 package, see COPYING file. 6 | # 7 | 8 | Authors: 9 | -------- 10 | 11 | Andreas Rönnquist 12 | - Code, Swedish translation 13 | 14 | Ross Burton 15 | - Original Devilspie 16 | 17 | Robin Hahling 18 | - French translation 19 | 20 | Hélder Máximo Botter Ribas 21 | - Brasilian Portugese translation 22 | 23 | Frans de Jonge 24 | - Dutch translation 25 | 26 | Roman V. Nikolaev 27 | - Russian translation 28 | 29 | Andreas Müller 30 | - Patch fixing --folder setting getting overridden in load_scripts 31 | 32 | Hans Nieser 33 | - Patch adding get_workspace_count function 34 | 35 | larchunix 36 | - Patch replacing lua_open with luaL_newstate, to make it work with Lua 5.2. 37 | 38 | Laurent Brachet 39 | - Patch to make set_window_geometry accept negative values 40 | 41 | Johan Lantto 42 | - Finnish translation 43 | 44 | Ronan Barzic 45 | - Function get_screen_geometry 46 | 47 | Hiroshi Hasebe 48 | - Japanese translation 49 | 50 | rbtwrrr 51 | - add boolean argument to set_window_{above, below} 52 | 53 | Toni Spets 54 | - add get_window_is_pinned function 55 | 56 | Nicola Fontana 57 | - Italian translation 58 | - Spelling fixes 59 | - Allow reading of XA_WINDOW properties 60 | 61 | Darren Salt 62 | - Add support for setting and deleting window properties 63 | - Most of the changes since 0.43 64 | 65 | Klaus Ethgen 66 | - Allow reading of XA_UTF8_STRING properties 67 | 68 | Longoon12000 69 | - Initial version of get_process_name 70 | 71 | Mark Cooke 72 | - Allow use of workspace names 73 | - Running rules on window name/title change 74 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2 | ChangeLog: 3 | ---------- 4 | 5 | 0.46 6 | * Converted README files to Markdown. 7 | * Added a time-out for scripts. 8 | * Improved parameter checking (and better error messages). 9 | 10 | 0.45 11 | * Fixes related to Lua version handling 12 | * Misc build fixes 13 | * Add set_on_bottom(): move to bottom of stack 14 | * Change set_on_top() so that it merely raises the window 15 | * Add get_class_group_name(). 16 | This complements get_class_instance_name re. WM_CLASS. 17 | * More aliases for function names containing 'maximize' or 18 | 'minimize': accept -ise spellings 19 | * Visibly deprecate function names containing 'horisontally' 20 | * Add set_adjust_for_decoration(), useful if you have problems with 21 | positioning & resizing of decorated windows [note: experimental] 22 | * Add get_window_frame_extents() 23 | * Allow workspaces to be referenced by name 24 | * Extra event type for running rules on window name/title changes 25 | * Ignore dot files in the scripts directory. 26 | * More UTF-8 support: use_utf8() (sets and reads whether UTF-8 is 27 | default, initially false), window_property_is_utf8() and 28 | window_property_full(). 29 | 30 | 0.44 31 | * Default to Lua 5.3, and permit use of other versions 32 | * Add support for setting and deleting window properties 33 | * Add get_process_name(), which returns the name of the process 34 | owning the window (if possible) 35 | * Add get_monitor_index() and get_monitor_geometry(); improve 36 | monitor index/geometry discovery 37 | * Add get_window_is_decorated() (which uses the Motif window hints) 38 | * Alias center() as centre() 39 | * Extend centre() to allow centring on a given monitor and to allow 40 | horizontal or vertical only 41 | * Extend set_window_position() to allow positioning on a given 42 | monitor and control which corner is measured from. 43 | (Behaviour with two parameters is unchanged.) 44 | * Quote the option hyphens in the man page (preventing replacement) 45 | * Various const & compiler warning (gcc -Wextra) fix-ups 46 | * Support for UTF-8 strings in window properties 47 | * Allow replacements for pkg-config at compile time 48 | 49 | 0.43 50 | * Update contact adresses 51 | * Move homepage to nongnu.org 52 | 53 | 0.42 54 | * Support window focus / blur events 55 | * Add example for Awesome window manager 56 | * Updated French, Italian and Swedish translations 57 | 58 | 0.41 59 | * Set a correct version number 60 | 61 | 0.40 62 | * Add callback for geometry change 63 | * Add error string for one or two indata expected 64 | * Make devilspie2_get_viewport_start return both x 65 | and y coordinates 66 | * Add alternative functionality to set_viewport Now you can set the 67 | coordinates to the window if you use two integers as indata 68 | * New Italian translation, updated Dutch, Japanese and Swedish 69 | translations 70 | * Build flags hardening fixes 71 | * Allow reading of XA_WINDOW properties 72 | 73 | 0.39 74 | * Fix proper flushing of debugging output 75 | * Some source formatting fixes 76 | * add get_window_is_pinned function 77 | * Make buildable with a custom CC like clang 78 | 79 | 0.38 80 | * Add documentation of xy and xywh functions 81 | * Source cleanups 82 | * Move setting of current window variable 83 | 84 | 0.37 85 | * Replace google group with savannah mailinglist 86 | * Add xy and xywh functions 87 | 88 | 0.36 89 | * _Really_ fix the man page commenting style 90 | * Remove version and date from man-page 91 | 92 | 0.35 93 | * Fix man page commenting 94 | 95 | 0.34 96 | * Add GPL headers in more places where needed 97 | * Fix cppcheck reassignment warning 98 | * Install man-page with Makefile too 99 | 100 | 0.33 101 | * Add boolean argument to set_window_{above,below} (Thanks to rbtwrrr) 102 | * Fix spelling of horizontally in all places 103 | * Various source formatting fixes 104 | 105 | 0.32 106 | * Add functions get_fullscreen (get_window_fullscreen) 107 | * Small documentation fixes 108 | * Add set_window_strut function 109 | * gdk_display_get_n_screens is deprecated on GLIB >= 3.10, there we default 110 | to only one screen. 111 | * Updated Russian translation 112 | 113 | 0.31 114 | * Add close_window function 115 | * Remove unused C function my_wnck_get_cardinal 116 | * Fix string problems reported by pscan 117 | * Updated Russian translation 118 | * Added Japanese translation 119 | 120 | 0.30 121 | * Update French translation 122 | * Add function set_window_opacity to do the same as set_opacity 123 | * Add maximize_horizontally with same functionality as 124 | maximize_horisontally 125 | * Add get_window_is_maximized_horizontally with same functionality as 126 | get_window_is_maximized_horisontally 127 | * Add focus and focus_window functions 128 | * Updated Brasilian-Portugese translation 129 | 130 | 0.29 131 | * Add finnish translation 132 | * Updated dutch translation 133 | * Add examples to get_window_geometry and get_window_client_geometry 134 | * Add get_screen_geometry function (Thanks to Ronan Barzic) 135 | 136 | 0.28 137 | * Make get workspace error string consistent with other past-tense strings 138 | * wnck_class_group_get_res_class is deprecated, use wnck_class_group_get_id 139 | instead on wnck versions it isn't available 140 | * Make 'relative window positioning' possible, allowing negative values to 141 | set_window_geometry 142 | * Remove sciteproj project file 143 | * Add set_window_type function 144 | * Add set_window_opacity function 145 | * Added handling of window closing events 146 | * Add file monitor to automatically load added scripts 147 | 148 | 0.27 149 | * Update Makefile to fix a Lua problem with pkg-config 150 | * Update the email contact address in the README 151 | * Add get_workspace_count function - Thanks Hans Nieser! 152 | * Use luaL_newstate instead of lua_open which is deprecated 153 | 154 | 0.26 155 | * Add "center" function 156 | * Register set_window_position2 under the correct name - Fixes 157 | bug where set_window_position2 couldn't be found 158 | * Add a text file describing development for people who 159 | want to join 160 | * Add a TODO file 161 | * Updated translations 162 | 163 | 0.25 164 | * Add set_viewport function 165 | * Move error strings to a source file of their own 166 | * Updated translations - Thanks guys! 167 | * Make it possible to build using -j without screwing up 168 | translation build 169 | 170 | 0.24 171 | * Fix bug where folder settings got overridden 172 | - Thanks Andreas Müller! 173 | * Add set_window_fullscreen function 174 | * Add some required checks for running in emulation mode 175 | 176 | 0.23 177 | * Added Russian translation - Thanks to Roman V. Nikolaev 178 | * Fix a string memory leak 179 | * Some source cleanups 180 | 181 | 0.22 182 | * Make scripts keep their environment between runs - Makes it possible 183 | to do something to a window class the "n-th" time a window of that 184 | class opens. 185 | * Documentation and translation updates. 186 | 187 | 0.21 188 | * Add get_window_is_maximized, get_window_is_maximized_horisontally 189 | and get_window_is_maximized_vertically functions 190 | * Add set_window_geometry2 and set_window_position2 functions, 191 | giving more similar behaviour to original devilspie functionality 192 | * Add set_window_above and set_window_below functions 193 | * Add get_window_type function 194 | * Add get_class_instance_name function 195 | * Add get_window_property function 196 | * Add get_window_role function 197 | * Add get_window_xid function 198 | * Add get_window_class function 199 | * Sort the list of scripts loaded, making it easier to determine script 200 | loading order. 201 | * Require an X11 display to run on GTK3 202 | * Updated translations (Thanks guys!) 203 | 204 | 0.20 205 | * Add get_window_has_name function 206 | * Added Brasilian Portugese translation 207 | - thanks to Hélder Máximo Botter Ribas 208 | * Massive whitespace fixes in the source 209 | * Documentation updates 210 | * Add linking to X11 (fixes linker error on some ports) 211 | 212 | 0.19 213 | * Add C preprocessor flags to build system 214 | * Minor update to documentation for translators 215 | 216 | 0.18 217 | * Translation fixes 218 | * Minor translation documentation fixes 219 | * Minor cleanups and fixes 220 | * Added French translation - thanks to Robin Hahling 221 | 222 | 0.17 223 | * Fix build warning for string not using %s 224 | 225 | 0.16 226 | * Documentation updates 227 | * Add get_window_geometry and get_client_window_geometry functions 228 | * Add option to get system wnck version (on systems that support it) 229 | * Added gettext support for translations, and added Swedish translation 230 | * Add set_skip_tasklist function 231 | * Add set_skip_pager function 232 | 233 | 0.15 234 | * Fix GPL headers, which incorrectly was LGPL 235 | * Minor documentation fixes 236 | 237 | 0.14 238 | * Better checks for valid windows 239 | * Source code commenting updates 240 | * Minor documentation updates 241 | 242 | 0.13 243 | * Updated example in the README and other documentation updates 244 | * Makefile updates 245 | 246 | 0.12 247 | * Fixes to the Makefile, fixing the depends system, fixing installation 248 | prefxes 249 | 250 | 0.11 251 | * Fix a build problem where standard C-flags wouldn't be included in makefile 252 | * Fix incorrect debug stuff to the makefile 253 | 254 | 0.10 255 | * Fixed a problem that made the project link even if no objects had changed 256 | * Default to build using GTK3, and add option to build using GTK2 257 | * Documentation fixes 258 | 259 | 0.09 260 | * Fixes to the Makefile 261 | * Minor documentation updates 262 | 263 | 0.08 264 | * Fix manpage problems 265 | 266 | 0.07 267 | * Fixes to the build system 268 | * Fixes of previous sloppy releases 269 | * Minor documentation updates 270 | 271 | 0.05 272 | * Update Makefile to allow CFLAGS changes, required by CDBS 273 | 274 | 0.04 275 | * Build system updates 276 | 277 | 0.03 278 | * Remove CMake stuff and go to a standard Makefile 279 | * Documentation updates 280 | * Move installation instructions to file of its own 281 | 282 | 0.02 283 | * Rename set_workspace to set_window_workspace 284 | * Massive documentation updates 285 | 286 | 0.01 287 | * Initial release 288 | 289 | 290 | -------------------------------------------------------------------------------- 291 | 292 | Copyright © 2011-2017 Andreas Rönnquist. 293 | This file is distributed under the same license 294 | as the devilspie2 package, see COPYING file. 295 | 296 | -------------------------------------------------------------------------------- 297 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright © 2011-2024 devilspie2 developers 3 | # This file is distributed under the same license 4 | # as the devilspie2 package, see COPYING file. 5 | # 6 | 7 | 8 | Installation: 9 | ------------- 10 | 11 | Building Devilspie2 requires pkg-config, gtk, wnck and lua libraries. On a 12 | Debian system, installing the following packages should do it: 13 | 14 | pkg-config 15 | libglib2.0-dev 16 | liblua5.3-0-dev 17 | libwnck-3-dev 18 | libgtk-3-dev 19 | libxrandr-dev (optional) 20 | 21 | On a system still using Gtk version 2, replace the wnck and gtk libs with: 22 | 23 | libwnck-dev 24 | libgtk2.0-dev 25 | 26 | 27 | To build, you simply do a 28 | 29 | make 30 | 31 | (which will build with Gtk3 libs) or 32 | 33 | make GTK2=on 34 | 35 | to make the build use the Gtk2 libs. 36 | 37 | You can use other versions of Lua. For example: 38 | 39 | make LUA=lua5.1 40 | make LUA=lua5.4 41 | 42 | You can build without xrandr: 43 | 44 | make NO_XRANDR=yes 45 | 46 | This will in the end create the devilspie2 binary in the bin/ folder. 47 | To build the same executable with debugging enabled, run 48 | 49 | make DEBUG=1 50 | 51 | Note that this may not do a full build – if you've been compiling without 52 | DEBUG=1, you should run “make clean” first.. 53 | 54 | (Any value works for GTK2, NO_XRANDR and DEBUG; it only matters whether 55 | they're defined.) 56 | 57 | 58 | To install Devilspie2 system-wide, run make install as superuser: 59 | 60 | su -c "make install" 61 | 62 | or on systems using sudo: 63 | 64 | sudo make install 65 | 66 | This will default to /usr/local, installing the binary to /usr/local/bin - 67 | this can be changed using PREFIX variable, and need to applied all through 68 | the build system. 69 | 70 | make PREFIX=/usr 71 | sudo make PREFIX=/usr install 72 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of devilspie2 3 | # Copyright (C) 2011-2016 Andreas Rönnquist 4 | # Copyright (C) 2019-2021 Darren Salt 5 | # 6 | # devilspie2 is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # devilspie2 is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with devilspie2. 18 | # If not, see . 19 | # 20 | 21 | ifndef CC 22 | CC=gcc 23 | endif 24 | ifndef PKG_CONFIG 25 | PKG_CONFIG=pkg-config 26 | endif 27 | SRC=src 28 | OBJ=obj 29 | BIN=bin 30 | 31 | ifndef LUA 32 | LUA=lua5.3 33 | endif 34 | 35 | # Some hardening by default. 36 | # Set default optimisation; override CFLAGS if DEBUG is set. 37 | STD_CFLAGS=-Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 38 | ifdef DEBUG 39 | STD_CFLAGS += -D_DEBUG 40 | CFLAGS = -Og -g3 -ggdb 41 | else 42 | CFLAGS ?= -O2 43 | endif 44 | 45 | DEPEND=Makefile.dep 46 | 47 | OBJECTS=$(OBJ)/config.o $(OBJ)/devilspie2.o $(OBJ)/xutils.o $(OBJ)/script.o $(OBJ)/script_functions.o $(OBJ)/error_strings.o 48 | 49 | ifndef PREFIX 50 | ifdef INSTALL_PREFIX 51 | PREFIX=$(INSTALL_PREFIX) 52 | else 53 | PREFIX=/usr/local 54 | endif 55 | endif 56 | 57 | NAME = devilspie2 58 | PROG=$(BIN)/$(NAME) 59 | VERSION = $(shell cat ./VERSION) 60 | DATADIR = ${DESTDIR}${PREFIX}/share 61 | LOCALEDIR = ${DATADIR}/locale 62 | MANDIR = ${DATADIR}/man 63 | # /etc if installing in /usr, else ${PREFIX}/etc 64 | # if this isn't right, submit a patch 65 | ETCDIR = ${DESTDIR}$(if $(patsubst /usr,,${PREFIX}),${PREFIX},)/etc 66 | APPDIR = ${ETCDIR}/xdg/autostart 67 | MANPAGE = ${NAME}.1 68 | 69 | ifdef GTK2 70 | PKG_GTK=gtk+-2.0 71 | PKG_WNCK=libwnck-1.0 72 | 73 | CHECK_GTK3=1 74 | else 75 | PKG_GTK=gtk+-3.0 76 | PKG_WNCK=libwnck-3.0 77 | endif 78 | 79 | LUA_LIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags --silence-errors $(LUA) || $(PKG_CONFIG) --cflags lua) 80 | LUA_LIBS := $(shell $(PKG_CONFIG) --libs --silence-errors $(LUA) || $(PKG_CONFIG) --libs lua) 81 | 82 | ifndef NO_XRANDR 83 | RANDR_LIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags xrandr) 84 | RANDR_LIBS := $(shell $(PKG_CONFIG) --libs xrandr) 85 | ifneq (,$(RANDR_LIBS)) 86 | RANDR_LIB_CFLAGS += -DHAVE_XRANDR 87 | endif 88 | else 89 | RANDR_LIB_CFLAGS := 90 | RANDR_LIBS := 91 | endif 92 | 93 | LIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_GTK) $(PKG_WNCK)) $(LUA_LIB_CFLAGS) $(RANDR_LIB_CFLAGS) 94 | STD_LDFLAGS= 95 | LIBS := -lX11 -lXinerama $(shell $(PKG_CONFIG) --libs $(PKG_GTK) $(PKG_WNCK)) $(LUA_LIBS) $(RANDR_LIBS) 96 | 97 | LOCAL_CFLAGS=$(STD_CFLAGS) $(DEPRECATED) $(CFLAGS) $(LIB_CFLAGS) 98 | LOCAL_LDFLAGS=$(STD_CFLAGS) $(LDFLAGS) $(STD_LDFLAGS) 99 | 100 | LOCAL_CPPFLAGS=$(CPPFLAGS) 101 | 102 | ifdef CHECK_GTK3 103 | LOCAL_CFLAGS+=-DGTK_DISABLE_SINGLE_INCLUDES 104 | LOCAL_CFLAGS+=-DGSEAL_ENABLE 105 | 106 | CHECK_DEPRECATED=1 107 | endif 108 | 109 | ifdef CHECK_DEPRECATED 110 | LOCAL_CFLAGS+=-DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED 111 | endif 112 | 113 | LOCAL_CFLAGS+=-DLOCALEDIR=\"$(LOCALEDIR)\" -DPACKAGE=\"$(NAME)\" -DDEVILSPIE2_VERSION=\"$(VERSION)\" 114 | 115 | .PHONY: all .lua 116 | all: .lua $(BIN)/$(NAME) 117 | ${MAKE} -C po -j1 all 118 | 119 | .lua: 120 | @if $(PKG_CONFIG) --cflags --silence-errors $(LUA) >/dev/null; then :; else echo '$(LUA) dev files not found - falling back on system default lua' >&2; fi 121 | 122 | $(OBJ)/%.o: $(SRC)/%.c 123 | @mkdir -p $(OBJ) 124 | $(CC) $(LOCAL_CFLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@ 125 | 126 | $(BIN)/$(NAME): $(OBJECTS) 127 | @mkdir -p -- $(BIN) 128 | $(CC) $(LOCAL_CFLAGS) $(LOCAL_LDFLAGS) $(OBJECTS) -o $(PROG) $(LIBS) 129 | 130 | .PHONY: clean 131 | clean: 132 | rm -rf -- $(OBJECTS) $(PROG) $(DEPEND) 133 | test ! -d $(BIN) || rmdir -- $(BIN) 134 | test ! -d $(OBJ) || rmdir -- $(OBJ) 135 | ${MAKE} -C po clean 136 | 137 | install: 138 | install -d $(DESTDIR)$(PREFIX)/bin 139 | install -m 755 $(PROG) $(DESTDIR)$(PREFIX)/bin 140 | install -d $(MANDIR)/man1 141 | install -m 644 $(MANPAGE) $(MANDIR)/man1 142 | install -d $(APPDIR) 143 | install -m 644 $(NAME).desktop $(APPDIR) 144 | ${MAKE} -C po install 145 | 146 | .PHONY: uninstall 147 | uninstall: 148 | rm -f $(DESTDIR)$(PREFIX)/$(PROG) 149 | ${MAKE} -C po uninstall 150 | 151 | $(DEPEND): 152 | $(CC) -MM $(LOCAL_CFLAGS) $(SRC)/*.c | sed -e "s/\([A-Za-z0-9+-0._&+-]*:\)/\$(OBJ)\/\1/g" > $(DEPEND) 153 | 154 | -include $(DEPEND) 155 | 156 | .PHONY: release 157 | VERSION = $(subst /,_,$(file 102 | 103 | Debug helper which prints a string to `stdout` if `devilspie2` is run with 104 | the `--debug` option; otherwise does nothing. 105 | 106 | ### Getters 107 | 108 | Then there are the functions to get the properties of a window, and related 109 | information: 110 | 111 | * `get_window_name()` 112 | 113 | 114 | Returns a string containing the name of the current window. 115 | 116 | * `get_window_has_name()` 117 | 118 | 119 | Returns a boolean value indicating whether the window has a name. 120 | 121 | *(Available from version 0.20)* 122 | 123 | * `get_application_name()` 124 | 125 | 126 | Returns the application name of the current window. 127 | 128 | * `get_process_name()` 129 | 130 | 131 | Returns the name of the process owning the current window. 132 | 133 | On (at least) Linux, the process name is read from `/proc//comm`. If 134 | that's not possible, `ps` is launched in a shell. For this reason, you 135 | should avoid calling `get_process_name()` more than necessary. 136 | 137 | *This function is not compatible with busybox `ps`.* 138 | 139 | *(Available from version 0.44)* 140 | 141 | * `get_window_geometry()` 142 | 143 | 144 | Returns the window geometry as four numbers - x-position, y-position, 145 | width and height. For example, you can do something like this: 146 | 147 | ```lua 148 | x, y, width, height = get_window_geometry(); 149 | print("X: "..x..", Y: "..y..", width: "..width..", height: "..height); 150 | ``` 151 | 152 | *(Available from version 0.16)* 153 | 154 | * `get_window_client_geometry()` 155 | 156 | 157 | Returns the window geometry excluding the window manager borders as four 158 | numbers, x-position, y-position, width and height. 159 | 160 | See [`get_window_geometry`](#user-content-get-window-geometry) for an 161 | example on how to use this function. 162 | 163 | *(Available from version 0.16)* 164 | 165 | * `get_window_frame_extents()` 166 | 167 | 168 | Returns the window frame extents as four numbers: left, right, top, bottom. 169 | 170 | *(Available from version 0.45.)* 171 | 172 | * `get_window_is_maximised` 173 | 181 | 182 | Returns `true` if the window is vertically maximised, `false` otherwise. 183 | 184 | *(Available from version 0.21; -`ise` from 0.45)* 185 | 186 | * `get_window_is_maximised_horizontally()` 187 | 188 | 189 | Returns `true` if the window is horizontally maximised, `false` otherwise. 190 | 191 | *(Available from version 0.21; -`ise` from 0.45)* 192 | 193 | * `get_window_is_decorated()` 194 | 195 | 196 | Returns `true` if the window is decorated, `false` otherwise. 197 | 198 | *(Available from version 0.44.)* 199 | 200 | * `get_window_type()` 201 | 202 | 203 | Returns the type of the window. The result type is a string, and can 204 | be one of the following: 205 | * `WINDOW_TYPE_NORMAL` 206 | * `WINDOW_TYPE_DESKTOP` 207 | * `WINDOW_TYPE_DOCK` 208 | * `WINDOW_TYPE_DIALOG` 209 | * `WINDOW_TYPE_TOOLBAR` 210 | * `WINDOW_TYPE_MENU` 211 | * `WINDOW_TYPE_UTILITY` 212 | * `WINDOW_TYPE_SPLASHSCREEN` 213 | * `WINDOW_TYPE_UNRECOGNIZED` (if libwnck didn't recognise the type) 214 | * `WINDOW_ERROR` (if there's no window to work on) 215 | 216 | *(Available from version 0.21)* 217 | 218 | * `get_class_instance_name()` 219 | 220 | 221 | Get the class instance name from the WM_CLASS property for the current 222 | window. 223 | 224 | *(Available from version 0.21; requires libwnck 3+)* 225 | 226 | * `get_class_group_name()` 227 | 228 | 229 | Get the class group name from the WM_CLASS Property for the current 230 | window. 231 | 232 | *(Available from version 0.21; requires libwnck 3+)* 233 | 234 | * `get_window_property(string property)` 235 | 236 | 237 | Returns the value of the named window property. For a list of available 238 | properties, see the [Freedesktop EWMH specification](http://standards.freedesktop.org/wm-spec/wm-spec-latest.html). 239 | 240 | From 0.45, returns `nil` if the property doesn't exist. 241 | 242 | *(Available from version 0.21)* 243 | 244 | * `window_property_is_utf8(string property)` 245 | 246 | 247 | Returns whether the named window property is UTF-8. 248 | (Always returns `true` for properties which are converted to string.) 249 | 250 | Returns `nil` if the property doesn't exist. 251 | 252 | *(Available from version 0.45)* 253 | 254 | * `get_window_property_full(string property)` 255 | 256 | 257 | Returns a list suitable for assignment to two variables, equivalent to calling 258 | ```lua 259 | get_window_property(property), window_property_is_utf8(property) 260 | ``` 261 | Returns `nil` if the property doesn't exist. 262 | 263 | *(Available from version 0.45)* 264 | 265 | * `get_window_role()` 266 | 267 | 268 | Returns a string describing the current window role of the matched window as 269 | defined by its `WM_WINDOW_ROLE` hint. 270 | 271 | * `get_window_xid()` 272 | 273 | 274 | Returns the X window id of the current window. 275 | 276 | * `get_window_class()` 277 | 278 | 279 | Returns a string representing the class of the current window. 280 | 281 | * `get_workspace_count()` 282 | 283 | 284 | Returns the number of workspaces available. 285 | 286 | *(Available from version 0.27)* 287 | 288 | * `get_screen_geometry()` 289 | 290 | 291 | Returns the screen geometry (two numbers) for the screen of the 292 | current window. 293 | 294 | *(Available from version 0.29)* 295 | 296 | * `get_window_fullscreen()` 297 | 298 | 299 | Returns `true` if the window is fullscreen, `false` otherwise. 300 | 301 | *(Available from version 0.32)* 302 | 303 | * `get_monitor_index()` 304 | 305 | 306 | Returns the index of the monitor containing the window centre (or some 307 | part of the window). 308 | 309 | *(Available from version 0.44)* 310 | 311 | * `get_monitor_geometry([int index])` 312 | 313 | 314 | Returns x, y, width, height for the given monitor or, 315 | without parameters, for the window's monitor. 316 | 317 | If the index is out of range, nothing is returned. 318 | 319 | *(Available from version 0.44 without parameter)* 320 | 321 | ### Setters 322 | 323 | And the rest of the commands are used to modify the properties of the windows: 324 | 325 | * `set_adjust_for_decoration([bool])` 326 | 327 | 328 | Allow for situations where moving or resizing the window is done 329 | incorrectly, i.e. 330 | ```lua 331 | set_window_position(0,0) 332 | ``` 333 | results in the window decoration being taken into account twice, i.e. 334 | the window (including decoration) is offset from the top left corner by 335 | the width of the left side decoration and the height of the title bar. 336 | 337 | This is currently off by default, and is sticky: if you do not explicitly 338 | set it in your script, its current value is retained. 339 | 340 | If used, it should be used at the start of the script. 341 | 342 | This affects the following functions: 343 | * [`set_window_geometry`](#user-content-set-window-geometry) 344 | * [`set_window_position`](#user-content-set-window-position) 345 | * [`set_window_size`](#user-content-set-window-size) 346 | * [`xy`](#user-content-xy) 347 | * [`xywh`](#user-content-xywh) 348 | 349 | *(Available from version 0.45)* 350 | 351 | * `set_window_position(int xpos, int ypos, [int index])` 352 | 353 | 354 | Set the position of a window. 355 | 356 | If `index` is specified then the co-ordinates are relative to a corner of 357 | the specified monitor (counting from 1) on the current workspace. Which 358 | corner is determined by the co-ordinates' signs: 359 | * +ve `X` ⇒ left, -ve `X` ⇒ right; 360 | * +ve `Y` ⇒ top, -ve `Y` ⇒ bottom. 361 | 362 | **NOTE:** since `-0` would have a use here but is equal to `+0`, `~` 363 | (bitwise NOT) is used. To put the window 60 pixels from the right or bottom, 364 | use `~60` or `-61`. 365 | 366 | If `index` = `0` then the ‘current’ monitor (with the window's centre 367 | point) is used (falling back on then the first monitor showing part of the 368 | window then the first monitor). 369 | 370 | If `index` = `-1` then all monitors are treated as one large virtual 371 | monitor. 372 | 373 | *(`index` parameter available from 0.46)* 374 | 375 | * `set_window_position2(int xpos, int ypos, [int index])` 376 | 377 | 378 | Set the position of a window. Parameters are as for 379 | [`set_window_position`](#user-content-set_window_position). 380 | 381 | This function uses `XMoveWindow` instead of `wnck_window_set_geometry`; this 382 | gives a slightly different result. 383 | 384 | *(Available from version 0.21, `index` from 0.46)* 385 | 386 | * `set_window_property(string property, int-or-string value, [bool utf8])` 387 | 388 | 389 | Set a property of a window to a string or a cardinal (32-bit integer or 390 | boolean). 391 | 392 | Optionally takes a boolean to indicate `UTF8_STRING` properties. The 393 | default is initially `false` and can be set via 394 | [`use_utf8()`](#user-content-use-utf8). Ignored for non-string values. 395 | 396 | *(Available from version 0.44; UTF-8 option available from version 0.45.)* 397 | 398 | * `delete_window_property(string property)` 399 | 400 | 401 | Remove a property from a window. 402 | 403 | *(Available from version 0.44)* 404 | 405 | * `set_window_size(int width, int height)` 406 | 407 | 408 | Set the size of a window. 409 | 410 | * `set_window_geometry(int xpos, int ypos, int width, int height, [int index])` 411 | 412 | 413 | Set both size and position of a window in one command. 414 | 415 | The `index` parameter works exactly as for 416 | [`set_window_position()`](#user-content-set-window-position) and affects 417 | the given coordinates in the same way. 418 | 419 | *(`index` parameter available from 0.46)* 420 | 421 | * `set_window_geometry2(int xpos, int ypos, int width, int height, [int index])` 422 | 423 | 424 | Set the window geometry as for 425 | [`set_window_geometry()`](#user-content-set-window-geometry), but using 426 | `XMoveResizeWindow` instead of its libwnck alternative. This may result 427 | in different coordinates, more like the original devilspie geometry 428 | function. 429 | 430 | *(Available from version 0.21; `index` from 0.46)* 431 | 432 | * `shade()` 433 | 434 | 435 | “Shade” a window, showing only the title-bar. 436 | 437 | * `unshade()` 438 | 439 | 440 | Unshade a window; the opposite of [`shade()`](#user-content-shade). 441 | 442 | * `maximise()` 443 | 444 | 445 | Maximise a window. 446 | 447 | (-`ise` from 0.45) 448 | 449 | * `unmaximise()` 450 | 451 | 452 | Unmaximise a window. 453 | 454 | (-`ise` from 0.45) 455 | 456 | * `maximise_vertically()` 457 | 458 | 459 | Maximise the current window vertically. 460 | 461 | (-`ise` from 0.45) 462 | 463 | * `maximise_horizontally()` 464 | 465 | 466 | Maximise the current window horizontally. 467 | 468 | (-`ise` from 0.45) 469 | 470 | * `minimise()` 471 | 472 | 473 | Minimise a window. 474 | 475 | (-`ise` from 0.45) 476 | 477 | * `unminimise()` 478 | 479 | 480 | Unminimise a window: brings it back to screen from the minimised 481 | position/size. 482 | 483 | (-`ise` from 0.45) 484 | 485 | * `decorate_window()` 486 | 487 | 488 | Show all (relevant) window decoration. 489 | 490 | * `undecorate_window()` 491 | 492 | 493 | Hide all window decoration. 494 | 495 | * `close_window()` 496 | 497 | 498 | Close the window. 499 | 500 | *(Available from 0.31)* 501 | 502 | * `set_window_workspace(int-or-string workspace)` 503 | 504 | 505 | Move a window to another workspace. 506 | Indicated as a 1-based number or a workspace name. 507 | 508 | * `change_workspace(int-or-string workspace)` 509 | 510 | 511 | Change the current workspace to another. 512 | Indicated as a 1-based number or a workspace name. 513 | 514 | * `pin_window()` 515 | 516 | 517 | Ask the window manager to put the window on all workspaces. 518 | 519 | * `unpin_window()` 520 | 521 | 522 | Ask the window manager to put window only in the currently active 523 | workspace. 524 | 525 | * `stick_window()` 526 | 527 | 528 | Ask the window manager to keep the window's position fixed on the screen, 529 | even when the workspace or viewport scrolls. 530 | 531 | * `unstick_window()` 532 | 533 | 534 | Ask the window manager not to have window's position fixed on the screen 535 | when the workspace or viewport scrolls. 536 | 537 | * `set_skip_tasklist(bool skip)` 538 | 539 | 540 | Set this to `true` if you would like the window to skip listing in your 541 | tasklist, or `false` if not. 542 | 543 | *(Available from version 0.16)* 544 | 545 | * `set_skip_pager(bool skip)` 546 | 547 | 548 | Set this to `true` if you would like the window to skip listing in your 549 | pager, or `false` if not. 550 | 551 | *(Available from version 0.16)* 552 | 553 | * `set_window_above([bool above = true])` 554 | 555 | 556 | Set the current window “always on top” (moves it to the top layer, above 557 | most windows) or, if `above` = `false`, clears “always on top” and “always 558 | below” (moves it to the middle, default, layer). 559 | 560 | *(Available from version 0.21)* 561 | 562 | * `set_window_below([bool below = true])` 563 | 564 | 565 | Set the current window “always below” (moves it to the bottom layer, 566 | below most windows) or, if `below` = `false`, clears “always on top” and 567 | “always below” (moves it to the middle, default, layer). 568 | 569 | *(Available from version 0.21)* 570 | 571 | * `set_on_top()` 572 | 573 | 574 | Raise the window to the top of its layer. 575 | 576 | (Prior to version 0.45, this was the same as `set_window_above`.) 577 | 578 | * `set_on_bottom()` 579 | 580 | 581 | Lower a window to the bottom of its layer. 582 | 583 | *(Available from version 0.45.)* 584 | 585 | * `set_window_fullscreen(bool fullscreen)` 586 | 587 | 588 | Ask the window manager to set or clear the fullscreen state of the 589 | window according to `fullscreen`. 590 | 591 | *(Available from version 0.24)* 592 | 593 | * `set_viewport(int viewport)` 594 | * `set_viewport(int x, int y)` 595 | 596 | 597 | **With one parameter,** move the window to the requested viewport. 598 | Counting starts at 1. 599 | 600 | *(Available from version 0.25)* 601 | 602 | **With two parameters,** move the window to the requested position 603 | within the viewport. 604 | 605 | *(Available from version 0.40)* 606 | 607 | * `centre([int index = -1,] [string direction = nil])` 608 | 609 | 610 | Centre the window on one monitor or across all monitors, according to the 611 | following rules: 612 | 613 | * If `index` = `-1`, all monitors are treated as one large virtual monitor. 614 | * If `index` = `0`, the ‘current’ monitor (with the window's centre point) 615 | is used (falling back on then the first monitor showing part of the 616 | window then the first monitor); 617 | * If `index` is out of range then the first monitor is used. 618 | * Otherwise, the window is centred on the specified monitor. 619 | 620 | * If `direction` begins with `H` or `h`, the window is horizontally 621 | centred only. 622 | * If `direction` begins with `V` or `v`, the window is vertically 623 | centred only. 624 | * Otherwise it is centred along both axes. 625 | 626 | If centring only along one axis, the window may be moved along the other 627 | axis to ensure that it is on the specified monitor. 628 | 629 | *(Available from version 0.40; as `center` and without parameters from 0.26)* 630 | 631 | * `set_window_opacity(float value)` 632 | 633 | 634 | Set the window opacity to the given fractional value. 635 | `1.0` is completely opaque, `0.0` is completely transparent. 636 | 637 | *(Available from version 0.29; as `set_opacity` from 0.28)* 638 | 639 | * `set_window_type(string type)` 640 | 641 | 642 | Set the window type, according to `_NET_WM_WINDOW_TYPE`. The allowed types 643 | are the standard `_NET_WM` ones (formatted as a string): 644 | 645 | * `_NET_WM_WINDOW_TYPE_DESKTOP` 646 | * `_NET_WM_WINDOW_TYPE_DOCK` 647 | * `_NET_WM_WINDOW_TYPE_TOOLBAR` 648 | * `_NET_WM_WINDOW_TYPE_MENU` 649 | * `_NET_WM_WINDOW_TYPE_UTILITY` 650 | * `_NET_WM_WINDOW_TYPE_SPLASH` 651 | * `_NET_WM_WINDOW_TYPE_DIALOG` 652 | * `_NET_WM_WINDOW_TYPE_NORMAL` 653 | 654 | You may omit `_NET_WM_`. 655 | 656 | *(Available from version 0.28)* 657 | 658 | * `focus_window()` 659 | 660 | 661 | Focus the current window. 662 | 663 | *(Available from version 0.30)* 664 | 665 | * `set_window_strut(int left, int right, int top, int bottom, int ...)` 666 | 667 | 668 | Set the reserved area at the borders of the desktop for a docking area such 669 | as a taskbar or a panel. *Will handle up to 12 values.* 670 | 671 | Default minimum values are 0 and default maximum values are taken 672 | from the screen size (current or maximum, depending on whether 673 | `xrandr` is used). 674 | 675 | *(Available from version 0.32)* 676 | 677 | * `get_window_strut()` 678 | 679 | 680 | Get the reserved area at the borders of the desktop for a docking 681 | area such as a taskbar or a panel. 682 | 683 | Returns a table (12 integers as for `_NET_WM_WINDOW_STRUT_PARTIAL`) or 684 | `nil`. If `_NET_WM_WINDOW_STRUT` was read then defaults are used as for 685 | [`set_window_strut()`](#user-content-set-window-strut). 686 | 687 | *(Available from version 0.45)* 688 | 689 | * `xy([x, y])` 690 | 691 | 692 | With parameters, set the position of a window. 693 | 694 | Without, returns the position of a window. 695 | 696 | * `xywh([int x, int y, int w, int h])` 697 | 698 | 699 | With parameters, set the position and size of a window. 700 | 701 | Without, returns the position and size of a window. 702 | 703 | ### Utilities 704 | 705 | * `use_utf8([bool])` 706 | 707 | 708 | Controls whether string-setting functions assume UTF-8 by default. 709 | If no value is supplied, the setting is left unchanged. 710 | Returns the previous value. 711 | 712 | This is initially `false`. 713 | 714 | *(Available from version 0.45)* 715 | 716 | * `millisleep(int time)` 717 | 718 | 719 | Sleep for a number of milliseconds, between 1 and 1000 (1 second). 720 | 721 | This is a convenience function so that you don't have to use `os.execute` 722 | (to run `sleep`) or (from LuaPosix `posix.time`) `nanosleep`. 723 | 724 | *(Available from version 0.46)* 725 | 726 | ### Function aliases 727 | 728 | * [`get_window_is_maximized`](#user-content-get_window_is_maximised) 729 | 730 | * [`get_window_is_maximized_vertically`](#user-content-get_window_is_maximised_vertically) 731 | 732 | * [`get_window_is_maximized_horizontally`](#user-content-get_window_is_maximised_horizontally) 733 | 734 | * [`get_fullscreen`](#user-content-get-window-fullscreen`) 735 | 736 | * [`maximize`](#user-content-maximise) 737 | 738 | * [`unmaximize`](#user-content-unmaximise) 739 | 740 | * [`maximize_vertically`](#user-content-maximise-vertically) 741 | 742 | * [`maximize_horizontally`](#user-content-maximise_horizontally) 743 | 744 | * [`minimize`](#user-content-minimise) 745 | 746 | * [`unminimize`](#user-content-unminimise) 747 | 748 | * [`center`](#user-content-centre) 749 | 750 | * [`set_opacity`](#user-content-set-window-opacity`) 751 | 752 | * [`focus`](#user-content-focus-window`) 753 | 754 | 755 | 756 | ### Simple script examples 757 | 758 | **Showing debug output and resizing and maximisation of specific windows:** 759 | 760 | ```lua 761 | -- the debug_print command only prints to stdout 762 | -- if devilspie2 is run using the '--debug' option 763 | debug_print("Window name: " .. get_window_name()); 764 | debug_print("Application name: " .. get_application_name()) 765 | 766 | -- I want my Xfce4 terminal to the right on the second screen (1080p) of my 767 | -- two-monitor setup. 768 | -- Note that this rule will only work with the window's initial title. 769 | if (get_window_name() == "Terminal") then 770 | set_window_position(1300, 200, 2) 771 | set_window_size(600, 800) 772 | end 773 | 774 | -- Make Firefox always start maximised. 775 | if (get_application_name() == "Firefox") then 776 | maximise() -- maximize() for compatibility with <0.45 777 | end 778 | ``` 779 | 780 | **Showing handling of conflict between `devilspie2` and other programs (in this case, 781 | `emacs`):** 782 | 783 | This example uses [millisleep](#user-content-millisleep) to enforce a short 784 | delay. 785 | 786 | ```lua 787 | -- Make Emacs (emacs or emacs-gtk) always start maximised. 788 | win_class = get_class_instance_name() 789 | 790 | debug_print("Window class: " .. win_class) 791 | 792 | if win_class == "emacs" or win_class == "Emacs" then 793 | -- Emacs applies default window size etc. after a brief delay, 794 | -- potentially overriding devilspie2. 795 | -- 796 | -- A brief pause (here, of 0.1s) ensures that devilspie2's actions on the 797 | -- window take effect after Emacs completes its initialisation. A shorter 798 | -- pause may work, or a longer one may be needed. Experiment! Could be 799 | -- that 'millisleep(10)' (0.01s) works well on one PC…? 800 | -- 801 | -- If you prefer, you can have Emacs maximise its window (as in this 802 | -- example) via one of its configuration files - early-init.el, which is 803 | -- normally faster (and avoids a possible visual effect), or init.el – 804 | -- using this LISP statement: 805 | -- (push '(fullscreen . maximized) default-frame-alist) 806 | -- 807 | -- 'millisleep' is new to 0.46. The 0.1s delay for older versions: 808 | -- option 1: 809 | -- os.execute("sleep 0.1") 810 | -- option 2 (needs luaposix): 811 | -- nanosleep = require "posix.time".nanosleep 812 | -- nanosleep{tv_nsec=100e6} 813 | millisleep(100) 814 | maximise() -- maximize() for compatibility with <0.45 815 | end 816 | ``` 817 | 818 | ## Translations 819 | 820 | `devilspie2` is translatable using `gettext` - see 821 | [README.translators.md](README.translators.md) for more information. 822 | 823 | ## Authors 824 | 825 | See [AUTHORS](AUTHORS). 826 | 827 | ## Contact 828 | 829 | * Homepage: http://www.nongnu.org/devilspie2 830 | * Contact / Mailing list: devilspie2-discuss@nongnu.org, 831 | https://lists.nongnu.org/mailman/listinfo/devilspie2-discuss 832 | * See also: https://github.com/dsalt/devilspie 833 | 834 | * IRC: irc://irc.libera.chat/#devilspie2 835 | -------------------------------------------------------------------------------- /README.translators.md: -------------------------------------------------------------------------------- 1 | Copyright © 2011-2024 devilspie2 developers 2 | 3 | This file is distributed under the same licence as the devilspie2 package 4 | (see [COPYING](COPYING)). 5 | 6 | # Information for translators 7 | 8 | **Note:** some translation work may be done via 9 | https://gitlocalize.com/repo/9900. If you use that service then much of the 10 | text below does not apply. 11 | 12 | ## Starting fresh 13 | 14 | Get a copy of the [devilspie2 source repository](https://github.com/dsalt/devilspie2). 15 | If a `devilspie2.pot` isn't available in the `po` folder (it should be!), 16 | create one: 17 | 18 | ```sh 19 | cd po 20 | make update-pot 21 | ``` 22 | 23 | When you have made sure you have `devilspie2.pot`, generate a `po` file for 24 | your language using `msginit`: 25 | 26 | ```sh 27 | msginit -i devilspie2.pot -l LOCALE 28 | ``` 29 | 30 | This copies the `devilspie2.pot` to `LOCALE.po` (it replaces `LOCALE` with 31 | the correct abbreviation for your language & country, e.g. 'sv' for generic 32 | Swedish or `de_CH` for Swiss German) and fills it with information that it 33 | gets from your system. 34 | 35 | Then start translating all strings in the generated `po` file using your 36 | favourite text editor, or a “gettext catalogues (.po files) editor” like 37 | [poedit](http://www.poedit.net/). 38 | 39 | 40 | ## Checking your translation for errors and completeness 41 | 42 | ```sh 43 | msgfmt -c --statistics sv.po -o /dev/null 44 | ``` 45 | 46 | This checks the file (in this example `sv.po`) for errors, outputs the 47 | result statistics to `stdout`, and sends other output to `/dev/null`. (“Other 48 | output” is of no use if just checking for errors.) 49 | 50 | 51 | ## Building Devilspie2 with your translation included 52 | 53 | Edit `po/Makefile` to include your translation under the `LANGUAGES` 54 | variable listing. 55 | 56 | Then build devilspie2 as usual with `make` and install using `make install` 57 | as root. 58 | 59 | 60 | ## Updating your translation 61 | 62 | When it is time to update your translation, you update your language file 63 | from the content of `devilspie2.pot` (in this example the language is 64 | Swedish, and the target file is called `sv.po`): 65 | 66 | ```sh 67 | msgmerge --update sv.po devilspie2.pot 68 | ``` 69 | 70 | There will normally be an updated devilspie2.pot in the git repository 71 | before each release. If you would like to generate it yourself (which you 72 | should if you're randomly checking for changed strings), just get the latest 73 | git version of `devilspie2`, and then do the following: 74 | 75 | ```sh 76 | cd po 77 | make -B update-po 78 | ``` 79 | 80 | and then update your po file as described above. 81 | 82 | Open your file and locate the strings that need updating. To get the 83 | translation to me you can fork `devilspie2` on github, do the translation, 84 | commit your changes then send a pull request. Please use English in your 85 | commit messages so that I can understand what you have done. 86 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright © 2011-2024 devilspie2 developers 3 | # This file is distributed under the same license 4 | # as the devilspie2 package, see COPYING file. 5 | # 6 | 7 | Optionally use GTK+4 8 | 9 | Handle CSD windows with overdraw (shadows etc.?) 10 | - https://github.com/dsalt/devilspie2/issues/18 seems related 11 | 12 | Support for Wayland? XWayland? 13 | - https://github.com/dsalt/devilspie2/issues/7 14 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.46-dev -------------------------------------------------------------------------------- /development.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright © 2011-2024 devilspie2 developers 3 | # This file is distributed under the same license 4 | # as the devilspie2 package, see COPYING file. 5 | # 6 | 7 | Devilspie2 development 8 | ====================== 9 | 10 | Git is used for version control for devilpsie2. If you would like to provide 11 | code to devilspie2, the first thing to do is to learn git. 12 | 13 | Number two to think about is if you are willing to release your code as 14 | GPL. Devilspie2 is released under the GPL version 3, and I will only accept 15 | code under that licence. 16 | 17 | As with any C program, program execution starts in the main function - which 18 | is placed in devilspie2.c in this case. The main function interprets the 19 | command line options, sets up a list of script files that should be 20 | interpreted, and registers the signal for window_opened to the proper callback 21 | function. 22 | 23 | 24 | Adding a new script function 25 | ============================ 26 | 27 | Add it in script.c in the function "register_cfunctions", using a 28 | lua_register call - to add a function having the lua names "centre" and 29 | "center" and connect them with the C function c_center, do this: 30 | 31 | lua_register(lua, "centre", c_center); 32 | lua_register(lua, "center", c_center); 33 | 34 | This registers a centre function which, when used, will call the c_center 35 | function in the C code. The C function should be placed in script_functions.c 36 | and its header, with the following prototype: 37 | 38 | int c_center(lua_State *lua); 39 | 40 | What is returned is an integer represeting the amount of return values that the 41 | Lua function returns. These return values are pushed to the stack using a 42 | lua_push for the correct type - for example lua_pushboolean(lua, TRUE); 43 | 44 | And logically if there is nothing to return, we simply do a "return 0;". 45 | 46 | If we need something that isn't directly implemented in libwnck, we can add 47 | a function implementing it to the file "xutils.c" - please separate stuff from 48 | script_functions if it has no need to be there, and simply call it from your 49 | function in script_functions.c. The point is to keep input and Lua interpreting 50 | to script_functions, while the actual wnck and/or X work is in the xutils files. 51 | -------------------------------------------------------------------------------- /devilspie2.1: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright © 2011-2017 Andreas Rönnquist. 3 | .\" Copyright © 2021-2024 Darren Salt. 4 | .\" This file is distributed under the same license 5 | .\" as the devilspie2 package, see COPYING file. 6 | .\" 7 | .TH devilspie2 1 "" "" 8 | .SH NAME 9 | Devilspie2 \- perform scripted actions on windows when certain events occur 10 | .SH Description 11 | .P 12 | .B Devilspie2 13 | is a program that detects windows as they are created, gain or lose focus or 14 | have their titles changed, and performs scripted actions on them. The 15 | scripts are written in \fILua\fR, allowing a great deal of customisation. 16 | 17 | .SH Options 18 | .TP 19 | \fB\-v\fR, \fB\-\-version 20 | Displays the version of Devilspie2. 21 | .TP 22 | \fB\-f \fIfolder\fR, \fB\-\-folder \fIfolder 23 | Sets the folder where the Lua scripts are loaded from. 24 | .TP 25 | \fB\-d\fR, \fB\-\-debug 26 | Shows debug information from the Lua scripts. If debug_print is used in the Lua 27 | scripts, that output will only be printed to stdout if this option is used. 28 | .TP 29 | \fB\-e\fR, \fB\-\-emulate 30 | Emulation mode. This prevents windows from being affected by the scripts, 31 | but window positions etc. can still be read. 32 | .TP 33 | \fB\-w\fR, \fB\-\-wnck\-version 34 | Show the version of libwnck in use. (Only available on GTK3 or later.) 35 | .TP 36 | \fB\-l\fR, \fB\-\-lua\-version 37 | Show the version of Lua in use. 38 | .SH Script Commands 39 | .P 40 | See 41 | .I /usr/share/doc/devilspie2/README.md 42 | for a detailed description of the commands recognised in Lua scripts. 43 | 44 | .SH Author 45 | .P 46 | .B Devilspie2 47 | is maintained by 48 | .MT devspam@moreofthesa.me.uk 49 | Darren Salt 50 | .ME . It was written by 51 | .MT andreas@ronnquist.net 52 | Andreas Rönnquist 53 | .ME , and is based on Devilspie by Ross 54 | Burton. 55 | -------------------------------------------------------------------------------- /devilspie2.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Name=DevilsPie2 4 | Comment=Perform scripted actions on windows 5 | #Icon=devilspie2 6 | Exec=devilspie2 7 | Terminal=false 8 | Type=Application 9 | StartupNotify=false 10 | Categories=Utility;GTK 11 | Keywords=X11 12 | -------------------------------------------------------------------------------- /doc/examples/awesome.lua: -------------------------------------------------------------------------------- 1 | -- Support Awesome 3.5 WM 2 | 3 | local posix = require("posix"); 4 | local os = require("os"); 5 | 6 | local awesome = "/usr/bin/awesome-client" 7 | if not posix.stat(awesome, "type") == "file" then 8 | awesome = nil; 9 | end 10 | 11 | -- Check for tiling mode 12 | function is_tiling() 13 | if awesome then 14 | return true; 15 | end 16 | return false; 17 | end 18 | 19 | -- Make window floating 20 | -- Parameters: state - true to make window floating, else make window tiled 21 | function set_tile_floating( state ) 22 | if not awesome then 23 | return nil; 24 | end 25 | 26 | if state then state = "true" else state = "false" end 27 | 28 | local xid = get_window_xid(); 29 | 30 | local command = "echo "; 31 | command = command .. "'"; 32 | command = command .. " local naughty = require(\"naughty\");"; 33 | command = command .. " local awcl = require(\"awful.client\");"; 34 | command = command .. " local client = require(\"client\");"; 35 | command = command .. " for k, c in pairs( client.get() ) do"; 36 | command = command .. " if c.window == " .. xid .. " then"; 37 | command = command .. " awcl.floating.set(c, " .. state .. ");"; 38 | command = command .. " end"; 39 | command = command .. " end"; 40 | command = command .. "'"; 41 | command = command .. " | "; 42 | command = command .. awesome; 43 | 44 | debug_print("Awesome floating: " .. command); 45 | return os.execute( command ); 46 | end 47 | -------------------------------------------------------------------------------- /doc/examples/file-header.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | This file is part of devilspie2 3 | Copyright (C) 2023 Darren Salt 4 | 5 | This is an example primarily intended for use in your own 6 | configuration files etc. without causing licence contamination. 7 | As such, no licence conditions are attached; it may be modified and 8 | redistributed freely. Essentially, do what you want with it. 9 | 10 | That said, retaining proper attribution would be appreciated. 11 | ]] 12 | -- Optional, but probably useful. (Technical feedback would be helpful.) 13 | set_adjust_for_decoration(true) 14 | -- Set up some variables containing likely-to-be-referenced values 15 | win_class = get_window_class() 16 | win_role = get_window_role() 17 | win_name = get_window_name() 18 | app_name = get_application_name() 19 | ins_name = get_class_instance_name() 20 | if ins_name == nil then ins_name = '[nil]' end 21 | grp_name = get_class_group_name() 22 | if grp_name == nil then grp_name = '[nil]' end 23 | -- Debug output ("devilspie2 -d") 24 | decorated = get_window_is_decorated() and "yes" or "no" 25 | debug_print("\nName: '" .. win_name .. "'\nApp: '" .. app_name .. "'\nClass: " .. win_class .. "\nRole: <" .. win_role .. ">") 26 | debug_print ("Process: '" .. get_process_name() .. "'\nDecorated: " .. decorated) 27 | debug_print ("Instance: '" .. ins_name .. "' & '" .. grp_name .. "'") 28 | 29 | -- Add your stuff here! 30 | -------------------------------------------------------------------------------- /po/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Devilspie2 po makefile 3 | # $Id$ 4 | # 5 | 6 | 7 | ifndef PREFIX 8 | ifdef INSTALL_PREFIX 9 | PREFIX=$(INSTALL_PREFIX) 10 | else 11 | PREFIX=/usr/local 12 | endif 13 | endif 14 | 15 | NAME = devilspie2 16 | VERSION = $(shell cat ../VERSION) 17 | DATADIR = ${DESTDIR}${PREFIX}/share 18 | LOCALEDIR = ${DATADIR}/locale 19 | 20 | SOURCES = config.c devilspie2.c script.c script_functions.c xutils.c error_strings.c 21 | 22 | XG_ARGS = --keyword=_ --keyword=N_ -w 80 --package-name=${NAME} --package-version=${VERSION} --msgid-bugs-address=devspam@moreofthesa.me.uk 23 | LANGUAGES = sv fr pt_BR nl ru fi ja it 24 | 25 | LANGUAGES_MO = $(foreach currlang,$(LANGUAGES),$(currlang).mo) 26 | LANGUAGES_PO = $(foreach currlang,$(LANGUAGES),$(currlang).po) 27 | 28 | all: build 29 | 30 | ${NAME}.pot: 31 | xgettext ${XG_ARGS} --directory=../src/ ${SOURCES} -d ${NAME} -o ./${NAME}.pot 32 | 33 | update-pot: ${NAME}.pot 34 | 35 | %.pox: %.po 36 | msgmerge -o $@ --previous $< ${NAME}.pot 37 | 38 | build: $(LANGUAGES_MO) 39 | 40 | $(LANGUAGES_MO): $(LANGUAGES_PO) 41 | for po in ${LANGUAGES}; \ 42 | do msgfmt -v --statistics -c -o t-$${po} $${po}.po && mv -f t-$${po} $${po}.mo; \ 43 | done 44 | 45 | 46 | install: all install-dirs 47 | for po in ${LANGUAGES}; \ 48 | do install -m 0644 $${po}.mo ${LOCALEDIR}/$${po}/LC_MESSAGES/${NAME}.mo; \ 49 | done 50 | 51 | install-dirs: 52 | for po in ${LANGUAGES}; \ 53 | do install -d ${LOCALEDIR}/$${po}/LC_MESSAGES; \ 54 | done 55 | 56 | uninstall: 57 | for po in ${LANGUAGES}; \ 58 | do rm -f ${LOCALEDIR}/$${po}/LC_MESSAGES/${NAME}.mo; \ 59 | done 60 | 61 | clean-build: 62 | rm -f *.mo 63 | 64 | clean-pox: 65 | rm -f *.pox 66 | 67 | clean: clean-build 68 | rm -f *~ 69 | 70 | .PHONY: all build install install-dirs uninstall clean clean-pox clean-build update-pot 71 | 72 | -------------------------------------------------------------------------------- /po/devilspie2.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: devilspie2 0.45\n" 10 | "Report-Msgid-Bugs-To: devspam@moreofthesa.me.uk\n" 11 | "POT-Creation-Date: 2024-10-18 22:13+0100\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=CHARSET\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: config.c:193 21 | msgid "script_folder isn't a folder." 22 | msgstr "" 23 | 24 | #: config.c:204 script.c:261 25 | #, c-format 26 | msgid "Error: %s\n" 27 | msgstr "" 28 | 29 | #: devilspie2.c:210 30 | msgid "Received signal:" 31 | msgstr "" 32 | 33 | #: devilspie2.c:259 34 | #, c-format 35 | msgid "List of Lua files handling \"%s\" events in folder:" 36 | msgstr "" 37 | 38 | #: devilspie2.c:269 39 | msgid "No script files found in the script folder - exiting." 40 | msgstr "" 41 | 42 | #: devilspie2.c:334 43 | msgid "Print debug info to stdout" 44 | msgstr "" 45 | 46 | #: devilspie2.c:337 47 | msgid "Don't apply any rules, only emulate execution" 48 | msgstr "" 49 | 50 | #: devilspie2.c:340 51 | msgid "Search for scripts in this folder" 52 | msgstr "" 53 | 54 | #: devilspie2.c:340 55 | msgid "FOLDER" 56 | msgstr "" 57 | 58 | #: devilspie2.c:343 59 | msgid "Show Devilspie2 version and quit" 60 | msgstr "" 61 | 62 | #: devilspie2.c:348 63 | msgid "Show libwnck version and quit" 64 | msgstr "" 65 | 66 | #: devilspie2.c:351 67 | msgid "Show Lua version and quit" 68 | msgstr "" 69 | 70 | #: devilspie2.c:366 71 | msgid "apply rules on windows" 72 | msgstr "" 73 | 74 | #: devilspie2.c:373 75 | #, c-format 76 | msgid "option parsing failed: %s" 77 | msgstr "" 78 | 79 | #: devilspie2.c:396 80 | msgid "Couldn't create the default folder for devilspie2 scripts." 81 | msgstr "" 82 | 83 | #: devilspie2.c:437 84 | msgid "An X11 display is required for devilspie2." 85 | msgstr "" 86 | 87 | #: devilspie2.c:444 88 | msgid "Couldn't init script error messages!" 89 | msgstr "" 90 | 91 | #: devilspie2.c:464 92 | msgid "Running devilspie2 in debug and emulate mode." 93 | msgstr "" 94 | 95 | #: devilspie2.c:466 96 | msgid "Running devilspie2 in debug mode." 97 | msgstr "" 98 | 99 | #: devilspie2.c:469 100 | #, c-format 101 | msgid "Using scripts from folder: %s" 102 | msgstr "" 103 | 104 | #: devilspie2.c:485 105 | msgid "Couldn't create directory monitor!" 106 | msgstr "" 107 | 108 | #: script_functions.c:996 script_functions.c:1049 109 | #, c-format 110 | msgid "A workspace with the name '%s' does not exist!" 111 | msgstr "" 112 | 113 | #: script_functions.c:1009 script_functions.c:1061 114 | #, c-format 115 | msgid "Workspace number %d does not exist!" 116 | msgstr "" 117 | 118 | #: xutils.c:195 xutils.c:213 error_strings.c:85 119 | msgid "Failed!" 120 | msgstr "" 121 | 122 | #: xutils.c:743 123 | msgid "Could not get workspace" 124 | msgstr "" 125 | 126 | #: error_strings.c:52 127 | msgid "Couldn't allocate error string!" 128 | msgstr "" 129 | 130 | #: error_strings.c:63 131 | msgid "No parameters expected" 132 | msgstr "" 133 | 134 | #: error_strings.c:64 135 | msgid "One parameter expected" 136 | msgstr "" 137 | 138 | #: error_strings.c:65 139 | msgid "Two parameters expected" 140 | msgstr "" 141 | 142 | #: error_strings.c:66 143 | msgid "Three parameters expected" 144 | msgstr "" 145 | 146 | #: error_strings.c:67 147 | msgid "Four parameters expected" 148 | msgstr "" 149 | 150 | #: error_strings.c:69 151 | #, c-format 152 | msgid "%d or %d parameters expected" 153 | msgstr "" 154 | 155 | #: error_strings.c:70 156 | #, c-format 157 | msgid "%d to %d parameters expected" 158 | msgstr "" 159 | 160 | #: error_strings.c:72 161 | msgid "At least four parameters expected" 162 | msgstr "" 163 | 164 | #: error_strings.c:74 165 | msgid "Number expected as parameter" 166 | msgstr "" 167 | 168 | #: error_strings.c:75 169 | msgid "Boolean expected as parameter" 170 | msgstr "" 171 | 172 | #: error_strings.c:76 173 | msgid "String expected as parameter" 174 | msgstr "" 175 | 176 | #: error_strings.c:78 177 | msgid "Number or string expected as parameter" 178 | msgstr "" 179 | 180 | #: error_strings.c:79 181 | msgid "Number or string or boolean expected as parameter" 182 | msgstr "" 183 | 184 | #: error_strings.c:81 185 | msgid "Integer greater than zero expected" 186 | msgstr "" 187 | 188 | #: error_strings.c:82 189 | msgid "Could not find current viewport" 190 | msgstr "" 191 | 192 | #: error_strings.c:83 193 | msgid "Setting viewport failed" 194 | msgstr "" 195 | -------------------------------------------------------------------------------- /po/fi.po: -------------------------------------------------------------------------------- 1 | # Finnish translations for devilspie2 package. 2 | # Copyright (C) 2013 THE devilspie2'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # Johan Lantto , 2013. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: devilspie2 0.28pre\n" 9 | "Report-Msgid-Bugs-To: gusnan@openmailbox.org\n" 10 | "POT-Creation-Date: 2014-04-02 21:21+0200\n" 11 | "PO-Revision-Date: 2013-02-22 09:02+0200\n" 12 | "Last-Translator: Johan Lantto \n" 13 | "Language-Team: Finnish\n" 14 | "Language: fi\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: config.c:188 20 | msgid "script_folder isn't a folder." 21 | msgstr "script_folder ei ole kansio." 22 | 23 | #: config.c:200 script.c:232 24 | #, c-format 25 | msgid "Error: %s\n" 26 | msgstr "Virhe: %s\n" 27 | 28 | #: devilspie2.c:164 29 | msgid "Received signal:" 30 | msgstr "Vastaanotettu signaali:" 31 | 32 | #: devilspie2.c:208 33 | msgid "No script files found in the script folder - exiting." 34 | msgstr "Käsikirjoituksia ei löytynyt käsikirjoituskansiossa - lopetetaan." 35 | 36 | #: devilspie2.c:215 devilspie2.c:223 37 | #, c-format 38 | msgid "List of Lua files handling \"%s\" events in folder:" 39 | msgstr "\"%s\"-tapahtumien käsitteleviä Lua-tiedostoja kansiossa:" 40 | 41 | #: devilspie2.c:289 42 | msgid "Print debug info to stdout" 43 | msgstr "Kirjoita debug-info stdout:iin" 44 | 45 | #: devilspie2.c:291 46 | msgid "Don't apply any rules, only emulate execution" 47 | msgstr "Älä noudata yhtään sääntöja, emuloi vaan" 48 | 49 | #: devilspie2.c:293 50 | msgid "Search for scripts in this folder" 51 | msgstr "Etsi käsikirjoituksia tästä kansiosta" 52 | 53 | #: devilspie2.c:293 54 | msgid "FOLDER" 55 | msgstr "KANSIO" 56 | 57 | #: devilspie2.c:295 58 | msgid "Show Devilspie2 version and quit" 59 | msgstr "Näytä Devilspie2:n versio ja lopeta" 60 | 61 | #: devilspie2.c:300 62 | msgid "Show libwnck version and quit" 63 | msgstr "Näytä libwnckin versio ja lopeta" 64 | 65 | #: devilspie2.c:318 66 | msgid "apply rules on windows" 67 | msgstr "käytä sääntöjä ikkunoissa" 68 | 69 | #: devilspie2.c:325 70 | #, c-format 71 | msgid "option parsing failed: %s" 72 | msgstr "vaihtoehtojen tulkinta epäonnistui: %s" 73 | 74 | #: devilspie2.c:346 75 | msgid "Couldn't create the default folder for devilspie2 scripts." 76 | msgstr "Ei voitu luoda devilspie2:n käsikirjoituksien oletuskansio" 77 | 78 | #: devilspie2.c:373 79 | msgid "An X11 display is required for devilspie2." 80 | msgstr "Devilspie2 vaatii X11-näytin" 81 | 82 | #: devilspie2.c:381 83 | msgid "Couldn't init script error messages!" 84 | msgstr "Ei voitu alustaa käsikirjoituksien virheilmoituksia!" 85 | 86 | #: devilspie2.c:398 87 | msgid "Running devilspie2 in debug and emulate mode." 88 | msgstr "Ajaa Devilspie2 virheenhaku- ja emulointimoodissa" 89 | 90 | #: devilspie2.c:400 91 | msgid "Running devilspie2 in debug mode." 92 | msgstr "Ajaa Devilspie2 virheenhakumoodissa" 93 | 94 | #: devilspie2.c:405 95 | #, c-format 96 | msgid "Using scripts from folder: %s" 97 | msgstr "Käyttää käsikirjoituksia kansiosta: %s" 98 | 99 | #: devilspie2.c:421 100 | msgid "Couldn't create directory monitor!" 101 | msgstr "Ei voitu luoda kansiomonitori!" 102 | 103 | #: script_functions.c:732 script_functions.c:778 104 | #, c-format 105 | msgid "Workspace number %d does not exist!" 106 | msgstr "Työpöytä numero %d ei ole olemassa!" 107 | 108 | #: script_functions.c:1673 109 | msgid "Could not get workspace" 110 | msgstr "Työpöytä ei saatu haettu" 111 | 112 | #: xutils.c:183 xutils.c:201 error_strings.c:127 113 | msgid "Failed!" 114 | msgstr "Epäonnistui!" 115 | 116 | #: error_strings.c:49 117 | msgid "Couldn't allocate error string!" 118 | msgstr "Ei voitu allokoida virhemerkkijono!" 119 | 120 | #: error_strings.c:51 121 | msgid "No indata expected" 122 | msgstr "Syötejonoa ei odotettu" 123 | 124 | #: error_strings.c:58 125 | msgid "One indata expected" 126 | msgstr "Yksi syötejono odotettiin" 127 | 128 | #: error_strings.c:65 129 | msgid "Two indata expected" 130 | msgstr "Kaksi syötejonoa odotettiin" 131 | 132 | #: error_strings.c:72 133 | msgid "Four indata expected" 134 | msgstr "Nejlä syötejonoa odotettiin" 135 | 136 | #: error_strings.c:80 137 | msgid "Number expected as indata" 138 | msgstr "Numero odotettiin syötejonona" 139 | 140 | #: error_strings.c:88 141 | msgid "Boolean expected as indata" 142 | msgstr "Boolinen arvo odotettiin syötejonona" 143 | 144 | #: error_strings.c:96 145 | msgid "String expected as indata" 146 | msgstr "Merkkijono odotettiin syötejonona" 147 | 148 | #: error_strings.c:104 149 | msgid "Integer greater than zero expected" 150 | msgstr "Kokonaisluvu nolla suurempi odotettiin" 151 | 152 | #: error_strings.c:112 153 | msgid "Could not find current viewport" 154 | msgstr "Nykyinen työtila ei löydetty" 155 | 156 | #: error_strings.c:120 157 | msgid "Setting viewport failed" 158 | msgstr "Työtilan asettelu epäonnistui" 159 | -------------------------------------------------------------------------------- /po/fr.po: -------------------------------------------------------------------------------- 1 | # French translations for devilspie2 package. 2 | # Copyright (C) 2012 THE devilspie2'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # Robin Hahling , 2012. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: devilspie2 0.18\n" 9 | "Report-Msgid-Bugs-To: gusnan@openmailbox.org\n" 10 | "POT-Creation-Date: 2016-07-06 12:26+0200\n" 11 | "PO-Revision-Date: 2012-04-15 15:44+0200\n" 12 | "Last-Translator: Robin Hahling \n" 13 | "Language-Team: French\n" 14 | "Language: fr\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=utf-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 19 | 20 | #: config.c:192 21 | msgid "script_folder isn't a folder." 22 | msgstr "script_folder n'est pas un dossier." 23 | 24 | #: config.c:204 script.c:238 25 | #, c-format 26 | msgid "Error: %s\n" 27 | msgstr "Erreur: %s\n" 28 | 29 | #: devilspie2.c:181 30 | msgid "Received signal:" 31 | msgstr "Signal reçu:" 32 | 33 | #: devilspie2.c:232 34 | #, c-format 35 | msgid "List of Lua files handling \"%s\" events in folder:" 36 | msgstr "Liste des fichiers Lua gérant les évènements \"%s\"dans le dossier:" 37 | 38 | #: devilspie2.c:242 39 | msgid "No script files found in the script folder - exiting." 40 | msgstr "Aucun script trouvé dans le dossier de scripts - sortie du programme." 41 | 42 | #: devilspie2.c:308 43 | msgid "Print debug info to stdout" 44 | msgstr "Affiche les informations de debug dans la sortie standard (stdout)" 45 | 46 | #: devilspie2.c:311 47 | msgid "Don't apply any rules, only emulate execution" 48 | msgstr "N'applique aucune règle, simule seulement l'exécution" 49 | 50 | #: devilspie2.c:314 51 | msgid "Search for scripts in this folder" 52 | msgstr "Recherche de scripts dans ce dossier" 53 | 54 | #: devilspie2.c:314 55 | msgid "FOLDER" 56 | msgstr "DOSSIER" 57 | 58 | #: devilspie2.c:317 59 | msgid "Show Devilspie2 version and quit" 60 | msgstr "Affiche la version de Devilspie2 et quitte le programme" 61 | 62 | #: devilspie2.c:323 63 | msgid "Show libwnck version and quit" 64 | msgstr "Affiche la version de libwnck et quitte le programme" 65 | 66 | #: devilspie2.c:342 67 | msgid "apply rules on windows" 68 | msgstr "applique les règles sur les fenêtres" 69 | 70 | #: devilspie2.c:349 71 | #, c-format 72 | msgid "option parsing failed: %s" 73 | msgstr "l'analyse des options a échoué: %s" 74 | 75 | #: devilspie2.c:370 76 | msgid "Couldn't create the default folder for devilspie2 scripts." 77 | msgstr "Impossible de créer le fichier par défaut pour les scripts devilspie2." 78 | 79 | #: devilspie2.c:397 80 | msgid "An X11 display is required for devilspie2." 81 | msgstr "Un affichage X11 est requis pour devilspie2." 82 | 83 | #: devilspie2.c:405 84 | msgid "Couldn't init script error messages!" 85 | msgstr "Impossible d'initialiser le script de messages d'erreurs" 86 | 87 | #: devilspie2.c:426 88 | msgid "Running devilspie2 in debug and emulate mode." 89 | msgstr "Exécution de devilspie2 en mode debug et simulation." 90 | 91 | #: devilspie2.c:428 92 | msgid "Running devilspie2 in debug mode." 93 | msgstr "Exécution de devilspie2 en mode debug." 94 | 95 | #: devilspie2.c:433 96 | #, c-format 97 | msgid "Using scripts from folder: %s" 98 | msgstr "Utilise les scripts du dossier: %s" 99 | 100 | #: devilspie2.c:449 101 | msgid "Couldn't create directory monitor!" 102 | msgstr "Impossible de créer le dossier moniteur!" 103 | 104 | #: script_functions.c:709 script_functions.c:755 105 | #, c-format 106 | msgid "Workspace number %d does not exist!" 107 | msgstr "L'espace de travail numéro %d n'existe pas!" 108 | 109 | #: script_functions.c:1734 110 | msgid "Could not get workspace" 111 | msgstr "Impossible d'obtenir l'espace de travail" 112 | 113 | #: xutils.c:186 xutils.c:204 error_strings.c:136 114 | msgid "Failed!" 115 | msgstr "Échec!" 116 | 117 | #: error_strings.c:51 118 | msgid "Couldn't allocate error string!" 119 | msgstr "Impossible d'allouer la chaine de caractères de l'erreur" 120 | 121 | #: error_strings.c:53 122 | msgid "No indata expected" 123 | msgstr "Aucune donnée d'entrée attendue" 124 | 125 | #: error_strings.c:60 126 | msgid "One indata expected" 127 | msgstr "Une donnée d'entrée attendue" 128 | 129 | #: error_strings.c:67 130 | msgid "Two indata expected" 131 | msgstr "Deux données d'entrée attendues" 132 | 133 | #: error_strings.c:74 134 | msgid "Four indata expected" 135 | msgstr "Quatre données d'entrée attendues" 136 | 137 | #: error_strings.c:81 138 | msgid "One or two indata expected" 139 | msgstr "Une ou deux données d'entrée attendues" 140 | 141 | #: error_strings.c:89 142 | msgid "Number expected as indata" 143 | msgstr "Nombre attendu de données d'entrée" 144 | 145 | #: error_strings.c:97 146 | msgid "Boolean expected as indata" 147 | msgstr "Booléen attendu comme donnée d'entrée" 148 | 149 | #: error_strings.c:105 150 | msgid "String expected as indata" 151 | msgstr "Chaine de caractères attendue comme donnée d'entrée" 152 | 153 | #: error_strings.c:113 154 | msgid "Integer greater than zero expected" 155 | msgstr "Un entier plus grand que zéro est attendu" 156 | 157 | #: error_strings.c:121 158 | msgid "Could not find current viewport" 159 | msgstr "Impossible de trouver la fenêtre courante" 160 | 161 | #: error_strings.c:129 162 | msgid "Setting viewport failed" 163 | msgstr "Le paramétrage de la fenêtre a échoué" 164 | -------------------------------------------------------------------------------- /po/it.po: -------------------------------------------------------------------------------- 1 | # Italian translation for devilspie2 package. 2 | # Copyright (C) 2016-2017 The devilspie2's copyright holder 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # Nicola Fontana , 2016-2017. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: devilspie2 0.42\n" 9 | "Report-Msgid-Bugs-To: andreas@ronnquist.net\n" 10 | "POT-Creation-Date: 2017-01-04 15:35+0100\n" 11 | "PO-Revision-Date: 2016-01-29 08:31+0100\n" 12 | "Last-Translator: Nicola Fontana \n" 13 | "Language-Team: Italian\n" 14 | "Language: it\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=utf-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: config.c:192 20 | msgid "script_folder isn't a folder." 21 | msgstr "script_folder non è una cartella." 22 | 23 | #: config.c:204 script.c:238 24 | #, c-format 25 | msgid "Error: %s\n" 26 | msgstr "Errore: %s\n" 27 | 28 | #: devilspie2.c:181 29 | msgid "Received signal:" 30 | msgstr "Segnale ricevuto:" 31 | 32 | #: devilspie2.c:232 33 | #, c-format 34 | msgid "List of Lua files handling \"%s\" events in folder:" 35 | msgstr "Elenco dei file Lua nella cartella che gestiscono l'evento \"%s\":" 36 | 37 | #: devilspie2.c:242 38 | msgid "No script files found in the script folder - exiting." 39 | msgstr "Nessuno script trovato nella cartella script - uscita." 40 | 41 | #: devilspie2.c:308 42 | msgid "Print debug info to stdout" 43 | msgstr "Stampa messaggi di debug su stdout" 44 | 45 | #: devilspie2.c:311 46 | msgid "Don't apply any rules, only emulate execution" 47 | msgstr "Non applicare le regole, simularne solo l'esecuzione" 48 | 49 | #: devilspie2.c:314 50 | msgid "Search for scripts in this folder" 51 | msgstr "Ricercare script in questa cartella" 52 | 53 | #: devilspie2.c:314 54 | msgid "FOLDER" 55 | msgstr "CARTELLA" 56 | 57 | #: devilspie2.c:317 58 | msgid "Show Devilspie2 version and quit" 59 | msgstr "Mostrare la versione di Devilspie2 e uscire" 60 | 61 | #: devilspie2.c:323 62 | msgid "Show libwnck version and quit" 63 | msgstr "Mostrare la versione di libwnck e uscire" 64 | 65 | #: devilspie2.c:340 66 | msgid "apply rules on windows" 67 | msgstr "applicare regole alla finestra" 68 | 69 | #: devilspie2.c:347 70 | #, c-format 71 | msgid "option parsing failed: %s" 72 | msgstr "analisi opzioni fallita: %s" 73 | 74 | #: devilspie2.c:370 75 | msgid "Couldn't create the default folder for devilspie2 scripts." 76 | msgstr "Non posso creare la cartella di default per gli script." 77 | 78 | #: devilspie2.c:397 79 | msgid "An X11 display is required for devilspie2." 80 | msgstr "Devilspie2 richiede un display X11." 81 | 82 | #: devilspie2.c:405 83 | msgid "Couldn't init script error messages!" 84 | msgstr "Impossibile inizializzare i messaggi di errore!" 85 | 86 | #: devilspie2.c:426 87 | msgid "Running devilspie2 in debug and emulate mode." 88 | msgstr "Esecuzione di devilspie2 in modalità debug e emulazione." 89 | 90 | #: devilspie2.c:428 91 | msgid "Running devilspie2 in debug mode." 92 | msgstr "Esecuzione di devilspie2 in modalità debug." 93 | 94 | #: devilspie2.c:433 95 | #, c-format 96 | msgid "Using scripts from folder: %s" 97 | msgstr "Utilizzo script dalla cartella: %s" 98 | 99 | #: devilspie2.c:449 100 | msgid "Couldn't create directory monitor!" 101 | msgstr "Impossibile creare la directory monitor!" 102 | 103 | #: script_functions.c:709 script_functions.c:755 104 | #, c-format 105 | msgid "Workspace number %d does not exist!" 106 | msgstr "Il workspace %d non esiste!" 107 | 108 | #: script_functions.c:1734 109 | msgid "Could not get workspace" 110 | msgstr "Impossibile leggere il workspace" 111 | 112 | #: xutils.c:186 xutils.c:204 error_strings.c:136 113 | msgid "Failed!" 114 | msgstr "Fallito!" 115 | 116 | #: error_strings.c:51 117 | msgid "Couldn't allocate error string!" 118 | msgstr "Impossibile allocare la stringa di errore!" 119 | 120 | #: error_strings.c:53 121 | msgid "No indata expected" 122 | msgstr "Nessun argomento atteso" 123 | 124 | #: error_strings.c:60 125 | msgid "One indata expected" 126 | msgstr "Un argomento atteso" 127 | 128 | #: error_strings.c:67 129 | msgid "Two indata expected" 130 | msgstr "Due argomenti attesi" 131 | 132 | #: error_strings.c:74 133 | msgid "Four indata expected" 134 | msgstr "Quattro argomenti attesi" 135 | 136 | #: error_strings.c:81 137 | msgid "One or two indata expected" 138 | msgstr "Uno o due argomenti attesi" 139 | 140 | #: error_strings.c:89 141 | msgid "Number expected as indata" 142 | msgstr "Atteso argomento numerico" 143 | 144 | #: error_strings.c:97 145 | msgid "Boolean expected as indata" 146 | msgstr "Atteso argomento booleano" 147 | 148 | #: error_strings.c:105 149 | msgid "String expected as indata" 150 | msgstr "Atteso argomento stringa" 151 | 152 | #: error_strings.c:113 153 | msgid "Integer greater than zero expected" 154 | msgstr "Atteso intero maggiore o uguale a zero" 155 | 156 | #: error_strings.c:121 157 | msgid "Could not find current viewport" 158 | msgstr "Impossibile trovare la viewport attuale" 159 | 160 | #: error_strings.c:129 161 | msgid "Setting viewport failed" 162 | msgstr "Impostazione della viewport fallita" 163 | -------------------------------------------------------------------------------- /po/ja.po: -------------------------------------------------------------------------------- 1 | # Japanese translations for devilspie2 package 2 | # Copyright (C) 2011 Andreas Rönnquist 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # Andreas Rönnquist , 2011. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: devilspie2 0.39\n" 9 | "Report-Msgid-Bugs-To: gusnan@openmailbox.org\n" 10 | "POT-Creation-Date: 2016-03-09 10:23+0100\n" 11 | "PO-Revision-Date: 2016-03-11 00:01+0900\n" 12 | "Last-Translator: Hiroshi Hasebe \n" 13 | "Language-Team: Japanese\n" 14 | "Language: ja\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=1; plural=0;\n" 19 | 20 | #: config.c:184 21 | msgid "script_folder isn't a folder." 22 | msgstr "script_folderがフォルダの検出に失敗" 23 | 24 | #: config.c:196 script.c:238 25 | #, c-format 26 | msgid "Error: %s\n" 27 | msgstr "エラー: %s\n" 28 | 29 | #: devilspie2.c:166 30 | msgid "Received signal:" 31 | msgstr "シグナルを検出:" 32 | 33 | #: devilspie2.c:210 34 | msgid "No script files found in the script folder - exiting." 35 | msgstr "スクリプトが空のため, 実行終了." 36 | 37 | #: devilspie2.c:217 devilspie2.c:225 38 | #, c-format 39 | msgid "List of Lua files handling \"%s\" events in folder:" 40 | msgstr "イベント \"%s\" を担当するLuaファイルの一覧:" 41 | 42 | #: devilspie2.c:293 43 | msgid "Print debug info to stdout" 44 | msgstr "標準出力にデバッグ情報を書き出す" 45 | 46 | #: devilspie2.c:296 47 | msgid "Don't apply any rules, only emulate execution" 48 | msgstr "ルールを適用せず, エミュレーションのみ行う" 49 | 50 | #: devilspie2.c:299 51 | msgid "Search for scripts in this folder" 52 | msgstr "スクリプト収容先フォルダ" 53 | 54 | #: devilspie2.c:299 55 | msgid "FOLDER" 56 | msgstr "FOLDER" 57 | 58 | #: devilspie2.c:302 59 | msgid "Show Devilspie2 version and quit" 60 | msgstr "Devilspie2のバージョン情報を表示して終了" 61 | 62 | #: devilspie2.c:308 63 | msgid "Show libwnck version and quit" 64 | msgstr "libwnckのバージョンを表示して終了" 65 | 66 | #: devilspie2.c:327 67 | msgid "apply rules on windows" 68 | msgstr "ウィンドウにルールを適用" 69 | 70 | #: devilspie2.c:334 71 | #, c-format 72 | msgid "option parsing failed: %s" 73 | msgstr "引数の解釈に失敗: %s" 74 | 75 | #: devilspie2.c:355 76 | msgid "Couldn't create the default folder for devilspie2 scripts." 77 | msgstr "規定のスクリプト・フォルダの作成に失敗" 78 | 79 | #: devilspie2.c:382 80 | msgid "An X11 display is required for devilspie2." 81 | msgstr "Devilspie2の実行にはX11環境を要する" 82 | 83 | #: devilspie2.c:390 84 | msgid "Couldn't init script error messages!" 85 | msgstr "スクリプト・エラー・メッセージの初期化に失敗!" 86 | 87 | #: devilspie2.c:411 88 | msgid "Running devilspie2 in debug and emulate mode." 89 | msgstr "Devilspie2をデバック + エミュレーション・モードで実行中" 90 | 91 | #: devilspie2.c:413 92 | msgid "Running devilspie2 in debug mode." 93 | msgstr "Devilspie2をデバッグ・モードで実行中" 94 | 95 | #: devilspie2.c:418 96 | #, c-format 97 | msgid "Using scripts from folder: %s" 98 | msgstr "フォルダ \"%s\" のスクリプトを使用中" 99 | 100 | #: devilspie2.c:434 101 | msgid "Couldn't create directory monitor!" 102 | msgstr "ディレクトリ認識機能の実行に失敗!" 103 | 104 | #: script_functions.c:709 script_functions.c:755 105 | #, c-format 106 | msgid "Workspace number %d does not exist!" 107 | msgstr "%d番ワークスペースの検出に失敗!" 108 | 109 | #: script_functions.c:1734 110 | msgid "Could not get workspace" 111 | msgstr "ワークスペースの認識に失敗" 112 | 113 | #: xutils.c:186 xutils.c:204 error_strings.c:136 114 | msgid "Failed!" 115 | msgstr "処理に失敗!" 116 | 117 | #: error_strings.c:51 118 | msgid "Couldn't allocate error string!" 119 | msgstr "エラー文字列の割当に失敗!" 120 | 121 | #: error_strings.c:53 122 | msgid "No indata expected" 123 | msgstr "不要な引数を検出" 124 | 125 | #: error_strings.c:60 126 | msgid "One indata expected" 127 | msgstr "1個の引数を想定" 128 | 129 | #: error_strings.c:67 130 | msgid "Two indata expected" 131 | msgstr "2個の引数を想定" 132 | 133 | #: error_strings.c:74 134 | msgid "Four indata expected" 135 | msgstr "4個の引数を想定" 136 | 137 | #: error_strings.c:81 138 | msgid "One or two indata expected" 139 | msgstr "1個もしくは2個の引数を想定" 140 | 141 | #: error_strings.c:89 142 | msgid "Number expected as indata" 143 | msgstr "数値の引数が想定" 144 | 145 | #: error_strings.c:97 146 | msgid "Boolean expected as indata" 147 | msgstr "ブール型の引数が必要" 148 | 149 | #: error_strings.c:105 150 | msgid "String expected as indata" 151 | msgstr "文字列型の引数が必要" 152 | 153 | #: error_strings.c:113 154 | msgid "Integer greater than zero expected" 155 | msgstr "ゼロよりも大きな整数を想定" 156 | 157 | #: error_strings.c:121 158 | msgid "Could not find current viewport" 159 | msgstr "カレント・ビューポートの検出に失敗" 160 | 161 | #: error_strings.c:129 162 | msgid "Setting viewport failed" 163 | msgstr "ビューポートの設定に失敗" 164 | -------------------------------------------------------------------------------- /po/nl.po: -------------------------------------------------------------------------------- 1 | # Dutch translation of Devilspie2 2 | # Copyright (C) 2011 Andreas Rönnquist 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # Andreas Rönnquist , 2011. 5 | # 6 | # 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: devilspie2 0.16\n" 10 | "Report-Msgid-Bugs-To: gusnan@openmailbox.org\n" 11 | "POT-Creation-Date: 2016-03-09 15:21+0100\n" 12 | "PO-Revision-Date: 2016-03-09 15:25+0100\n" 13 | "Last-Translator: Frans de Jonge \n" 14 | "Language-Team: Dutch\n" 15 | "Language: nl\n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "X-Generator: Poedit 1.8.7.1\n" 20 | 21 | #: config.c:184 22 | msgid "script_folder isn't a folder." 23 | msgstr "script_folder is geen map." 24 | 25 | #: config.c:196 script.c:238 26 | #, c-format 27 | msgid "Error: %s\n" 28 | msgstr "Fout: %s\n" 29 | 30 | #: devilspie2.c:166 31 | msgid "Received signal:" 32 | msgstr "Ontvangen signaal:" 33 | 34 | #: devilspie2.c:210 35 | msgid "No script files found in the script folder - exiting." 36 | msgstr "" 37 | "Er werden geen scriptbestanden in de scriptmap gevonden — programma wordt " 38 | "afgesloten." 39 | 40 | #: devilspie2.c:217 devilspie2.c:225 41 | #, c-format 42 | msgid "List of Lua files handling \"%s\" events in folder:" 43 | msgstr "" 44 | "Lijst van Lua-bestanden die worden uitgevoerd bij een \"%s\"-gebeurtenis in " 45 | "deze map:" 46 | 47 | #: devilspie2.c:293 48 | msgid "Print debug info to stdout" 49 | msgstr "Print debuginformatie naar stdout" 50 | 51 | #: devilspie2.c:296 52 | msgid "Don't apply any rules, only emulate execution" 53 | msgstr "Pas geen regels permanent toe; enkel emulatie van uitvoering" 54 | 55 | #: devilspie2.c:299 56 | msgid "Search for scripts in this folder" 57 | msgstr "Zoek naar scripts in deze map" 58 | 59 | #: devilspie2.c:299 60 | msgid "FOLDER" 61 | msgstr "MAP" 62 | 63 | #: devilspie2.c:302 64 | msgid "Show Devilspie2 version and quit" 65 | msgstr "Toon Devilspie2-versie en sluit af" 66 | 67 | #: devilspie2.c:308 68 | msgid "Show libwnck version and quit" 69 | msgstr "Toon libwnck-versie en sluit af" 70 | 71 | #: devilspie2.c:327 72 | msgid "apply rules on windows" 73 | msgstr "Pas regels toe op vensters" 74 | 75 | #: devilspie2.c:334 76 | #, c-format 77 | msgid "option parsing failed: %s" 78 | msgstr "de volgende optie wordt niet begrepen: %s" 79 | 80 | #: devilspie2.c:355 81 | msgid "Couldn't create the default folder for devilspie2 scripts." 82 | msgstr "Kon geen standaardmap aanmaken voor devilspie2-scripts." 83 | 84 | #: devilspie2.c:382 85 | msgid "An X11 display is required for devilspie2." 86 | msgstr "Een X11-scherm is noodzakelijk voor devilspie2." 87 | 88 | #: devilspie2.c:390 89 | msgid "Couldn't init script error messages!" 90 | msgstr "Scriptfoutmeldingen konden niet geïnitialiseerd worden!" 91 | 92 | #: devilspie2.c:411 93 | msgid "Running devilspie2 in debug and emulate mode." 94 | msgstr "Devilspie2 draait in debug- en emuleringsmodus." 95 | 96 | #: devilspie2.c:413 97 | msgid "Running devilspie2 in debug mode." 98 | msgstr "Devilspie2 draait in debugmodus." 99 | 100 | #: devilspie2.c:418 101 | #, c-format 102 | msgid "Using scripts from folder: %s" 103 | msgstr "Scripts worden uit deze map toegepast: %s" 104 | 105 | #: devilspie2.c:434 106 | msgid "Couldn't create directory monitor!" 107 | msgstr "De map kon niet worden gemonitord!" 108 | 109 | #: script_functions.c:709 script_functions.c:755 110 | #, c-format 111 | msgid "Workspace number %d does not exist!" 112 | msgstr "Werkruimte nummer %d bestaat niet!" 113 | 114 | #: script_functions.c:1734 115 | msgid "Could not get workspace" 116 | msgstr "Kon werkruimte niet verkrijgen." 117 | 118 | #: xutils.c:186 xutils.c:204 error_strings.c:136 119 | msgid "Failed!" 120 | msgstr "Mislukt!" 121 | 122 | #: error_strings.c:51 123 | msgid "Couldn't allocate error string!" 124 | msgstr "Foutmeldingsreeks kon niet worden gealloceerd!" 125 | 126 | #: error_strings.c:53 127 | msgid "No indata expected" 128 | msgstr "Geen invoergegevens verwacht" 129 | 130 | #: error_strings.c:60 131 | msgid "One indata expected" 132 | msgstr "Eén invoergegeven verwacht" 133 | 134 | #: error_strings.c:67 135 | msgid "Two indata expected" 136 | msgstr "Twee invoergegevens verwacht" 137 | 138 | #: error_strings.c:74 139 | msgid "Four indata expected" 140 | msgstr "Vier invoergegevens verwacht" 141 | 142 | #: error_strings.c:81 143 | msgid "One or two indata expected" 144 | msgstr "Eén of twee invoergegevens verwacht" 145 | 146 | #: error_strings.c:89 147 | msgid "Number expected as indata" 148 | msgstr "Nummer verwacht als invoer" 149 | 150 | #: error_strings.c:97 151 | msgid "Boolean expected as indata" 152 | msgstr "Boolean verwacht als invoer" 153 | 154 | #: error_strings.c:105 155 | msgid "String expected as indata" 156 | msgstr "String verwacht als invoer" 157 | 158 | #: error_strings.c:113 159 | msgid "Integer greater than zero expected" 160 | msgstr "Geheel getal groter dan nul verwacht" 161 | 162 | #: error_strings.c:121 163 | msgid "Could not find current viewport" 164 | msgstr "Huidige viewport niet gevonden" 165 | 166 | #: error_strings.c:129 167 | msgid "Setting viewport failed" 168 | msgstr "Viewport instellen mislukt" 169 | -------------------------------------------------------------------------------- /po/pt_BR.po: -------------------------------------------------------------------------------- 1 | # Portuguese translations for devilspie2 package. 2 | # Copyright (C) 2012 THE devilspie2'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # Helder Maximo Botter Ribas <>, 2012. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: devilspie2 0.19\n" 9 | "Report-Msgid-Bugs-To: gusnan@openmailbox.org\n" 10 | "POT-Creation-Date: 2014-04-02 21:21+0200\n" 11 | "PO-Revision-Date: 2012-06-05 14:01-0300\n" 12 | "Last-Translator: Helder Maximo Botter Ribas <>\n" 13 | "Language-Team: Brazilian Portuguese\n" 14 | "Language: pt_BR\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 19 | 20 | #: config.c:188 21 | msgid "script_folder isn't a folder." 22 | msgstr "script_folder não é um diretório." 23 | 24 | #: config.c:200 script.c:232 25 | #, c-format 26 | msgid "Error: %s\n" 27 | msgstr "Erro: %s\n" 28 | 29 | #: devilspie2.c:164 30 | msgid "Received signal:" 31 | msgstr "Sinal recebido:" 32 | 33 | #: devilspie2.c:208 34 | msgid "No script files found in the script folder - exiting." 35 | msgstr "Nenhum arquivo de script encontrado no diretório de scripts - saindo." 36 | 37 | #: devilspie2.c:215 devilspie2.c:223 38 | #, c-format 39 | msgid "List of Lua files handling \"%s\" events in folder:" 40 | msgstr "Lista de arquivos Lua de manipulação de eventos \"%s\" no diretório:" 41 | 42 | #: devilspie2.c:289 43 | msgid "Print debug info to stdout" 44 | msgstr "Imprimindo informação de debug no stdout" 45 | 46 | #: devilspie2.c:291 47 | msgid "Don't apply any rules, only emulate execution" 48 | msgstr "Não aplique nenhuma regra, apena simule a execução" 49 | 50 | #: devilspie2.c:293 51 | msgid "Search for scripts in this folder" 52 | msgstr "Procurar por scripts neste diretório" 53 | 54 | #: devilspie2.c:293 55 | msgid "FOLDER" 56 | msgstr "DIRETÓRIO" 57 | 58 | #: devilspie2.c:295 59 | msgid "Show Devilspie2 version and quit" 60 | msgstr "Mostar versão do Devilspie2 e sair" 61 | 62 | #: devilspie2.c:300 63 | msgid "Show libwnck version and quit" 64 | msgstr "Mostrar versão do libwnck e sair" 65 | 66 | #: devilspie2.c:318 67 | msgid "apply rules on windows" 68 | msgstr "aplicar regras na janela" 69 | 70 | #: devilspie2.c:325 71 | #, c-format 72 | msgid "option parsing failed: %s" 73 | msgstr "falha no parsing da opção: %s" 74 | 75 | #: devilspie2.c:346 76 | msgid "Couldn't create the default folder for devilspie2 scripts." 77 | msgstr "Não pode criar o diretório padrão para os scripts do devilspie2." 78 | 79 | #: devilspie2.c:373 80 | msgid "An X11 display is required for devilspie2." 81 | msgstr "Uma tela X11 é necessária para o devilspie2" 82 | 83 | #: devilspie2.c:381 84 | msgid "Couldn't init script error messages!" 85 | msgstr "Não pode iniciar script de mensagens de erro!" 86 | 87 | #: devilspie2.c:398 88 | msgid "Running devilspie2 in debug and emulate mode." 89 | msgstr "Rodando devilspie2 em modo debug e emulação." 90 | 91 | #: devilspie2.c:400 92 | msgid "Running devilspie2 in debug mode." 93 | msgstr "Rodando devilspie2 em modo debug." 94 | 95 | #: devilspie2.c:405 96 | #, c-format 97 | msgid "Using scripts from folder: %s" 98 | msgstr "Usando scripts do diretório: %s" 99 | 100 | #: devilspie2.c:421 101 | msgid "Couldn't create directory monitor!" 102 | msgstr "Não pode criar o monitor de diretório" 103 | 104 | #: script_functions.c:732 script_functions.c:778 105 | #, c-format 106 | msgid "Workspace number %d does not exist!" 107 | msgstr "Workspace de número %d não existe!" 108 | 109 | #: script_functions.c:1673 110 | msgid "Could not get workspace" 111 | msgstr "Não foi possível obter o workspace" 112 | 113 | #: xutils.c:183 xutils.c:201 error_strings.c:127 114 | msgid "Failed!" 115 | msgstr "Falhou!" 116 | 117 | #: error_strings.c:49 118 | msgid "Couldn't allocate error string!" 119 | msgstr "Não pode alocar string de erro!" 120 | 121 | #: error_strings.c:51 122 | msgid "No indata expected" 123 | msgstr "Nenhum dado de entrada esperado" 124 | 125 | #: error_strings.c:58 126 | msgid "One indata expected" 127 | msgstr "Um dado de entrada esperado" 128 | 129 | #: error_strings.c:65 130 | msgid "Two indata expected" 131 | msgstr "Dois dados de entrada esperados" 132 | 133 | #: error_strings.c:72 134 | msgid "Four indata expected" 135 | msgstr "Quatro dados de entrada esperados" 136 | 137 | #: error_strings.c:80 138 | msgid "Number expected as indata" 139 | msgstr "Esperado número como dado de entrada" 140 | 141 | #: error_strings.c:88 142 | msgid "Boolean expected as indata" 143 | msgstr "Esperado boleano como dado de entrada" 144 | 145 | #: error_strings.c:96 146 | msgid "String expected as indata" 147 | msgstr "Esperado string como dado de entrada" 148 | 149 | #: error_strings.c:104 150 | msgid "Integer greater than zero expected" 151 | msgstr "Esperado inteiro maior que zero" 152 | 153 | #: error_strings.c:112 154 | msgid "Could not find current viewport" 155 | msgstr "Não pode encontrar a viewport atual" 156 | 157 | #: error_strings.c:120 158 | msgid "Setting viewport failed" 159 | msgstr "Falha no ajuste da viewport" 160 | -------------------------------------------------------------------------------- /po/ru.po: -------------------------------------------------------------------------------- 1 | # Russian translations for devilspie2 package. 2 | # Copyright (C) 2012 the devilspie2'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # Roman V. Nikolaev , 2012. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: devilspie2 0.22pre\n" 9 | "Report-Msgid-Bugs-To: gusnan@openmailbox.org\n" 10 | "POT-Creation-Date: 2014-04-02 21:21+0200\n" 11 | "PO-Revision-Date: 2014-02-20 15:06+0300\n" 12 | "Last-Translator: Roman V. Nikolaev \n" 13 | "Language-Team: Russian\n" 14 | "Language: ru\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=utf-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: config.c:188 20 | msgid "script_folder isn't a folder." 21 | msgstr "script_folder не является директорией" 22 | 23 | #: config.c:200 script.c:232 24 | #, c-format 25 | msgid "Error: %s\n" 26 | msgstr "Ошибка: %s\n" 27 | 28 | #: devilspie2.c:164 29 | msgid "Received signal:" 30 | msgstr "Получен сигнал:" 31 | 32 | #: devilspie2.c:208 33 | msgid "No script files found in the script folder - exiting." 34 | msgstr "В директории для скриптов нет скриптов - выходим." 35 | 36 | #: devilspie2.c:215 devilspie2.c:223 37 | #, c-format 38 | msgid "List of Lua files handling \"%s\" events in folder:" 39 | msgstr "Список Lua файлов для \"%s\" событий в директории:" 40 | 41 | #: devilspie2.c:289 42 | msgid "Print debug info to stdout" 43 | msgstr "Вывод отладочной информации в stdout" 44 | 45 | #: devilspie2.c:291 46 | msgid "Don't apply any rules, only emulate execution" 47 | msgstr "Не применять правила, только эмулировать выполнение" 48 | 49 | #: devilspie2.c:293 50 | msgid "Search for scripts in this folder" 51 | msgstr "Искать скрипты в заданной директории" 52 | 53 | #: devilspie2.c:293 54 | msgid "FOLDER" 55 | msgstr "ДИРЕКТОРИЯ" 56 | 57 | #: devilspie2.c:295 58 | msgid "Show Devilspie2 version and quit" 59 | msgstr "Показать версию Devilspie2 и выйти" 60 | 61 | #: devilspie2.c:300 62 | msgid "Show libwnck version and quit" 63 | msgstr "Показать версию libwnck и выйти" 64 | 65 | #: devilspie2.c:318 66 | msgid "apply rules on windows" 67 | msgstr "применить правила на окна" 68 | 69 | #: devilspie2.c:325 70 | #, c-format 71 | msgid "option parsing failed: %s" 72 | msgstr "ошибка парсинга: %s" 73 | 74 | #: devilspie2.c:346 75 | msgid "Couldn't create the default folder for devilspie2 scripts." 76 | msgstr "Не могу создать директорию по умолчанию для скриптов." 77 | 78 | #: devilspie2.c:373 79 | msgid "An X11 display is required for devilspie2." 80 | msgstr "Для работы необходим дисплей X11" 81 | 82 | #: devilspie2.c:381 83 | msgid "Couldn't init script error messages!" 84 | msgstr "Не удалось инициализировать сообщения об ошибке скрипта!" 85 | 86 | #: devilspie2.c:398 87 | msgid "Running devilspie2 in debug and emulate mode." 88 | msgstr "Запустить devilspie2 в режиме отладки и эмуляции." 89 | 90 | #: devilspie2.c:400 91 | msgid "Running devilspie2 in debug mode." 92 | msgstr "Запустить devilspie2 в режиме отладки." 93 | 94 | #: devilspie2.c:405 95 | #, c-format 96 | msgid "Using scripts from folder: %s" 97 | msgstr "Используются скрипты из директории: %s" 98 | 99 | #: devilspie2.c:421 100 | msgid "Couldn't create directory monitor!" 101 | msgstr "Не удалось создать наблюдателя директории!" 102 | 103 | #: script_functions.c:732 script_functions.c:778 104 | #, c-format 105 | msgid "Workspace number %d does not exist!" 106 | msgstr "Рабочий стол номер %d не найден!" 107 | 108 | #: script_functions.c:1673 109 | msgid "Could not get workspace" 110 | msgstr "Не могу получить рабочий стол" 111 | 112 | #: xutils.c:183 xutils.c:201 error_strings.c:127 113 | msgid "Failed!" 114 | msgstr "Ошибка!" 115 | 116 | #: error_strings.c:49 117 | msgid "Couldn't allocate error string!" 118 | msgstr "Не удалось выделить память для сообщения об ошибке!" 119 | 120 | #: error_strings.c:51 121 | msgid "No indata expected" 122 | msgstr "Используется без параметров" 123 | 124 | #: error_strings.c:58 125 | msgid "One indata expected" 126 | msgstr "Ожидается один параметр" 127 | 128 | #: error_strings.c:65 129 | msgid "Two indata expected" 130 | msgstr "Ожидается два параметра" 131 | 132 | #: error_strings.c:72 133 | msgid "Four indata expected" 134 | msgstr "Ожидается четыре параметра" 135 | 136 | #: error_strings.c:80 137 | msgid "Number expected as indata" 138 | msgstr "Ожидается число" 139 | 140 | #: error_strings.c:88 141 | msgid "Boolean expected as indata" 142 | msgstr "Ожидается boolean " 143 | 144 | #: error_strings.c:96 145 | msgid "String expected as indata" 146 | msgstr "Ожидается строка" 147 | 148 | #: error_strings.c:104 149 | msgid "Integer greater than zero expected" 150 | msgstr "Ожидается целое больше нуля" 151 | 152 | #: error_strings.c:112 153 | msgid "Could not find current viewport" 154 | msgstr "Не могу найти текущее окно" 155 | 156 | #: error_strings.c:120 157 | msgid "Setting viewport failed" 158 | msgstr "Ошибка настройки окна" 159 | -------------------------------------------------------------------------------- /po/sv.po: -------------------------------------------------------------------------------- 1 | # Swedish translation of Devilspie2 2 | # Copyright (C) 2011-2017 Andreas Rönnquist 3 | # This file is distributed under the same license as the devilspie2 package. 4 | # Andreas Rönnquist , 2011-2017. 5 | # 6 | # 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: devilspie2 0.42\n" 10 | "Report-Msgid-Bugs-To: gusnan@openmailbox.org\n" 11 | "POT-Creation-Date: 2017-01-04 15:35+0100\n" 12 | "PO-Revision-Date: 2016-03-11 10:09+0100\n" 13 | "Last-Translator: Andreas Rönnquist \n" 14 | "Language-Team: Swedish\n" 15 | "Language: sv\n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "X-Generator: Poedit 1.6.10\n" 20 | 21 | #: config.c:192 22 | msgid "script_folder isn't a folder." 23 | msgstr "script_folder är inte en folder." 24 | 25 | #: config.c:204 script.c:238 26 | #, c-format 27 | msgid "Error: %s\n" 28 | msgstr "Fel: %s\n" 29 | 30 | #: devilspie2.c:181 31 | msgid "Received signal:" 32 | msgstr "Tog emot signal:" 33 | 34 | #: devilspie2.c:232 35 | #, c-format 36 | msgid "List of Lua files handling \"%s\" events in folder:" 37 | msgstr "Lista på Lua-filer som hanterar \"%s\"-händelser i mappen:" 38 | 39 | #: devilspie2.c:242 40 | msgid "No script files found in the script folder - exiting." 41 | msgstr "Inga skript hittades i skript-mappen - avslutar." 42 | 43 | #: devilspie2.c:308 44 | msgid "Print debug info to stdout" 45 | msgstr "Skriv ut debug-information till stdout" 46 | 47 | #: devilspie2.c:311 48 | msgid "Don't apply any rules, only emulate execution" 49 | msgstr "Applicera inga regler, emulera endast körning" 50 | 51 | #: devilspie2.c:314 52 | msgid "Search for scripts in this folder" 53 | msgstr "Sök efter skript i denna mapp" 54 | 55 | #: devilspie2.c:314 56 | msgid "FOLDER" 57 | msgstr "MAPP" 58 | 59 | #: devilspie2.c:317 60 | msgid "Show Devilspie2 version and quit" 61 | msgstr "Visa version av Devilspie2 och avsluta" 62 | 63 | #: devilspie2.c:323 64 | msgid "Show libwnck version and quit" 65 | msgstr "Visa version av libwnck och avsluta" 66 | 67 | #: devilspie2.c:340 68 | msgid "apply rules on windows" 69 | msgstr "applicera regler på fönster" 70 | 71 | #: devilspie2.c:347 72 | #, c-format 73 | msgid "option parsing failed: %s" 74 | msgstr "tolkning av alternativ misslyckades; %s" 75 | 76 | #: devilspie2.c:370 77 | msgid "Couldn't create the default folder for devilspie2 scripts." 78 | msgstr "Kunde inte skapa standard-mappen för devilspie2-skript." 79 | 80 | #: devilspie2.c:397 81 | msgid "An X11 display is required for devilspie2." 82 | msgstr "En X11-display krävs för att köra devilspie2" 83 | 84 | #: devilspie2.c:405 85 | msgid "Couldn't init script error messages!" 86 | msgstr "Kunde inte initiera skript-felmeddelanden!" 87 | 88 | #: devilspie2.c:426 89 | msgid "Running devilspie2 in debug and emulate mode." 90 | msgstr "Kör Devilspie2 i debug och emulerings-mode" 91 | 92 | #: devilspie2.c:428 93 | msgid "Running devilspie2 in debug mode." 94 | msgstr "Kör Devilspie2 i debug-mode" 95 | 96 | #: devilspie2.c:433 97 | #, c-format 98 | msgid "Using scripts from folder: %s" 99 | msgstr "Använder skript från mappen: %s" 100 | 101 | #: devilspie2.c:449 102 | msgid "Couldn't create directory monitor!" 103 | msgstr "Kunde inte skapa folder-monitor!" 104 | 105 | #: script_functions.c:709 script_functions.c:755 106 | #, c-format 107 | msgid "Workspace number %d does not exist!" 108 | msgstr "Arbetsyta nummer %d finns inte!" 109 | 110 | #: script_functions.c:1734 111 | msgid "Could not get workspace" 112 | msgstr "Kunde inte hämta arbetsytan" 113 | 114 | #: xutils.c:186 xutils.c:204 error_strings.c:136 115 | msgid "Failed!" 116 | msgstr "Misslyckades!" 117 | 118 | #: error_strings.c:51 119 | msgid "Couldn't allocate error string!" 120 | msgstr "Kunde inte allokera felsträng!" 121 | 122 | #: error_strings.c:53 123 | msgid "No indata expected" 124 | msgstr "Ingen indata väntad" 125 | 126 | #: error_strings.c:60 127 | msgid "One indata expected" 128 | msgstr "En indata väntad" 129 | 130 | #: error_strings.c:67 131 | msgid "Two indata expected" 132 | msgstr "Två indata väntade" 133 | 134 | #: error_strings.c:74 135 | msgid "Four indata expected" 136 | msgstr "Fyra indata väntade" 137 | 138 | #: error_strings.c:81 139 | msgid "One or two indata expected" 140 | msgstr "En eller två indata väntat" 141 | 142 | #: error_strings.c:89 143 | msgid "Number expected as indata" 144 | msgstr "Nummer väntat som indata" 145 | 146 | #: error_strings.c:97 147 | msgid "Boolean expected as indata" 148 | msgstr "Boolskt värde väntat som indata" 149 | 150 | #: error_strings.c:105 151 | msgid "String expected as indata" 152 | msgstr "Sträng väntad som indata" 153 | 154 | #: error_strings.c:113 155 | msgid "Integer greater than zero expected" 156 | msgstr "Heltal större än noll väntat" 157 | 158 | #: error_strings.c:121 159 | msgid "Could not find current viewport" 160 | msgstr "Kunde inte hitta aktuell visningsyta" 161 | 162 | #: error_strings.c:129 163 | msgid "Setting viewport failed" 164 | msgstr "Kunde inte sätta visningsyta" 165 | 166 | #~ msgid "List of Lua files handling \"window open\" events in folder:" 167 | #~ msgstr "Lista på Lua-filer som hanterar \"window open\"-händelser i mappen:" 168 | -------------------------------------------------------------------------------- /src/compat.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2021 Darren Salt 4 | * 5 | * devilspie2 is free software: you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * devilspie2 is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with devilspie2. 17 | * If not, see . 18 | */ 19 | 20 | #ifndef __HEADER_COMPAT_ 21 | #define __HEADER_COMPAT_ 22 | 23 | #if defined(__GNUC__) || defined(__clang__) 24 | # define ATTR_MALLOC __attribute__((malloc)) 25 | #else 26 | # define ATTR_MALLOC 27 | #endif 28 | 29 | #endif /* __HEADER_COMPAT_ */ 30 | -------------------------------------------------------------------------------- /src/config.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2013-2017 Andreas Rönnquist 4 | * 5 | * devilspie2 is free software: you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * devilspie2 is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with devilspie2. 17 | * If not, see . 18 | */ 19 | #include 20 | 21 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include "script.h" 34 | #include "script_functions.h" 35 | 36 | #include "config.h" 37 | 38 | /** 39 | * 40 | */ 41 | GSList *event_lists[W_NUM_EVENTS] = { NULL, NULL, NULL, NULL, NULL }; 42 | const char *const event_names[W_NUM_EVENTS] = { 43 | "window_open", 44 | "window_close", 45 | "window_focus", 46 | "window_blur", 47 | "window_name_change", 48 | }; 49 | 50 | 51 | /** 52 | * filename_list_sortfunc 53 | * function to sort the inserted filenames, to be able to determine 54 | * which order files are loaded. 55 | */ 56 | static gint filename_list_sortfunc(gconstpointer a,gconstpointer b) 57 | { 58 | gchar *file1 = (gchar*)a; 59 | gchar *file2 = (gchar*)b; 60 | 61 | return g_ascii_strcasecmp(file1, file2); 62 | } 63 | 64 | 65 | /** 66 | * 67 | */ 68 | static GSList *add_lua_file_to_list(GSList *list, gchar *filename) 69 | { 70 | gchar *temp_filename = g_strdup(filename); 71 | 72 | list=g_slist_insert_sorted(list, 73 | temp_filename, 74 | filename_list_sortfunc); 75 | 76 | return list; 77 | } 78 | 79 | 80 | 81 | /** 82 | * 83 | */ 84 | static GSList *get_table_of_strings(lua_State *luastate, 85 | gchar *script_folder, 86 | gchar *table_name) 87 | { 88 | GSList *list = NULL; 89 | 90 | if (luastate) { 91 | 92 | lua_getglobal(luastate, table_name); 93 | 94 | // Do we have a value? 95 | if (lua_isnil(luastate, -1)) { 96 | goto EXITPOINT; 97 | } 98 | 99 | // Is it a table? 100 | if (!lua_istable(luastate, -1)) { 101 | goto EXITPOINT; 102 | } 103 | 104 | lua_pushnil(luastate); 105 | 106 | while(lua_next(luastate, -2)) { 107 | if (lua_isstring(luastate, -1)) { 108 | char *temp = (char *)lua_tostring(luastate, -1); 109 | 110 | gchar *added_filename = g_build_path(G_DIR_SEPARATOR_S, 111 | script_folder, 112 | temp, 113 | NULL); 114 | 115 | list = add_lua_file_to_list(list, added_filename); 116 | } 117 | lua_pop(luastate, 1); 118 | } 119 | lua_pop(luastate, 1); 120 | } 121 | 122 | EXITPOINT: 123 | 124 | return list; 125 | } 126 | 127 | 128 | /** 129 | * is_in_list 130 | * Go through _one_ list, and check if the filename is in this list 131 | */ 132 | static gboolean is_in_list(GSList *list, gchar *filename) 133 | { 134 | gboolean result = FALSE; 135 | 136 | if (list) { 137 | GSList *temp_list = list; 138 | 139 | while (temp_list) { 140 | gchar *list_filename = (gchar*)temp_list->data; 141 | if (list_filename) { 142 | 143 | if (g_ascii_strcasecmp(list_filename, filename) == 0) { 144 | result = TRUE; 145 | } 146 | } 147 | temp_list = temp_list->next; 148 | } 149 | } 150 | 151 | return result; 152 | } 153 | 154 | 155 | /** 156 | * is_in_any_list 157 | * Go through our lists, and check if the file is already in any of them 158 | */ 159 | static gboolean is_in_any_list(gchar *filename) 160 | { 161 | win_event_type i; 162 | 163 | for (i=0; i < W_NUM_EVENTS; i++) { 164 | if (is_in_list(event_lists[i], filename)) 165 | return TRUE; 166 | } 167 | 168 | return FALSE; 169 | } 170 | 171 | 172 | 173 | /** 174 | * load_config 175 | * Load configuration from a file - From this we set up the lists of files 176 | * which decides what script to load on what wnck event. 177 | */ 178 | int load_config(gchar *filename) 179 | { 180 | lua_State *config_lua_state = NULL; 181 | int result = 0; 182 | const gchar *current_file = NULL; 183 | GSList *temp_window_open_file_list = NULL; 184 | 185 | // First get list of Lua files in folder - Then read variables from 186 | // devilspie2.lua and put the files in the required lists. 187 | 188 | gchar *script_folder = g_path_get_dirname(filename); 189 | 190 | GDir *dir = g_dir_open(script_folder, 0, NULL); 191 | if (!g_file_test(script_folder, G_FILE_TEST_IS_DIR)) { 192 | 193 | printf("%s\n", _("script_folder isn't a folder.")); 194 | return -1; 195 | } 196 | 197 | int total_number_of_files = 0; 198 | 199 | config_lua_state = init_script(); 200 | 201 | if (g_file_test(filename, G_FILE_TEST_EXISTS)) { 202 | 203 | if (run_script(config_lua_state, filename) != 0) { 204 | printf(_("Error: %s\n"), filename); 205 | result = -1; 206 | goto EXITPOINT; 207 | } 208 | 209 | event_lists[W_CLOSE] = get_table_of_strings(config_lua_state, 210 | script_folder, 211 | "scripts_window_close"); 212 | event_lists[W_FOCUS] = get_table_of_strings(config_lua_state, 213 | script_folder, 214 | "scripts_window_focus"); 215 | event_lists[W_BLUR] = get_table_of_strings(config_lua_state, 216 | script_folder, 217 | "scripts_window_blur"); 218 | event_lists[W_NAME_CHANGED] = get_table_of_strings(config_lua_state, 219 | script_folder, 220 | "scripts_window_name_change"); 221 | } 222 | 223 | // add the files in the folder to our linked list 224 | while ((current_file = g_dir_read_name(dir))) { 225 | 226 | gchar *temp_filename = g_build_path(G_DIR_SEPARATOR_S, 227 | script_folder, 228 | current_file, 229 | NULL); 230 | 231 | // we only bother with *.lua in the folder 232 | // we also ignore dot files 233 | if (current_file[0] != '.' && g_str_has_suffix(current_file, ".lua")) { 234 | if (!is_in_any_list(temp_filename)) { 235 | temp_window_open_file_list = 236 | add_lua_file_to_list(temp_window_open_file_list, temp_filename); 237 | } 238 | total_number_of_files++; 239 | } 240 | 241 | g_free(temp_filename); 242 | } 243 | 244 | event_lists[W_OPEN] = temp_window_open_file_list; 245 | EXITPOINT: 246 | if (config_lua_state) 247 | done_script(config_lua_state); 248 | 249 | return result; 250 | } 251 | 252 | 253 | 254 | /** 255 | * 256 | */ 257 | static void unallocate_file_list(GSList *file_list) 258 | { 259 | if (file_list) { 260 | while(file_list) { 261 | g_free ((gchar*)file_list->data); 262 | file_list = file_list->next; 263 | } 264 | } 265 | } 266 | 267 | 268 | /** 269 | * 270 | */ 271 | void clear_file_lists() 272 | { 273 | win_event_type i = 0; 274 | 275 | for (i = 0; i < W_NUM_EVENTS; i++) { 276 | if (event_lists[i]) { 277 | unallocate_file_list(event_lists[i]); 278 | g_slist_free(event_lists[i]); 279 | event_lists[i] = NULL; 280 | } 281 | } 282 | } 283 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2013-2017 Andreas Rönnquist 4 | * 5 | * devilspie2 is free software: you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * devilspie2 is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with devilspie2. 17 | * If not, see . 18 | */ 19 | #ifndef __HEADER_CONFIG_ 20 | #define __HEADER_CONFIG_ 21 | 22 | #include "glib.h" 23 | 24 | int load_config(gchar *config_filename); 25 | 26 | void clear_file_lists(); 27 | 28 | typedef enum { 29 | W_OPEN, 30 | W_CLOSE, 31 | W_FOCUS, 32 | W_BLUR, 33 | W_NAME_CHANGED, 34 | W_NUM_EVENTS /* keep this at the end */ 35 | } win_event_type; 36 | 37 | extern GSList *event_lists[W_NUM_EVENTS]; 38 | extern const char *const event_names[W_NUM_EVENTS]; 39 | 40 | // Our git version which is defined through some magic in the build system 41 | extern const char *gitversion; 42 | 43 | #endif /*__HEADER_CONFIG_*/ 44 | -------------------------------------------------------------------------------- /src/devilspie2.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2005 Ross Burton, 2011-2017 Andreas Rönnquist 4 | * 5 | * devilspie2 is free software: you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * devilspie2 is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with devilspie2. 17 | * If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | #include "script.h" 39 | #include "script_functions.h" 40 | 41 | #include "error_strings.h" 42 | 43 | #include "config.h" 44 | 45 | 46 | #if (GTK_MAJOR_VERSION >= 3) 47 | #define HAVE_GTK3 48 | #endif 49 | 50 | /** 51 | * 52 | */ 53 | GMainLoop *loop = NULL; 54 | 55 | static gboolean debug = FALSE; 56 | static gboolean emulate = FALSE; 57 | static gboolean show_version = FALSE; 58 | 59 | // libwnck Version Information is only availible if you have 60 | // libwnck 3.0 or later 61 | static gboolean show_wnck_version = FALSE; 62 | 63 | static gboolean show_lua_version = FALSE; 64 | 65 | static gchar *script_folder = NULL; 66 | static gchar *temp_folder = NULL; 67 | 68 | GFileMonitor *mon = NULL; 69 | 70 | gchar *config_filename = NULL; 71 | 72 | WnckHandle *my_wnck_handle = NULL; 73 | 74 | /** 75 | * 76 | */ 77 | static void load_list_of_scripts(WnckScreen *screen G_GNUC_UNUSED, WnckWindow *window, 78 | GSList *file_list) 79 | { 80 | GSList *temp_file_list = file_list; 81 | // set the window to work on 82 | set_current_window(window); 83 | 84 | // for every file in the folder - load the script 85 | if (event_lists[W_OPEN] != NULL) { 86 | 87 | while(temp_file_list) { 88 | gchar *filename = (gchar*)temp_file_list->data; 89 | 90 | // is it a Lua file? 91 | if (g_str_has_suffix((gchar*)filename, ".lua")) { 92 | 93 | // init the script, run it 94 | if (!run_script(global_lua_state, filename)) 95 | /**/; 96 | 97 | } 98 | temp_file_list=temp_file_list->next; 99 | } 100 | } 101 | return; 102 | 103 | } 104 | 105 | 106 | static void window_name_changed_cb(WnckWindow *window) 107 | { 108 | WnckScreen * screen = wnck_window_get_screen(window); 109 | if(screen == NULL) return; 110 | 111 | // Handle duplicate name-change events 112 | // Simple method: just track the most recent event regardless of window 113 | static WnckWindow *previous = NULL; 114 | static char *prevname = NULL; 115 | 116 | const char *newname = wnck_window_get_name(window); 117 | if (window == previous && prevname && !strcmp (prevname, newname)) 118 | return; 119 | // Store the info for the next event 120 | free(prevname); 121 | prevname = strdup(newname); 122 | previous = window; 123 | 124 | load_list_of_scripts(screen, window, event_lists[W_NAME_CHANGED]); 125 | } 126 | 127 | /** 128 | * 129 | */ 130 | static void window_opened_cb(WnckScreen *screen, WnckWindow *window) 131 | { 132 | load_list_of_scripts(screen, window, event_lists[W_OPEN]); 133 | /* 134 | Attach a listener to each window for window-specific changes 135 | Safe to do this way as long as the 'user data' parameter is NULL 136 | */ 137 | g_signal_connect(window, "name-changed", (GCallback)window_name_changed_cb, NULL); 138 | } 139 | 140 | 141 | /** 142 | * 143 | */ 144 | static void window_closed_cb(WnckScreen *screen, WnckWindow *window) 145 | { 146 | load_list_of_scripts(screen, window, event_lists[W_CLOSE]); 147 | } 148 | 149 | 150 | /** 151 | * 152 | */ 153 | static void window_changed_cb(WnckScreen *screen, WnckWindow *window) 154 | { 155 | WnckWindow *cur; 156 | 157 | load_list_of_scripts(screen, window, event_lists[W_BLUR]); 158 | cur = wnck_screen_get_active_window(screen); 159 | load_list_of_scripts(screen, cur, event_lists[W_FOCUS]); 160 | } 161 | 162 | 163 | /** 164 | * 165 | */ 166 | void init_screens() 167 | { 168 | int i; 169 | int num_screens; 170 | 171 | #ifndef GDK_VERSION_3_10 172 | num_screens = gdk_display_get_n_screens(gdk_display_get_default()); 173 | #else 174 | num_screens = 1; 175 | #endif 176 | 177 | for (i=0; idata; 229 | 230 | if (file_name) { 231 | if (g_str_has_suffix((gchar*)file_name, ".lua")) { 232 | printf("%s\n", (gchar*)file_name); 233 | } 234 | } 235 | temp_list = temp_list->next; 236 | } 237 | } 238 | } 239 | 240 | 241 | /** 242 | * 243 | */ 244 | void print_script_lists() 245 | { 246 | gboolean have_any_files = FALSE; 247 | win_event_type i; 248 | 249 | if (debug) 250 | printf("------------\n"); 251 | 252 | for (i = 0; i < W_NUM_EVENTS; i++) { 253 | if (event_lists[i]) 254 | have_any_files = TRUE; 255 | // If we are running debug mode - print the list of files: 256 | if (debug) { 257 | printf(_("List of Lua files handling \"%s\" events in folder:"), 258 | event_names[i]); 259 | printf("\n"); 260 | if (event_lists[i]) { 261 | print_list(event_lists[i]); 262 | } 263 | } 264 | } 265 | 266 | if (!have_any_files) { 267 | printf("%s\n\n", _("No script files found in the script folder - exiting.")); 268 | exit(EXIT_SUCCESS); 269 | } 270 | } 271 | 272 | 273 | /** 274 | * 275 | */ 276 | void folder_changed_callback(GFileMonitor *mon G_GNUC_UNUSED, 277 | GFile *first_file, 278 | GFile *second_file G_GNUC_UNUSED, 279 | GFileMonitorEvent event, 280 | gpointer user_data) 281 | { 282 | gchar *our_filename = (gchar*)(user_data); 283 | 284 | // If a file is created or deleted, we need to check the file lists again 285 | if ((event == G_FILE_MONITOR_EVENT_CREATED) || 286 | (event == G_FILE_MONITOR_EVENT_DELETED)) { 287 | 288 | clear_file_lists(); 289 | 290 | set_current_window(NULL); 291 | load_config(our_filename); 292 | 293 | if (debug) 294 | printf("Files in folder updated!\n - new lists:\n\n"); 295 | 296 | print_script_lists(); 297 | 298 | if (debug) 299 | printf("-----------\n"); 300 | } 301 | 302 | // Also monitor if our devilspie2.lua file is changed - since it handles 303 | // which files are window close or window open scripts. 304 | if (event == G_FILE_MONITOR_EVENT_CHANGED) { 305 | if (first_file) { 306 | gchar *short_filename = g_file_get_basename(first_file); 307 | 308 | if (g_strcmp0(short_filename, "devilspie2.lua")==0) { 309 | 310 | clear_file_lists(); 311 | 312 | set_current_window(NULL); 313 | load_config(our_filename); 314 | 315 | print_script_lists(); 316 | 317 | if (debug) 318 | printf("----------"); 319 | } 320 | } 321 | } 322 | } 323 | 324 | 325 | /** 326 | * Program main entry 327 | */ 328 | int main(int argc, char *argv[]) 329 | { 330 | static const GOptionEntry options[]= { 331 | { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, 332 | N_("Print debug info to stdout"), NULL 333 | }, 334 | { "emulate", 'e', 0, G_OPTION_ARG_NONE, &emulate, 335 | N_("Don't apply any rules, only emulate execution"), NULL 336 | }, 337 | { "folder", 'f', 0, G_OPTION_ARG_STRING, &script_folder, 338 | N_("Search for scripts in this folder"), N_("FOLDER") 339 | }, 340 | { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, 341 | N_("Show Devilspie2 version and quit"), NULL 342 | }, 343 | // libwnck Version Information is only availible if you have 344 | // libwnck 3.0 or later 345 | { "wnck-version", 'w', 0, G_OPTION_ARG_NONE, &show_wnck_version, 346 | N_("Show libwnck version and quit"), NULL 347 | }, 348 | { "lua-version", 'l', 0, G_OPTION_ARG_NONE, &show_lua_version, 349 | N_("Show Lua version and quit"), NULL 350 | }, 351 | { NULL } 352 | }; 353 | 354 | GError *error = NULL; 355 | GOptionContext *context; 356 | 357 | // Init gettext stuff 358 | setlocale(LC_ALL, ""); 359 | 360 | bindtextdomain(PACKAGE, LOCALEDIR); 361 | bind_textdomain_codeset(PACKAGE, ""); 362 | textdomain(PACKAGE); 363 | 364 | gchar *devilspie2_description = g_strdup_printf(_("apply rules on windows")); 365 | 366 | gchar *full_desc_string = g_strdup_printf("- %s", devilspie2_description); 367 | 368 | context = g_option_context_new(full_desc_string); 369 | g_option_context_add_main_entries(context, options, NULL); 370 | if (!g_option_context_parse(context, &argc, &argv, &error)) { 371 | g_print(_("option parsing failed: %s"), error->message); 372 | printf("\n"); 373 | exit(EXIT_FAILURE); 374 | } 375 | 376 | gdk_init(&argc, &argv); 377 | 378 | g_free(full_desc_string); 379 | g_free(devilspie2_description); 380 | 381 | // if the folder is NULL, default to ~/.config/devilspie2/ 382 | if (script_folder == NULL) { 383 | 384 | temp_folder = g_build_path(G_DIR_SEPARATOR_S, 385 | g_get_user_config_dir(), 386 | "devilspie2", 387 | NULL); 388 | 389 | // check if the folder does exist 390 | if (!g_file_test(temp_folder, G_FILE_TEST_IS_DIR)) { 391 | 392 | // - and if it doesn't, create it. 393 | if (g_mkdir(temp_folder, 0700) != 0) { 394 | printf("%s\n", _("Couldn't create the default folder for devilspie2 scripts.")); 395 | exit(EXIT_FAILURE); 396 | } 397 | } 398 | 399 | script_folder = temp_folder; 400 | } 401 | 402 | gboolean shown = FALSE; 403 | if (show_version) { 404 | printf("Devilspie2 v%s\n", DEVILSPIE2_VERSION); 405 | shown = TRUE; 406 | } 407 | // libwnck Version Information is only availible if you have 408 | // libwnck 3.0 or later 409 | if (show_wnck_version) { 410 | #ifdef _DEBUG 411 | printf("GTK v%d.%d.%d\n", 412 | GTK_MAJOR_VERSION, 413 | GTK_MINOR_VERSION, 414 | GTK_MICRO_VERSION); 415 | #endif 416 | #ifdef HAVE_GTK3 417 | printf("libwnck v%d.%d.%d\n", 418 | WNCK_MAJOR_VERSION, 419 | WNCK_MINOR_VERSION, 420 | WNCK_MICRO_VERSION); 421 | #else 422 | printf("libwnck v2.x\n"); 423 | #endif 424 | shown = TRUE; 425 | } 426 | if (show_lua_version) { 427 | puts(LUA_VERSION); 428 | shown = TRUE; 429 | } 430 | if (shown) 431 | exit(0); 432 | 433 | #if (GTK_MAJOR_VERSION >= 3) 434 | if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) { 435 | puts(_("An X11 display is required for devilspie2.")); 436 | if (getenv("WAYLAND_DISPLAY")) 437 | puts(_("Wayland & XWayland are not supported.\nSee https://github.com/dsalt/devilspie2/issues/7")); 438 | puts(""); 439 | return EXIT_FAILURE; 440 | } 441 | #endif 442 | 443 | if (init_script_error_messages()!=0) { 444 | printf("%s\n", _("Couldn't init script error messages!")); 445 | exit(EXIT_FAILURE); 446 | } 447 | 448 | // set the current window to NULL, we don't need to be able to modify 449 | // the windows when reading the config 450 | set_current_window(NULL); 451 | 452 | config_filename = 453 | g_build_filename(script_folder, "devilspie2.lua", NULL); 454 | 455 | if (load_config(config_filename) != 0) { 456 | 457 | devilspie_exit(); 458 | return EXIT_FAILURE; 459 | } 460 | 461 | if (debug) { 462 | 463 | if (emulate) { 464 | printf("%s\n\n", _("Running devilspie2 in debug and emulate mode.")); 465 | } else { 466 | printf("%s\n\n", _("Running devilspie2 in debug mode.")); 467 | } 468 | 469 | printf(_("Using scripts from folder: %s"), script_folder); 470 | 471 | printf("\n"); 472 | 473 | devilspie2_debug = TRUE; 474 | } 475 | 476 | // Should we only run an emulation (don't modify any windows) 477 | if (emulate) devilspie2_emulate = emulate; 478 | 479 | GFile *directory_file; 480 | directory_file = g_file_new_for_path(script_folder); 481 | // mon = g_file_monitor_directory(directory_file, G_FILE_MONITOR_WATCH_MOUNTS, 482 | mon = g_file_monitor_directory(directory_file, G_FILE_MONITOR_NONE, 483 | NULL, NULL); 484 | if (!mon) { 485 | printf("%s\n", _("Couldn't create directory monitor!")); 486 | return EXIT_FAILURE; 487 | } 488 | 489 | g_signal_connect(mon, "changed", G_CALLBACK(folder_changed_callback), 490 | (gpointer)(config_filename)); 491 | 492 | global_lua_state = init_script(); 493 | print_script_lists(); 494 | 495 | if (debug) printf("------------\n"); 496 | 497 | // remove stuff cleanly 498 | atexit(devilspie_exit); 499 | 500 | struct sigaction signal_action; 501 | 502 | sigemptyset(&signal_action.sa_mask); 503 | signal_action.sa_flags = 0; 504 | signal_action.sa_handler = signal_handler; 505 | 506 | if (sigaction(SIGINT, &signal_action, NULL) == -1) { 507 | exit(EXIT_FAILURE); 508 | } 509 | 510 | my_wnck_handle = wnck_handle_new(WNCK_CLIENT_TYPE_PAGER); 511 | init_screens(); 512 | 513 | loop=g_main_loop_new(NULL, TRUE); 514 | g_main_loop_run(loop); 515 | 516 | return EXIT_SUCCESS; 517 | } 518 | -------------------------------------------------------------------------------- /src/error_strings.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2012-2017 Andreas Rönnquist 4 | * Copyright (C) 2019-2021 Darren Salt 5 | * 6 | * devilspie2 is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * devilspie2 is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with devilspie2. 18 | * If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "error_strings.h" 26 | 27 | const int max_indata_expected; 28 | gchar *num_indata_expected_errors[] = {NULL, NULL, NULL, NULL, NULL}; 29 | 30 | gchar *n_or_m_indata_expected_error = NULL; 31 | gchar *n_to_m_indata_expected_error = NULL; 32 | 33 | gchar *at_least_four_indata_expected_error = NULL; 34 | 35 | gchar *number_expected_as_indata_error = NULL; 36 | gchar *boolean_expected_as_indata_error = NULL; 37 | gchar *string_expected_as_indata_error = NULL; 38 | 39 | gchar *number_or_string_expected_as_indata_error = NULL; 40 | gchar *number_or_string_or_boolean_expected_as_indata_error = NULL; 41 | 42 | gchar *integer_greater_than_zero_expected_error = NULL; 43 | gchar *could_not_find_current_viewport_error = NULL; 44 | 45 | gchar *setting_viewport_failed_error = NULL; 46 | 47 | gchar *failed_string = NULL; 48 | 49 | /** 50 | * 51 | */ 52 | #define ALLOCATE_ERROR_STRING _("Couldn't allocate error string!") 53 | #define INIT_ERRMSG(errvar, errtxt) \ 54 | { \ 55 | errvar = g_strdup(errtxt); \ 56 | if (!errvar) { \ 57 | printf("%s: \"%s\"\n", ALLOCATE_ERROR_STRING, errtxt); \ 58 | return -1; \ 59 | } \ 60 | } 61 | int init_script_error_messages() 62 | { 63 | INIT_ERRMSG(num_indata_expected_errors[0], _("No parameters expected")); 64 | INIT_ERRMSG(num_indata_expected_errors[1], _("One parameter expected")); 65 | INIT_ERRMSG(num_indata_expected_errors[2], _("Two parameters expected")); 66 | INIT_ERRMSG(num_indata_expected_errors[3], _("Three parameters expected")); 67 | INIT_ERRMSG(num_indata_expected_errors[4], _("Four parameters expected")); 68 | 69 | INIT_ERRMSG(n_or_m_indata_expected_error, _("%d or %d parameters expected")); 70 | INIT_ERRMSG(n_to_m_indata_expected_error, _("%d to %d parameters expected")); 71 | 72 | INIT_ERRMSG(at_least_four_indata_expected_error, _("At least four parameters expected")); 73 | 74 | INIT_ERRMSG(number_expected_as_indata_error, _("Number expected as parameter")); 75 | INIT_ERRMSG(boolean_expected_as_indata_error, _("Boolean expected as parameter")); 76 | INIT_ERRMSG(string_expected_as_indata_error, _("String expected as parameter")); 77 | 78 | INIT_ERRMSG(number_or_string_expected_as_indata_error, _("Number or string expected as parameter")); 79 | INIT_ERRMSG(number_or_string_or_boolean_expected_as_indata_error, _("Number or string or boolean expected as parameter")); 80 | 81 | INIT_ERRMSG(integer_greater_than_zero_expected_error, _("Integer greater than zero expected")); 82 | INIT_ERRMSG(could_not_find_current_viewport_error, _("Could not find current viewport")); 83 | INIT_ERRMSG(setting_viewport_failed_error, _("Setting viewport failed")); 84 | 85 | INIT_ERRMSG(failed_string, _("Failed!")); 86 | 87 | return 0; 88 | } 89 | 90 | 91 | /** 92 | * 93 | */ 94 | void done_script_error_messages() 95 | { 96 | for (int i = 0; i <= max_indata_expected; i++) { 97 | g_free(num_indata_expected_errors[i]); 98 | } 99 | 100 | g_free(n_or_m_indata_expected_error); 101 | g_free(n_to_m_indata_expected_error); 102 | 103 | g_free(at_least_four_indata_expected_error); 104 | 105 | g_free(number_expected_as_indata_error); 106 | g_free(boolean_expected_as_indata_error); 107 | g_free(string_expected_as_indata_error); 108 | 109 | g_free(number_or_string_expected_as_indata_error); 110 | g_free(number_or_string_or_boolean_expected_as_indata_error); 111 | 112 | g_free(integer_greater_than_zero_expected_error); 113 | g_free(could_not_find_current_viewport_error); 114 | g_free(setting_viewport_failed_error); 115 | 116 | g_free(failed_string); 117 | } 118 | -------------------------------------------------------------------------------- /src/error_strings.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * This file is part of devilspie2 4 | * Copyright (C) 2012-2017 Andreas Rönnquist 5 | * 6 | * devilspie2 is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * devilspie2 is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with devilspie2. 18 | * If not, see . 19 | */ 20 | #ifndef __HEADER_ERROR_STRINGS_ 21 | #define __HEADER_ERROR_STRINGS_ 22 | 23 | /** 24 | * 25 | */ 26 | extern const int max_indata_expected; 27 | extern gchar *num_indata_expected_errors[]; 28 | 29 | extern gchar *n_or_m_indata_expected_error; 30 | extern gchar *n_to_m_indata_expected_error; 31 | 32 | extern gchar *at_least_four_indata_expected_error; 33 | 34 | extern gchar *number_expected_as_indata_error; 35 | extern gchar *boolean_expected_as_indata_error; 36 | extern gchar *string_expected_as_indata_error; 37 | 38 | extern gchar *number_or_string_expected_as_indata_error; 39 | extern gchar *number_or_string_or_boolean_expected_as_indata_error; 40 | 41 | extern gchar *integer_greater_than_zero_expected_error; 42 | extern gchar *could_not_find_current_viewport_error; 43 | 44 | extern gchar *setting_viewport_failed_error; 45 | 46 | extern gchar *failed_string; 47 | 48 | /** 49 | * 50 | */ 51 | int init_script_error_messages(); 52 | void done_script_error_messages(); 53 | 54 | 55 | #endif /*__HEADER_ERROR_STRINGS_*/ 56 | -------------------------------------------------------------------------------- /src/intl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2001 Havoc Pennington, 2011-2019 Andreas Rönnquist 4 | * Copyright (C) 2019-2021 Darren Salt 5 | * 6 | * devilspie2 is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * devilspie2 is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with devilspie2. 18 | * If not, see . 19 | */ 20 | #ifndef __HEADER_INTL__ 21 | #define __HEADER_INTL__ 22 | 23 | #include 24 | #define _(String) gettext (String) 25 | #define gettext_noop(String) String 26 | #define N_(String) gettext_noop (String) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/script.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2011-2019 Andreas Rönnquist 4 | * Copyright (C) 2019-2021 Darren Salt 5 | * 6 | * devilspie2 is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * devilspie2 is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with devilspie2. 18 | * If not, see . 19 | */ 20 | 21 | 22 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | #include "compat.h" 36 | #include "intl.h" 37 | #include "script.h" 38 | 39 | #if (GTK_MAJOR_VERSION >= 3) 40 | #define HAVE_GTK3 41 | #endif 42 | 43 | #include "script_functions.h" 44 | 45 | 46 | 47 | /** 48 | * 49 | */ 50 | gboolean devilspie2_debug = FALSE; 51 | gboolean devilspie2_emulate = FALSE; 52 | 53 | lua_State *global_lua_state = NULL; 54 | 55 | /** 56 | * 57 | */ 58 | lua_State * 59 | init_script() 60 | { 61 | lua_State *lua = luaL_newstate(); 62 | luaL_openlibs(lua); 63 | 64 | register_cfunctions(lua); 65 | 66 | return lua; 67 | } 68 | 69 | 70 | /** 71 | * 72 | */ 73 | #define DP2_REGISTER(lua, name) lua_register(lua, #name, c_##name) 74 | void 75 | register_cfunctions(lua_State *lua) 76 | { 77 | DP2_REGISTER(lua, use_utf8); 78 | 79 | DP2_REGISTER(lua, get_window_name); 80 | DP2_REGISTER(lua, get_window_has_name); 81 | 82 | DP2_REGISTER(lua, set_window_position); 83 | DP2_REGISTER(lua, set_window_position2); 84 | DP2_REGISTER(lua, set_window_size); 85 | DP2_REGISTER(lua, set_window_strut); 86 | 87 | DP2_REGISTER(lua, set_window_geometry); 88 | DP2_REGISTER(lua, set_window_geometry2); 89 | 90 | DP2_REGISTER(lua, get_application_name); 91 | 92 | DP2_REGISTER(lua, debug_print); 93 | 94 | DP2_REGISTER(lua, shade); 95 | DP2_REGISTER(lua, unshade); 96 | 97 | DP2_REGISTER(lua, maximize); 98 | lua_register(lua, "maximise", c_maximize); 99 | DP2_REGISTER(lua, maximize_horisontally); // deprecated 100 | DP2_REGISTER(lua, maximize_horizontally); 101 | lua_register(lua, "maximise_horizontally", c_maximize_horizontally); 102 | DP2_REGISTER(lua, maximize_vertically); 103 | lua_register(lua, "maximise_vertically", c_maximize_vertically); 104 | DP2_REGISTER(lua, unmaximize); 105 | lua_register(lua, "unmaximise", c_unmaximize); 106 | 107 | DP2_REGISTER(lua, minimize); 108 | lua_register(lua, "minimise", c_minimize); 109 | DP2_REGISTER(lua, unminimize); 110 | lua_register(lua, "unminimise", c_unminimize); 111 | 112 | DP2_REGISTER(lua, decorate_window); 113 | DP2_REGISTER(lua, undecorate_window); 114 | 115 | DP2_REGISTER(lua, set_window_workspace); 116 | DP2_REGISTER(lua, change_workspace); 117 | DP2_REGISTER(lua, get_workspace_count); 118 | 119 | DP2_REGISTER(lua, pin_window); 120 | DP2_REGISTER(lua, unpin_window); 121 | DP2_REGISTER(lua, stick_window); 122 | DP2_REGISTER(lua, unstick_window); 123 | 124 | DP2_REGISTER(lua, close_window); 125 | 126 | DP2_REGISTER(lua, set_adjust_for_decoration); 127 | 128 | DP2_REGISTER(lua, get_window_geometry); 129 | DP2_REGISTER(lua, get_window_client_geometry); 130 | DP2_REGISTER(lua, get_window_frame_extents); 131 | 132 | DP2_REGISTER(lua, set_skip_tasklist); 133 | DP2_REGISTER(lua, set_skip_pager); 134 | 135 | DP2_REGISTER(lua, get_window_is_maximized); 136 | lua_register(lua, "get_window_is_maximised", c_get_window_is_maximized); 137 | 138 | DP2_REGISTER(lua, get_window_is_maximized_vertically); 139 | lua_register(lua, "get_window_is_maximised_vertically", c_get_window_is_maximized_vertically); 140 | 141 | lua_register(lua, "get_window_is_maximized_horisontally", // deprecated 142 | c_get_window_is_maximized_horisontally); 143 | DP2_REGISTER(lua, get_window_is_maximized_horizontally); 144 | lua_register(lua, "get_window_is_maximised_horizontally", 145 | c_get_window_is_maximized_horizontally); 146 | DP2_REGISTER(lua, get_window_is_pinned); 147 | 148 | DP2_REGISTER(lua, get_window_is_decorated); 149 | 150 | DP2_REGISTER(lua, set_window_below); 151 | DP2_REGISTER(lua, set_window_above); 152 | DP2_REGISTER(lua, set_window_fullscreen); 153 | 154 | DP2_REGISTER(lua, make_always_on_top); 155 | DP2_REGISTER(lua, set_on_top); 156 | DP2_REGISTER(lua, set_on_bottom); 157 | 158 | DP2_REGISTER(lua, get_window_type); 159 | 160 | DP2_REGISTER(lua, get_window_property); 161 | DP2_REGISTER(lua, window_property_is_utf8); 162 | DP2_REGISTER(lua, get_window_property_full); 163 | DP2_REGISTER(lua, get_window_role); 164 | DP2_REGISTER(lua, get_window_xid); 165 | 166 | DP2_REGISTER(lua, get_window_class); 167 | 168 | DP2_REGISTER(lua, set_window_property); 169 | DP2_REGISTER(lua, delete_window_property); 170 | 171 | DP2_REGISTER(lua, set_viewport); 172 | 173 | DP2_REGISTER(lua, center); 174 | lua_register(lua, "centre", c_center); 175 | 176 | DP2_REGISTER(lua, set_window_opacity); 177 | lua_register(lua, "set_opacity", c_set_window_opacity); 178 | 179 | DP2_REGISTER(lua, set_window_type); 180 | 181 | DP2_REGISTER(lua, get_screen_geometry); 182 | 183 | DP2_REGISTER(lua, get_window_fullscreen); 184 | lua_register(lua, "get_fullscreen", c_get_window_fullscreen); 185 | 186 | DP2_REGISTER(lua, get_window_strut); 187 | 188 | // wnck_window_get_class_{instance,group}_name are only availible on wnck 3 and later 189 | DP2_REGISTER(lua, get_class_instance_name); 190 | DP2_REGISTER(lua, get_class_group_name); 191 | 192 | DP2_REGISTER(lua, focus); 193 | lua_register(lua, "focus_window", c_focus); 194 | 195 | DP2_REGISTER(lua, get_monitor_index); 196 | DP2_REGISTER(lua, get_monitor_geometry); 197 | 198 | DP2_REGISTER(lua, xy); 199 | DP2_REGISTER(lua, xywh); 200 | 201 | DP2_REGISTER(lua, on_geometry_changed); 202 | 203 | DP2_REGISTER(lua, get_process_name); 204 | 205 | DP2_REGISTER(lua, millisleep); 206 | } 207 | 208 | 209 | /** 210 | * 211 | */ 212 | static ATTR_MALLOC gchar *error_add_backtrace(lua_State *lua, const char *msg) 213 | { 214 | int r, level = 0, lines = 0; 215 | lua_Debug state; 216 | const gchar *header = _("Backtrace:\n"); 217 | gchar *backtrace = (gchar*)msg; 218 | 219 | while ((r = lua_getstack(lua, level, &state)) != 0) 220 | { 221 | lua_getinfo(lua, "Sln", &state); 222 | // only report script locations; 223 | // C code has name="[C]" & currentline=-1 224 | if (state.currentline > 0) { 225 | char *traced = state.name 226 | ? g_strdup_printf("%s\n%s %s:%d [%-6s] %s", backtrace, header, state.short_src, state.currentline, state.namewhat, state.name) 227 | : g_strdup_printf("%s\n%s %s:%d [%-6s]", backtrace, header, state.short_src, state.currentline, state.what); 228 | header = ""; 229 | if (backtrace != msg) 230 | g_free(backtrace); 231 | backtrace = traced; 232 | ++lines; 233 | } 234 | ++level; 235 | } 236 | 237 | if (lines > 1) 238 | return backtrace; 239 | 240 | if (backtrace != msg) 241 | g_free(backtrace); 242 | return g_strdup(msg); 243 | } 244 | 245 | static ATTR_MALLOC gchar *error_add_location(lua_State* lua, const char *msg) 246 | { 247 | lua_Debug state; 248 | 249 | int r = lua_getstack(lua, 0, &state); 250 | if (r == 0) 251 | return g_strdup(msg); 252 | lua_getinfo(lua, "Sln", &state); 253 | // the error handler will add a backtrace, so no need for function info 254 | return g_strdup_printf("%s:%d: %s", state.short_src, state.currentline, msg); 255 | } 256 | 257 | static gboolean timedout = FALSE; 258 | 259 | static void timeout_script(int sig) 260 | { 261 | timedout = TRUE; 262 | } 263 | 264 | static void check_timeout_script(lua_State *lua, lua_Debug *state) 265 | { 266 | // state is invalid? 267 | if (!timedout) 268 | return; 269 | // don't add backtrace etc. here; just the location 270 | gchar *msg = error_add_location(lua, _("script timed out")); 271 | lua_pushstring(lua, msg); 272 | g_free(msg); 273 | lua_error(lua); 274 | } 275 | 276 | static int script_error(lua_State *lua) 277 | { 278 | const char *msg = lua_tostring(lua, -1); 279 | lua_pop(lua, 1); 280 | // only the backtrace here, as the location's probably present already 281 | gchar *fullmsg = error_add_backtrace(lua, msg); 282 | lua_pushstring(lua, fullmsg); 283 | g_free(fullmsg); 284 | return 1; 285 | } 286 | 287 | 288 | /** 289 | * 290 | */ 291 | int 292 | run_script(lua_State *lua, const char *filename) 293 | { 294 | #define SCRIPT_TIMEOUT_SECONDS 5 295 | 296 | if (!lua) 297 | return -1; 298 | 299 | lua_pushcfunction(lua, script_error); 300 | int errpos = lua_gettop(lua); 301 | 302 | int result = luaL_loadfile(lua, filename); 303 | 304 | if (result) { 305 | // We got an error, print it 306 | printf(_("Error: %s\n"), lua_tostring(lua, -1)); 307 | lua_remove(lua, errpos); // unstack the error handler 308 | lua_pop(lua, 1); 309 | return -1; 310 | } 311 | 312 | // Okay, loaded the script; now run it 313 | 314 | struct sigaction newact, oldact; 315 | newact.sa_handler = timeout_script; 316 | sigemptyset(&newact.sa_mask); 317 | newact.sa_flags = 0; 318 | 319 | timedout = FALSE; 320 | lua_sethook(lua, check_timeout_script, LUA_MASKCOUNT, 1); 321 | sigaction(SIGALRM, &newact, &oldact); 322 | alarm(SCRIPT_TIMEOUT_SECONDS); 323 | 324 | int s = lua_pcall(lua, 0, LUA_MULTRET, errpos); 325 | 326 | alarm(0); 327 | sigaction(SIGALRM, &oldact, NULL); 328 | 329 | lua_remove(lua, errpos); // unstack the error handler 330 | 331 | if (s) { 332 | // no info to add here; just output the error 333 | printf(_("Error: %s\n"), lua_tostring(lua, -1)); 334 | lua_pop(lua, 1); // else we leak it 335 | } 336 | 337 | return 0; 338 | } 339 | 340 | 341 | /** 342 | * 343 | */ 344 | void 345 | done_script(lua_State *lua) 346 | { 347 | if (lua) 348 | lua_close(lua); 349 | 350 | //lua=NULL; 351 | } 352 | 353 | -------------------------------------------------------------------------------- /src/script.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2011-2019 Andreas Rönnquist 4 | * 5 | * devilspie2 is free software: you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * devilspie2 is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with devilspie2. 17 | * If not, see . 18 | */ 19 | #ifndef __HEADER_SCRIPT_ 20 | #define __HEADER_SCRIPT_ 21 | 22 | /** 23 | * 24 | */ 25 | 26 | 27 | /** 28 | * 29 | */ 30 | lua_State *init_script(); 31 | 32 | void register_cfunctions(lua_State *lua); 33 | int run_script(lua_State *lua, const char *filename); 34 | void done_script(lua_State *lua); 35 | 36 | 37 | extern gboolean devilspie2_debug; 38 | extern gboolean devilspie2_emulate; 39 | 40 | extern lua_State *global_lua_state; 41 | 42 | #endif /*__HEADER_SCRIPT_*/ 43 | -------------------------------------------------------------------------------- /src/script_functions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2011-2019 Andreas Rönnquist 4 | * 5 | * devilspie2 is free software: you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * devilspie2 is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with devilspie2. 17 | * If not, see . 18 | */ 19 | 20 | #ifndef __HEADER_SCRIPT_FUNCTIONS_ 21 | #define __HEADER_SCRIPT_FUNCTIONS_ 22 | 23 | /** 24 | * 25 | */ 26 | #include "lua.h" 27 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE 28 | #include "libwnck/libwnck.h" 29 | 30 | int c_use_utf8(lua_State *lua); 31 | 32 | int c_get_window_name(lua_State *lua); 33 | int c_get_window_has_name(lua_State *lua); 34 | 35 | int c_set_window_position(lua_State *lua); 36 | int c_set_window_position2(lua_State *lua); 37 | 38 | int c_set_window_geometry(lua_State *lua); 39 | int c_set_window_geometry2(lua_State *lua); 40 | 41 | int c_set_window_size(lua_State *lua); 42 | 43 | int c_set_window_strut(lua_State *lua); 44 | int c_get_window_strut(lua_State *lua); 45 | 46 | int c_get_application_name(lua_State *lua); 47 | 48 | int c_debug_print(lua_State *lua); 49 | 50 | int c_shade(lua_State *lua); 51 | int c_unshade(lua_State *lua); 52 | 53 | int c_minimize(lua_State *lua); 54 | int c_unminimize(lua_State *lua); 55 | 56 | int c_decorate_window(lua_State *lua); 57 | int c_undecorate_window(lua_State *lua); 58 | int c_get_window_is_decorated(lua_State *lua); 59 | 60 | int c_set_window_workspace(lua_State *lua); 61 | int c_change_workspace(lua_State *lua); 62 | int c_get_workspace_count(lua_State *lua); 63 | 64 | int c_unmaximize(lua_State *lua); 65 | int c_maximize(lua_State *lua); 66 | int c_maximize_vertically(lua_State *lua); 67 | int c_maximize_horisontally(lua_State *lua); // deprecated 68 | int c_maximize_horizontally(lua_State *lua); 69 | 70 | int c_pin_window(lua_State *lua); 71 | int c_unpin_window(lua_State *lua); 72 | int c_stick_window(lua_State *lua); 73 | int c_unstick_window(lua_State *lua); 74 | 75 | int c_close_window(lua_State *lua); 76 | 77 | void set_current_window(WnckWindow *window); 78 | WnckWindow *get_current_window(); 79 | 80 | int c_set_adjust_for_decoration(lua_State *lua); 81 | 82 | int c_get_window_geometry(lua_State *lua); 83 | int c_get_window_client_geometry(lua_State *lua); 84 | int c_get_window_frame_extents(lua_State *lua); 85 | 86 | int c_set_skip_tasklist(lua_State *lua); 87 | int c_set_skip_pager(lua_State *lua); 88 | 89 | int c_get_window_is_maximized(lua_State *lua); 90 | int c_get_window_is_maximized_vertically(lua_State *lua); 91 | int c_get_window_is_maximized_horisontally(lua_State *lua); // deprecated 92 | int c_get_window_is_maximized_horizontally(lua_State *lua); 93 | int c_get_window_is_pinned(lua_State *lua); 94 | 95 | int c_set_window_fullscreen(lua_State *lua); 96 | 97 | int c_set_window_above(lua_State *lua); 98 | int c_set_window_below(lua_State *lua); 99 | 100 | int c_make_always_on_top(lua_State *lua); 101 | int c_set_on_top(lua_State *lua); 102 | int c_set_on_bottom(lua_State *lua); 103 | 104 | int c_get_window_type(lua_State *lua); 105 | 106 | // these two require GTK 3 or later 107 | int c_get_class_instance_name(lua_State *lua); 108 | int c_get_class_group_name(lua_State *lua); 109 | 110 | int c_get_window_property(lua_State *lua); 111 | int c_window_property_is_utf8(lua_State *lua); 112 | int c_get_window_property_full(lua_State *lua); 113 | int c_get_window_role(lua_State *lua); 114 | 115 | int c_get_window_xid(lua_State *lua); 116 | 117 | int c_get_window_class(lua_State *lua); 118 | 119 | int c_set_window_property(lua_State *lua); 120 | int c_delete_window_property(lua_State *lua); 121 | 122 | int c_set_viewport(lua_State *lua); 123 | 124 | int c_center(lua_State *lua); 125 | 126 | int c_set_window_opacity(lua_State *lua); 127 | int c_set_window_type(lua_State *lua); 128 | 129 | 130 | int c_get_screen_geometry(lua_State *lua); 131 | 132 | int c_focus(lua_State *lua); 133 | 134 | int c_get_window_fullscreen(lua_State *lua); 135 | 136 | int c_get_monitor_index(lua_State *lua); 137 | int c_get_monitor_geometry(lua_State *lua); 138 | 139 | int c_xy(lua_State *lua); 140 | int c_xywh(lua_State *lua); 141 | 142 | int c_on_geometry_changed(lua_State *lua); 143 | 144 | int c_get_process_name(lua_State *lua); 145 | 146 | int c_millisleep(lua_State *lua); 147 | 148 | #endif /*__HEADER_SCRIPT_FUNCTIONS_*/ 149 | -------------------------------------------------------------------------------- /src/xutils.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2001 Havoc Pennington, 2011-2019 Andreas Rönnquist 4 | * Copyright (C) 2019-2021 Darren Salt 5 | * 6 | * devilspie2 is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as published 8 | * by the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * devilspie2 is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with devilspie2. 18 | * If not, see . 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | // FIXME: retrieve screen position via wnck 29 | #include 30 | 31 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE 32 | #include 33 | 34 | #include 35 | 36 | #include "intl.h" 37 | #include "xutils.h" 38 | 39 | 40 | #if (GTK_MAJOR_VERSION >= 3) 41 | #define HAVE_GTK3 42 | #endif 43 | 44 | 45 | static GHashTable *atom_hash = NULL; 46 | static GHashTable *reverse_atom_hash = NULL; 47 | 48 | 49 | /** 50 | * 51 | */ 52 | Atom my_wnck_atom_get(const char *atom_name) 53 | { 54 | Atom retval; 55 | 56 | g_return_val_if_fail (atom_name != NULL, None); 57 | 58 | if (!atom_hash) { 59 | atom_hash = g_hash_table_new (g_str_hash, g_str_equal); 60 | reverse_atom_hash = g_hash_table_new (NULL, NULL); 61 | } 62 | 63 | retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name)); 64 | if (!retval) { 65 | retval = XInternAtom (gdk_x11_get_default_xdisplay(), atom_name, FALSE); 66 | 67 | if (retval != None) { 68 | char *name_copy; 69 | 70 | name_copy = g_strdup (atom_name); 71 | 72 | g_hash_table_insert (atom_hash, 73 | name_copy, 74 | GUINT_TO_POINTER (retval)); 75 | g_hash_table_insert (reverse_atom_hash, 76 | GUINT_TO_POINTER (retval), 77 | name_copy); 78 | } 79 | } 80 | return retval; 81 | } 82 | 83 | 84 | /** 85 | * 86 | */ 87 | void devilspie2_change_state(Screen *screen, Window xwindow, 88 | gboolean add, 89 | Atom state1, 90 | Atom state2) 91 | { 92 | XEvent xev; 93 | 94 | #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ 95 | #define _NET_WM_STATE_ADD 1 /* add/set property */ 96 | #define _NET_WM_STATE_TOGGLE 2 /* toggle property */ 97 | 98 | xev.xclient.type = ClientMessage; 99 | xev.xclient.serial = 0; 100 | xev.xclient.send_event = True; 101 | xev.xclient.display = gdk_x11_get_default_xdisplay(); 102 | xev.xclient.window = xwindow; 103 | xev.xclient.message_type = my_wnck_atom_get ("_NET_WM_STATE"); 104 | xev.xclient.format = 32; 105 | xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; 106 | xev.xclient.data.l[1] = state1; 107 | xev.xclient.data.l[2] = state2; 108 | 109 | XSendEvent (gdk_x11_get_default_xdisplay(), 110 | RootWindowOfScreen (screen), 111 | False, 112 | SubstructureRedirectMask | SubstructureNotifyMask, 113 | &xev); 114 | } 115 | 116 | 117 | /** 118 | * 119 | */ 120 | void devilspie2_error_trap_push() 121 | { 122 | #if GTK_CHECK_VERSION(3, 0, 0) 123 | gdk_x11_display_error_trap_push(gdk_display_get_default()); 124 | #else 125 | gdk_error_trap_push(); 126 | #endif 127 | } 128 | 129 | 130 | /** 131 | * 132 | */ 133 | int devilspie2_error_trap_pop() 134 | { 135 | #if GTK_CHECK_VERSION(3, 0, 0) 136 | return gdk_x11_display_error_trap_pop(gdk_display_get_default()); 137 | #else 138 | XSync(gdk_x11_get_default_xdisplay(),False); 139 | return gdk_error_trap_pop(); 140 | #endif 141 | } 142 | 143 | 144 | /** 145 | * 146 | */ 147 | static void set_decorations(Window xid /*WnckWindow *window*/, gboolean decorate) 148 | { 149 | #define PROP_MOTIF_WM_HINTS_ELEMENTS 5 150 | #define MWM_HINTS_DECORATIONS (1L << 1) 151 | struct { 152 | unsigned long flags; 153 | unsigned long functions; 154 | unsigned long decorations; 155 | long inputMode; 156 | unsigned long status; 157 | } hints = {0,}; 158 | 159 | hints.flags = MWM_HINTS_DECORATIONS; 160 | hints.decorations = decorate ? 1 : 0; 161 | 162 | /* Set Motif hints, most window managers handle these */ 163 | XChangeProperty(gdk_x11_get_default_xdisplay(), xid /*wnck_window_get_xid (window)*/, 164 | my_wnck_atom_get ("_MOTIF_WM_HINTS"), 165 | my_wnck_atom_get ("_MOTIF_WM_HINTS"), 32, PropModeReplace, 166 | (unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS); 167 | 168 | 169 | //Window xid; 170 | XWindowAttributes attrs; 171 | 172 | //xid = wnck_window_get_xid (window); 173 | XGetWindowAttributes(gdk_x11_get_default_xdisplay(), xid, &attrs); 174 | 175 | /* Apart from OpenBox, which doesn't respect it changing after mapping. 176 | * Instead it has this workaround. 177 | */ 178 | devilspie2_change_state (attrs.screen, 179 | xid /*wnck_window_get_xid(window)*/, !decorate, 180 | my_wnck_atom_get ("_OB_WM_STATE_UNDECORATED"), 0); 181 | 182 | } 183 | 184 | 185 | /** 186 | * 187 | */ 188 | gboolean decorate_window(Window xid) 189 | { 190 | devilspie2_error_trap_push(); 191 | 192 | set_decorations(xid, TRUE); 193 | 194 | if (devilspie2_error_trap_pop()) { 195 | g_printerr("decorate_window %s\n", _("Failed!")); 196 | return FALSE; 197 | } 198 | 199 | return TRUE; 200 | } 201 | 202 | 203 | /** 204 | * 205 | */ 206 | gboolean undecorate_window(Window xid) 207 | { 208 | devilspie2_error_trap_push(); 209 | 210 | set_decorations(xid, FALSE); 211 | 212 | if (devilspie2_error_trap_pop()) { 213 | g_printerr("decorate_window %s\n", _("Failed!")); 214 | return FALSE; 215 | } 216 | 217 | return TRUE; 218 | } 219 | 220 | 221 | /** 222 | * 223 | */ 224 | gboolean get_decorated(Window xid /*WnckWindow *window*/) 225 | { 226 | Display *disp = gdk_x11_get_default_xdisplay(); 227 | Atom type_ret; 228 | Atom hints_atom = XInternAtom(disp, "_MOTIF_WM_HINTS", False); 229 | int format_ret; 230 | int err, result = 0; 231 | unsigned long nitems_ret, bytes_after_ret, *prop_ret; 232 | 233 | devilspie2_error_trap_push(); 234 | XGetWindowProperty(disp, xid, hints_atom, 0, 235 | PROP_MOTIF_WM_HINTS_ELEMENTS, 0, hints_atom, 236 | &type_ret, &format_ret, &nitems_ret, 237 | &bytes_after_ret, (unsigned char **)&prop_ret); 238 | 239 | err = devilspie2_error_trap_pop (); 240 | if (err != Success || result != Success) 241 | return FALSE; 242 | 243 | return type_ret != hints_atom || nitems_ret < 3 || prop_ret[2] != 0; 244 | } 245 | 246 | 247 | /** 248 | * 249 | */ 250 | Screen *devilspie2_window_get_xscreen(Window xid) 251 | { 252 | XWindowAttributes attrs; 253 | 254 | XGetWindowAttributes(gdk_x11_get_default_xdisplay(), xid, &attrs); 255 | 256 | return attrs.screen; 257 | } 258 | 259 | 260 | /** 261 | * 262 | */ 263 | char* my_wnck_get_string_property(Window xwindow, Atom atom, gboolean *utf8) 264 | { 265 | Atom type; 266 | int format; 267 | gulong nitems; 268 | gulong bytes_after; 269 | unsigned char *property; 270 | int err, result; 271 | char *retval; 272 | Atom XA_UTF8_STRING; 273 | gboolean is_utf8 = True; 274 | 275 | if (utf8) 276 | *utf8 = False; 277 | 278 | devilspie2_error_trap_push(); 279 | property = NULL; 280 | result = XGetWindowProperty (gdk_x11_get_default_xdisplay (), 281 | xwindow, atom, 282 | 0, G_MAXLONG, 283 | False, AnyPropertyType, &type, 284 | &format, &nitems, 285 | &bytes_after, &property); 286 | 287 | err = devilspie2_error_trap_pop (); 288 | if (err != Success || result != Success) 289 | return NULL; 290 | 291 | retval = NULL; 292 | XA_UTF8_STRING = XInternAtom(gdk_x11_get_default_xdisplay(), "UTF8_STRING", False); 293 | 294 | if (utf8) 295 | *utf8 = False; 296 | 297 | if (type == XA_STRING) { 298 | is_utf8 = False; 299 | retval = g_strdup ((char*)property); 300 | } else if (type == XA_UTF8_STRING) { 301 | retval = g_strdup ((char*)property); 302 | } else if (type == XA_ATOM && nitems > 0 && format == 32) { 303 | long *pp; 304 | 305 | pp = (long *)property; // we can assume (long *) since format == 32 306 | if (nitems == 1) { 307 | char* prop_name; 308 | prop_name = XGetAtomName (gdk_x11_get_default_xdisplay (), *pp); 309 | if (prop_name) { 310 | retval = g_strdup (prop_name); 311 | XFree (prop_name); 312 | } 313 | } else { 314 | gulong i; 315 | char** prop_names; 316 | 317 | prop_names = g_new (char *, nitems + 1); 318 | prop_names[nitems] = NULL; 319 | for (i=0; i < nitems; i++) { 320 | prop_names[i] = XGetAtomName (gdk_x11_get_default_xdisplay (), 321 | *pp++); 322 | } 323 | retval = g_strjoinv (", ", prop_names); 324 | for (i=0; i < nitems; i++) { 325 | if (prop_names[i]) XFree (prop_names[i]); 326 | } 327 | g_free (prop_names); 328 | } 329 | } else if (type == XA_CARDINAL && nitems == 1) { 330 | switch(format) { 331 | case 32: 332 | retval = g_strdup_printf("%lu", *(unsigned long*)property); 333 | break; 334 | case 16: 335 | retval = g_strdup_printf("%u", *(unsigned int*)property); 336 | break; 337 | case 8: 338 | retval = g_strdup_printf("%c", *(unsigned char*)property); 339 | break; 340 | } 341 | } else if (type == XA_WINDOW && nitems == 1) { 342 | /* unsinged long is the same format used for XID by libwnck: 343 | * https://git.gnome.org/browse/libwnck/tree/libwnck/window.c?h=3.14.0#n763 344 | */ 345 | retval = g_strdup_printf("%lu", (gulong) *(Window *)property); 346 | } 347 | 348 | XFree (property); 349 | if (utf8) 350 | *utf8 = is_utf8; 351 | return retval; 352 | } 353 | 354 | 355 | /** 356 | * 357 | */ 358 | void my_wnck_set_string_property(Window xwindow, Atom atom, const gchar *const string, gboolean utf8) 359 | { 360 | const unsigned char *const str = (const unsigned char *)string; 361 | Display *display = gdk_x11_get_default_xdisplay(); 362 | Atom type = utf8 ? XInternAtom(display, "UTF8_STRING", False) : XA_STRING; 363 | 364 | devilspie2_error_trap_push(); 365 | XChangeProperty (display, xwindow, atom, type, 8, PropModeReplace, str, strlen(string)); 366 | devilspie2_error_trap_pop (); 367 | } 368 | 369 | 370 | /** 371 | * 372 | */ 373 | void my_wnck_set_cardinal_property(Window xwindow, Atom atom, int32_t value) 374 | { 375 | devilspie2_error_trap_push(); 376 | XChangeProperty (gdk_x11_get_default_xdisplay (), 377 | xwindow, atom, XA_CARDINAL, 32, 378 | PropModeReplace, (unsigned char *)&value, 1); 379 | devilspie2_error_trap_pop (); 380 | } 381 | 382 | 383 | /** 384 | * 385 | */ 386 | void my_wnck_delete_property(Window xwindow, Atom atom) 387 | { 388 | devilspie2_error_trap_push(); 389 | XDeleteProperty (gdk_x11_get_default_xdisplay (), xwindow, atom); 390 | devilspie2_error_trap_pop (); 391 | } 392 | 393 | 394 | /** 395 | * 396 | */ 397 | gboolean 398 | my_wnck_get_cardinal_list (Window xwindow, Atom atom, 399 | gulong **cardinals, int *len) 400 | { 401 | Atom type; 402 | int format; 403 | gulong nitems; 404 | gulong bytes_after; 405 | gulong *nums; 406 | int err, result; 407 | 408 | *cardinals = NULL; 409 | *len = 0; 410 | 411 | devilspie2_error_trap_push(); 412 | type = None; 413 | result = XGetWindowProperty(gdk_x11_get_default_xdisplay (), 414 | xwindow, 415 | atom, 416 | 0, G_MAXLONG, 417 | False, XA_CARDINAL, &type, &format, &nitems, 418 | &bytes_after, (void*)&nums); 419 | 420 | err = devilspie2_error_trap_pop(); 421 | 422 | if ((err != Success) || (result != Success)) 423 | return FALSE; 424 | 425 | if (type != XA_CARDINAL) { 426 | XFree (nums); 427 | return FALSE; 428 | } 429 | 430 | *cardinals = g_new(gulong, nitems); 431 | memcpy(*cardinals, nums, sizeof (gulong) * nitems); 432 | *len = nitems; 433 | 434 | XFree(nums); 435 | 436 | return TRUE; 437 | } 438 | 439 | 440 | /** 441 | * Get viewport start coordinates to the x and y integers, 442 | * returns 0 on success and non-zero on error. 443 | */ 444 | int devilspie2_get_viewport_start(Window xid, int *x, int *y) 445 | { 446 | gulong *list; 447 | int len; 448 | 449 | int result = -1; 450 | 451 | my_wnck_get_cardinal_list(RootWindowOfScreen(devilspie2_window_get_xscreen(xid)), 452 | my_wnck_atom_get("_NET_DESKTOP_VIEWPORT"), 453 | &list, &len); 454 | 455 | if (len > 0) { 456 | *x = list[0]; 457 | *y = list[1]; 458 | 459 | result = 0; 460 | } 461 | 462 | g_free(list); 463 | 464 | return result; 465 | } 466 | 467 | 468 | /** 469 | * 470 | */ 471 | void my_window_set_window_type(Window xid, gchar *window_type) 472 | { 473 | Display *display = gdk_x11_get_default_xdisplay(); 474 | 475 | Atom atoms[10]; 476 | 477 | /* 478 | _NET_WM_WINDOW_TYPE_DESKTOP, ATOM 479 | _NET_WM_WINDOW_TYPE_DOCK, ATOM 480 | _NET_WM_WINDOW_TYPE_TOOLBAR, ATOM 481 | _NET_WM_WINDOW_TYPE_MENU, ATOM 482 | _NET_WM_WINDOW_TYPE_UTILITY, ATOM 483 | _NET_WM_WINDOW_TYPE_SPLASH, ATOM 484 | _NET_WM_WINDOW_TYPE_DIALOG, ATOM 485 | _NET_WM_WINDOW_TYPE_NORMAL, ATOM 486 | */ 487 | 488 | gchar *type = NULL; 489 | 490 | // Make it a recognized _NET_WM_TYPE 491 | 492 | if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_DESKTOP") == 0) { 493 | type = g_strdup("_NET_WM_WINDOW_TYPE_DESKTOP"); 494 | 495 | } else if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_DOCK") == 0) { 496 | type = g_strdup("_NET_WM_WINDOW_TYPE_DOCK"); 497 | 498 | } else if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_TOOLBAR") == 0) { 499 | type = g_strdup("_NET_WM_WINDOW_TYPE_TOOLBAR"); 500 | 501 | } else if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_MENU") == 0) { 502 | type = g_strdup("_NET_WM_WINDOW_TYPE_MENU"); 503 | 504 | } else if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_UTILITY") == 0) { 505 | type = g_strdup("_NET_WM_WINDOW_TYPE_UTILITY"); 506 | 507 | } else if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_SPLASH") == 0) { 508 | type = g_strdup("_NET_WM_WINDOW_TYPE_SPLASH"); 509 | 510 | } else if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_DIALOG") == 0) { 511 | type = g_strdup("_NET_WM_WINDOW_TYPE_DIALOG"); 512 | 513 | } else if (g_ascii_strcasecmp(window_type, "WINDOW_TYPE_NORMAL") == 0) { 514 | type = g_strdup("_NET_WM_WINDOW_TYPE_NORMAL"); 515 | 516 | } else { 517 | type = g_strdup(window_type); 518 | } 519 | 520 | atoms[0] = XInternAtom(display, type, False); 521 | 522 | XChangeProperty(gdk_x11_get_default_xdisplay(), xid, 523 | XInternAtom(display, "_NET_WM_WINDOW_TYPE", False), XA_ATOM, 32, 524 | PropModeReplace, (unsigned char *) &atoms, 1); 525 | 526 | g_free(type); 527 | } 528 | 529 | 530 | /** 531 | * 532 | */ 533 | void my_window_set_opacity(Window xid, double value) 534 | { 535 | Display *display = gdk_x11_get_default_xdisplay(); 536 | 537 | unsigned int opacity = (uint)(0xffffffff * value); 538 | Atom atom_net_wm_opacity = XInternAtom(display, "_NET_WM_WINDOW_OPACITY", False); 539 | 540 | 541 | XChangeProperty(gdk_x11_get_default_xdisplay(), xid, 542 | atom_net_wm_opacity, XA_CARDINAL, 32, 543 | PropModeReplace, (unsigned char *) &opacity, 1L); 544 | 545 | } 546 | 547 | 548 | /** 549 | * 550 | */ 551 | void adjust_for_decoration(WnckWindow *window, int *x, int *y, int *w, int *h) 552 | { 553 | GdkRectangle geom, geom_undec; 554 | 555 | wnck_window_get_geometry(window, &geom.x, &geom.y, &geom.width, &geom.height); 556 | wnck_window_get_client_window_geometry(window, &geom_undec.x, &geom_undec.y, &geom_undec.width, &geom_undec.height); 557 | 558 | if (x) *x -= geom_undec.x - geom.x; 559 | if (y) *y -= geom_undec.y - geom.y; 560 | if (w) *w -= geom_undec.width - geom.width; 561 | if (h) *h -= geom_undec.height - geom.height; 562 | } 563 | 564 | 565 | /** 566 | * 567 | */ 568 | void set_window_geometry(WnckWindow *window, int x, int y, int w, int h, gboolean adjusting_for_decoration) 569 | { 570 | if (window) { 571 | WnckScreen *screen = wnck_window_get_screen(window); 572 | int sw = wnck_screen_get_width(screen); 573 | int sh = wnck_screen_get_height(screen); 574 | 575 | int gravity = WNCK_WINDOW_GRAVITY_CURRENT; 576 | if (x >= 0 && y >= 0) 577 | gravity = WNCK_WINDOW_GRAVITY_NORTHWEST; 578 | if (x >= 0 && y < 0) 579 | gravity = WNCK_WINDOW_GRAVITY_SOUTHWEST; 580 | if (x < 0 && y >= 0) 581 | gravity = WNCK_WINDOW_GRAVITY_NORTHEAST; 582 | if (x < 0 && y < 0) 583 | gravity = WNCK_WINDOW_GRAVITY_SOUTHEAST; 584 | if (x < 0) 585 | x = sw + x; 586 | if (y < 0) 587 | y = sh + y; 588 | 589 | if (adjusting_for_decoration) 590 | adjust_for_decoration(window, &x, &y, &w, &h); 591 | 592 | wnck_window_set_geometry(window, 593 | gravity, 594 | WNCK_WINDOW_CHANGE_X + 595 | WNCK_WINDOW_CHANGE_Y + 596 | WNCK_WINDOW_CHANGE_WIDTH + 597 | WNCK_WINDOW_CHANGE_HEIGHT, 598 | x, y, w, h); 599 | } 600 | 601 | } 602 | 603 | 604 | /** 605 | * 606 | */ 607 | int get_monitor_count(void) 608 | { 609 | // FIXME: retrieve monitor count via wnck 610 | // For now, use Xinerama directly 611 | Display *dpy = gdk_x11_get_default_xdisplay(); 612 | 613 | if (!XineramaIsActive(dpy)) 614 | return 0; 615 | 616 | // Normally, we'd use the return value, but we only want the number of entries 617 | int monitor_count = 0; 618 | XineramaQueryScreens(dpy, &monitor_count); 619 | 620 | return monitor_count; 621 | } 622 | 623 | 624 | /** 625 | * 626 | */ 627 | int get_monitor_index_geometry(WnckWindow *window, const GdkRectangle *window_r_in, GdkRectangle *monitor_r) 628 | { 629 | // monitor_r is always filled in unless the return value is -1 630 | 631 | // FIXME: retrieve monitor info via wnck 632 | // For now, use Xinerama directly 633 | int id = -1; 634 | int monitor_count = 0; 635 | XineramaScreenInfo *monitor_list = NULL; 636 | Display *dpy = gdk_x11_get_default_xdisplay(); 637 | 638 | if (XineramaIsActive(dpy)) 639 | monitor_list = XineramaQueryScreens(dpy, &monitor_count); 640 | 641 | // bail out if no Xinermama or no monitors 642 | if (!monitor_list || !monitor_count) 643 | return -1; 644 | 645 | // find which monitor the window's centre is on 646 | GdkRectangle window_r; 647 | if (window) 648 | wnck_window_get_geometry(window, &window_r.x, &window_r.y, &window_r.width, &window_r.height); 649 | else 650 | window_r = *window_r_in; 651 | 652 | GdkPoint centre = { window_r.x + window_r.width / 2, window_r.y + window_r.height / 2 }; 653 | 654 | for (int i = 0; i < monitor_count; ++i) { 655 | if (centre.x >= monitor_list[i].x_org && 656 | centre.x < monitor_list[i].x_org + monitor_list[i].width && 657 | centre.y >= monitor_list[i].y_org && 658 | centre.y < monitor_list[i].y_org + monitor_list[i].height) { 659 | id = i; 660 | break; 661 | } 662 | } 663 | 664 | // if that fails, try intersection of rectangles 665 | // just use the first matching 666 | // FIXME?: should find whichever shows most of the window (if tied, closest to window centre) 667 | if (id < 0) { 668 | for (int i = 0; i < monitor_count; ++i) { 669 | GdkRectangle r = { 670 | monitor_list[i].x_org, monitor_list[i].y_org, 671 | monitor_list[i].x_org + monitor_list[i].width, 672 | monitor_list[i].y_org + monitor_list[i].height 673 | }; 674 | if (gdk_rectangle_intersect(&window_r, &r, NULL)) { 675 | id = i; 676 | break; 677 | } 678 | } 679 | } 680 | 681 | // and if that too fails, use the default 682 | if (id < 0) 683 | id = 0; // FIXME: primary monitor 684 | 685 | if (monitor_r) { 686 | monitor_r->x = monitor_list[id].x_org; 687 | monitor_r->y = monitor_list[id].y_org; 688 | monitor_r->width = monitor_list[id].width; 689 | monitor_r->height = monitor_list[id].height; 690 | } 691 | 692 | return id; 693 | } 694 | 695 | 696 | /** 697 | * 698 | */ 699 | int get_monitor_geometry(int index, GdkRectangle *monitor_r) 700 | { 701 | // if out of range, output is for monitor 0 (if present) else this: 702 | *monitor_r = (GdkRectangle){ 0, 0, 640, 480 }; 703 | 704 | // FIXME: retrieve monitor info via wnck 705 | // For now, use Xinerama directly 706 | int monitor_count = 0; 707 | XineramaScreenInfo *monitor_list = NULL; 708 | Display *dpy = gdk_x11_get_default_xdisplay(); 709 | 710 | if (XineramaIsActive(dpy)) 711 | monitor_list = XineramaQueryScreens(dpy, &monitor_count); 712 | 713 | // bail out if no Xinermama or no monitors 714 | if (!monitor_list || !monitor_count) 715 | return -1; // no xinerama! 716 | 717 | // FIXME: default to primary monitor 718 | if (index < 0 || index >= monitor_count) 719 | index = 0; 720 | 721 | monitor_r->x = monitor_list[index].x_org; 722 | monitor_r->y = monitor_list[index].y_org; 723 | monitor_r->width = monitor_list[index].width; 724 | monitor_r->height = monitor_list[index].height; 725 | 726 | return index; 727 | } 728 | 729 | 730 | /** 731 | * 732 | */ 733 | int get_window_workspace_geometry(WnckWindow *window, GdkRectangle *geom) 734 | { 735 | WnckScreen *screen = wnck_window_get_screen(window); 736 | WnckWorkspace *workspace = wnck_screen_get_active_workspace(screen); 737 | 738 | if (workspace == NULL) { 739 | workspace = wnck_screen_get_workspace(screen, 0); 740 | } 741 | 742 | if (workspace == NULL) { 743 | g_printerr(_("Could not get workspace")); 744 | return 1; 745 | } 746 | 747 | geom->x = 0; 748 | geom->y = 0; 749 | geom->width = wnck_workspace_get_width(workspace); 750 | geom->height = wnck_workspace_get_height(workspace); 751 | 752 | return 0; 753 | } 754 | 755 | 756 | /** 757 | * Wrapper for the above geometry-reading functions 758 | * Selects according to monitor number 759 | * Returns the monitor index, MONITOR_ALL or, on error, MONITOR_NONE 760 | */ 761 | int get_monitor_or_workspace_geometry(int monitor_no, WnckWindow *window, GdkRectangle *bounds) 762 | { 763 | int ret; 764 | 765 | switch (monitor_no) 766 | { 767 | case MONITOR_ALL: 768 | return get_window_workspace_geometry(window, bounds) ? MONITOR_NONE : MONITOR_ALL; 769 | 770 | case MONITOR_WINDOW: 771 | ret = get_monitor_index_geometry(window, NULL, bounds); 772 | return ret < 0 ? MONITOR_NONE : ret; 773 | 774 | default: 775 | if (monitor_no < 0 || monitor_no >= get_monitor_count()) 776 | return MONITOR_NONE; 777 | return get_monitor_geometry(monitor_no, bounds) < 0 ? MONITOR_NONE : monitor_no; 778 | } 779 | } 780 | -------------------------------------------------------------------------------- /src/xutils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of devilspie2 3 | * Copyright (C) 2001 Havoc Pennington, 2011-2019 Andreas Rönnquist 4 | * 5 | * devilspie2 is free software: you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * devilspie2 is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with devilspie2. 17 | * If not, see . 18 | */ 19 | 20 | #ifndef __HEADER_XUTILS_ 21 | #define __HEADER_XUTILS_ 22 | 23 | #include "compat.h" 24 | 25 | /* Special values for specifying which monitor. 26 | * These values are relied upon; changing them will require changing the code where used. 27 | * Scripts use these numbers plus 1. 28 | * Where these are used, values ≥ 0 (> 0 in scripts) correspond to actual monitors. 29 | */ 30 | #define MONITOR_NONE INT_MIN 31 | #define MONITOR_ALL -2 /* Monitor no. -1 (all monitors as one) */ 32 | #define MONITOR_WINDOW -1 /* Monitor no. 0 (current monitor) */ 33 | 34 | /** 35 | * 36 | */ 37 | Atom my_wnck_atom_get(const char *atom_name); 38 | 39 | void devilspie2_change_state(Screen *screen, 40 | Window xwindow, 41 | gboolean add, 42 | Atom state1, 43 | Atom state2); 44 | 45 | Screen* devilspie2_window_get_xscreen(Window xid); 46 | 47 | void devilspie2_error_trap_push(); 48 | int devilspie2_error_trap_pop(); 49 | 50 | gboolean decorate_window(Window xid); 51 | gboolean undecorate_window(Window xid); 52 | gboolean get_decorated(Window xid); 53 | 54 | char* my_wnck_get_string_property(Window xwindow, Atom atom, gboolean *utf8) ATTR_MALLOC; 55 | void my_wnck_set_string_property(Window xwindow, Atom atom, const gchar *const value, gboolean utf8); 56 | void my_wnck_set_cardinal_property (Window xwindow, Atom atom, int32_t value); 57 | void my_wnck_delete_property (Window xwindow, Atom atom); 58 | 59 | gboolean my_wnck_get_cardinal_list(Window xwindow, 60 | Atom atom, 61 | gulong **cardinals, 62 | int *len); 63 | 64 | int devilspie2_get_viewport_start(Window xwindow, int *x, int *y); 65 | 66 | void my_window_set_window_type(Window xid, gchar *window_type); 67 | void my_window_set_opacity(Window xid, double value); 68 | 69 | void adjust_for_decoration(WnckWindow *window, int *x, int *y, int *w, int *h); 70 | void set_window_geometry(WnckWindow *window, int x, int y, int w, int h, gboolean adjust_for_decoration); 71 | 72 | int get_monitor_count(void); 73 | int get_monitor_index_geometry(WnckWindow *window, const GdkRectangle *window_r, /*out*/ GdkRectangle *monitor_r); 74 | int get_monitor_geometry(int index, /*out*/ GdkRectangle *monitor_r); 75 | 76 | int get_window_workspace_geometry(WnckWindow *window, /*out*/ GdkRectangle *monitor_r); 77 | 78 | /* 79 | * Wrapper for the above geometry-reading functions 80 | * Selects according to monitor number (MONITOR_ALL, MONITOR_WINDOW or a monitor index no.) 81 | * Returns the monitor index, MONITOR_ALL or, on error, MONITOR_NONE 82 | */ 83 | int get_monitor_or_workspace_geometry(int monitor_no, WnckWindow *window, /*out*/ GdkRectangle *monitor_or_workspace_r); 84 | 85 | #endif /*__HEADER_XUTILS_*/ 86 | --------------------------------------------------------------------------------