From: Robert Manea Date: Thu, 30 Apr 2009 09:02:45 +0000 (+0200) Subject: Initial commit X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=28d0094dc79bd66c3710be0a6bb8abcdf81002fd;p=uzbl-mobile Initial commit --- 28d0094dc79bd66c3710be0a6bb8abcdf81002fd diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..b57d253 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,14 @@ + +Developers: + Dieter Plaetinck (Dieter@be) + Dusan Popovic (dusanx) + Michael Walker (Barrucadu) + +Contributors: + Zane Ashby (HashBox) - Rewrote FIFO interface. Fixed various bugs. + (sentientswitch) - Cleaned up code. Added some commands. + +Originaly based on http://trac.webkit.org/browser/trunk/WebKitTools/GtkLauncher/main.c +Which is copyrighted: +2006, 2007 Apple Inc +2007 Alp Toker diff --git a/CHECKLIST b/CHECKLIST new file mode 100644 index 0000000..e88df08 --- /dev/null +++ b/CHECKLIST @@ -0,0 +1,28 @@ +This file contains all things that are/should be working. +When you have been working on something, use this list to verify that you did not cause any regressions (things that worked before, but got broken). +Also, when you finish a new feature, add it to this list so that everyone knows about it, can play with it, and can test it. + +Also testers and interested people can use this list to see what uzbl is about, and report problems if they find items listed here that do not work. + +* commandline switches --uri "http://.." and --config should behave as expected +* --help and -? should show help +* config loading: loading of settings, bindings and all behavior settings (including handlers) from config file +* fifo: type this in your shell after starting uzbl: + echo 'uri http://www...' > ' + where is printed on stdout during program startup. Also "back" , "forward", "refresh" (basically all actions defined in `static Command commands` should behave as expected) + -> temporarily changed to socket io with uzblctrl. see examples in scripts +* history logging: the script as defined in sample config should write history entries (date,time, url) into the file defined in the script (by default ./extra/history.sh and /tmp/uzbl.history) +* invocations of external commands: you'll see it on stdout everytime uzbl calls an external script/program. the invocations should work and none of the arguments passed should be null/garbage/.. . + all should be valid strings and contain things like the pid, fifo file, config file,.. (see README for details). +* XDG_CONFIG_HOME and XDG_CONFIG_DIRS (+ default values) fully supported and working (looks for a config file called 'uzbl/config'). +* --uri can be specified without http:// -- if missing will be prepended. +* Downloading of files with handler script +* Open in new window partially finished: target _new works, from popup meny does not work yet +* Home command working (home_page variable in config) +* Page Up / Page Down / Up / Down / Left / Right for page navigation work in command mode. +* Open in new window completely finished with --config forwarding between instances +* internal keybinds to change things work (as loaded by config) +* vimlike command and insert modes behave as expected +* always_insert_mode and modkey work too +* status bar can be toggled on and off, if off, some info (mode) will be put in title bar. position of statusbar (top/bottom) also works + diff --git a/INSTALLING b/INSTALLING new file mode 100644 index 0000000..0d10d24 --- /dev/null +++ b/INSTALLING @@ -0,0 +1,23 @@ +* Arch Linux: + pkgbuild @ http://aur.archlinux.org/packages.php?ID=25972 + +* From source: + +$ git clone git://github.com/Dieterbe/uzbl.git +[ $ git checkout master/experimental ] # master == fairly stable. experimental is more bleeding edge +$ cd uzbl +$ make +$ sudo make install + +Dependencies: +libwebkit 1.1.4 or higher +gtk 2 something something +pkgconfig (for Make/gcc) + +Optional: +dmenu, zenity, bash for the sample scripts + +You will have the program in /usr/bin and various sample scripts, a sample config, sample bookmarks file and some documentation in /usr/share/uzbl. You +will probably want to change the scripts to behave more like you want, so copy the scripts to your home dir. If you save your config as +$XDG_CONFIG_HOME/uzbl/config (this expands to ~/.config/uzbl/config on most systems) it will be recognized automatically. You can also pass the path to +the config file with the --config parameter. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fa68594 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -Wall -W +LDFLAGS=$(shell pkg-config --libs gtk+-2.0 webkit-1.0) +all: uzbl uzblctrl + +test: + ./uzbl --uri http://www.uzbl.org + +test-config: + ./uzbl --uri http://www.uzbl.org --config examples/configs/sampleconfig-dev + +test-config-real: + ./uzbl --uri http://www.uzbl.org --config /usr/share/uzbl/examples/configs/sampleconfig + +clean: + rm -f uzbl + rm -f uzblctrl + +install: + install -d $(DESTDIR)/usr/bin + install -d $(DESTDIR)/usr/share/uzbl/docs + install -d $(DESTDIR)/usr/share/uzbl/examples + install -D -m755 uzbl $(DESTDIR)/usr/bin/uzbl + install -D -m755 uzblctrl $(DESTDIR)/usr/bin/uzblctrl + cp -ax examples $(DESTDIR)/usr/share/uzbl/ + install -D -m644 CHECKLIST $(DESTDIR)/usr/share/uzbl/docs + install -D -m644 README $(DESTDIR)/usr/share/uzbl/docs diff --git a/README b/README new file mode 100644 index 0000000..31f307a --- /dev/null +++ b/README @@ -0,0 +1,124 @@ +THIS PROJECT IS NOT FOR: +- people want a browser that does everything +- people who want a browser with things like a built-in bookmark manager, address bar, forward/back buttons, ... + + + +TO NEW PEOPLE: + - please read the README in /usr/share/uzbl/docs + - invoke uzbl --help + - to get you started: uzbl --uri 'http://www.archlinux.org' --config /usr/share/uzbl/examples/configs/sampleconfig + - study the sample config, have a look at all the bindings, and note how you can call the scripts to load new url from history and the bookmarks file + - inserting new bookmarks is not working yet. it will be soon. + - note that there is no url bar. all url editing is supposed to happen _outside_ of uzbl. + for now, you can use the load_from_* dmenu based scripts to pick a url or type a new one (we should have a dmenu-like that functions as a better editor) or write commands into the fifo (see /usr/share/uzbl/docs/CHECKLIST) + + +CURRENT STATE: + alpha / prototype + + +- Uzbl. + In my opinion, any program can only be really useful if it complies to the unix philosophy. + Web browsers are frequent violators of this principle. Time to change that! + +Right now uzbl is in a very early state but here are some ideas I would like to (not) implement + +- each instance of uzbl renders 1 page (eg it's a small wrapper around webkit), no tabbing, tab previews, or speed dial things. we have window managers for that. + -> well actually, there is lots of dicussion about this, i'll probably implement a basic form of tabbing. +- simple ini config file ("profile") for keyboard, network,.. settings +- implement some basic keyboard shortcuts for going up, down, refresh etc. preferably vim-like command style. +- listen to signals and do useful stuff when triggered. +- open up a socket file/fifo/.. so we can easily control each instance by writing things like 'uri ' to /tmp/uzbl-windowid +- MAYBE (if needed): 1 control application called uzblctrl or something. use this to modify the behavior of a uzbl instance (change url, refresh). use xdotool to get the window with focus. eg uzblctrl -win -url . + use xbindkeys to bind keys to call uzblctrl. +- no bookmark management builtin. make your own solution. for pulling a bookmark a plaintxt-based program using dmenu would work great here. combine with uzbltcrl and xbindkeys. + uzblctrl should support an option to query the current page so you can script something to add to your bookmarks. use zenity or something to add tags. +- history: log 'Y-m-d H:M:S ' entries to a plaintext file. you can then use dmenu or whatever to select an entry and pipe the output to uzbl's fifo. +- no ad blocking built in (I think). + alternatives: + -> /etc/hosts (not very good cause you need root and it affects the whole system)-> uzblctrl would need to support an option to list all images on a page, so you can easily pick the links to ads to add them to your /etc/hosts. (dmenu can again be great here to automate this) + -> privoxy looks cool and perfectly demonstrates the unix philosphy. +- no download manager. allow user to pick wget/curl/a custom script/... +- no build in command interpreters like ubiquity. uzbl should be accessible and you should use a shell or similar. +- no "clear cookies/cache/..." menu items. rm ~/$XDG_{DATA,CACHE}_DIR/uzbl/{cache,cookies}/* +- vimperator/konqueror-like hyperlink following. +- password management. maybe an encrypted store that unlocks with an ssh key? +- use the XDG basedir spec for separation of config, data and cache. and state will be a subdir in the config dir (not part of the spec yet) too. + +WIDGET ROADMAP: +* statusbar? (the bar you see in pretty much every gtk program at the bottom. eg firefox) + consumes too much space (if always visible) for the little it is used. (+ you can put only 1 message in it at a time!) + -> option 1: no statusbar at all. when hovering over a link (or pressing key to preview the url without changing page) -> show url in tooltip on page. + -> option 2: toggle visibility of statusbar on/off when hovering over a link. since it's at the bottom I don't think it will disturb too much. +* viewing progress/state of pageload? most programs use statusbar for this. + -> option 1: titlebar can show a percentage when it's loading a new page. + -> option 2: toggle a statusbar everytime we start loading a new page. +* uri bar -> yes, even though we can write stuff to the fifo, it can still be convenient to change the url manually and stuff, so a widget in uzbl itself is good. +* tabs -> yes. you don't have to use them, but you can. +* back/forward/.. buttons? -> no: use keyboard shortcuts. +* searching in a page? not sure.. maybe we can abuse the statusbar for that too. + eg toggle it on when the user wants to search for something and then do searching in some vim-like fashion. + we don't need a gtk text entry widget, just a feedback display of what the current command is. +* scrollbar? no: use keyboard shortcuts. we should however have some info about the page length and where we are. + -> option 1: put a percentage in the window title + -> option 2: everytime you hit a key to change position, temporarily make a statusbar visible and put the percentage in the statusbar. + what will we do with pages who are too wide? horizontal scrolling? +all of the above goes in 1 bar at the top of the program. there should be a key to toggle visibility of it and one to toggle visibilety + focus on the entrybar at once. + +input welcome! + + +HISTORY FILE SIZE/PERFORMANCE +each new pageload -> fopen(history_file, "a"), fwrite one line, fclose. +I use utf8, so unless you use characters that are "special" (chinese etc) +each character takes 1 byte. +So, assume each entry is about 80 chars, you visit 100 pages per day (?), and you wonder when your history file will be 50MB big: +(50 * 1000 * 1000 ) / ( 80 * 100 ) = 6250 days or 17 years. +There is code to run a benchmark in the 'extra' dir. For results & interpretation, see http://dieter.plaetinck.be/poor_mans_dmenu_benchmark + +CONTROL: +- FIFO opened in /tmp/uzbl_pid +- See config file for commands +- Press ESC/i to toggle command/insert mode + +NOTES: +- My c skills are very rusty, it will take me a while to get back up to speed +- For more thoughts & ideas see http://bbs.archlinux.org/viewtopic.php?id=67463 + +REPO's: +- http://github.com/Dieterbe/uzbl + master -> uzbl stable branch + experimental -> bleeding edge stuff that may break. after QA codes gets merged into master +- various contributors also have their clones on github (http://github.com/dusanx, http://github.com/Barrucadu/uzbl, ...). + They may be developing specific features, which get merged into Dieters experimental branch + + +EXTERNAL SCRIPTS +You can use external scripts with uzbl the following ways: +1) let uzbl call them. these scripts are called handlers in the uzbl config. used for handling logging history, handling a new download,.. +2) call them yourself from inside uzbl. you can bind keys for this. examples: add new bookmark, load new url,.. +3) if you want to call scripts that have no option, you can trigger them with something like xbindkeys. example: ? (we try to keep all possibilities inside option 1/2) + +Scripts that are called by uzbl are passed the following arguments: +$1 uzbl-config-file +$2 uzbl-pid +$3 uzbl-x-window-id +$4 uzbl_fifo-filename +$5 uzbl_socket-filename +.. [ script specific ] (optional) + +The script specific arguments are this: +* history: + $6 page url + $7 page title + $8 date of visit (Y-m-d H:i:s localtime) +* add bookmark: + $6 page url + $7 page title +* download: + $6 url + +KNOWN BUGS +- Segfaults when using zoom commands (happens when max zoom already reached?). +- Something in the FIFO code causes CPU usage to jump. diff --git a/TODO b/TODO new file mode 100644 index 0000000..6e74e96 --- /dev/null +++ b/TODO @@ -0,0 +1,39 @@ +ASAP +* implement all the ideas from README +* get a logo +* improve site +* when launching new instance, don't just try 'uzbl' and then './uzbl', rather launch a new uzbl in the same way the current uzbl instance was started. (same command, same arguments, except --uri) +* where to put proxy config? webkit support? +* implement XDG basedir spec (config is done, but not cache/data, which I presume we'll need at some point) +* check configured commands if they end on .sh so users don't need to prepend /bin/ +* implement a more advanced dmenu alike that behaves like FF's awesomebar and where you can search in url + window title +* recognize -h with GOption? +* implement a vimperator-like link following scheme. but let user pick his favorite characters to construct the "link identifiers" with. +* add a keybind to hand the current url to an external scrips, so you can edit it and/or store it in the primary and secondary clipboards +* use http://library.gnome.org/devel/glib/stable/glib-Hash-Tables.html#g-hash-table-insert for tracking bindings and wherever we use structs and ugly loops +* fifo -> socket. so you can do question-response. socket is slightly more complicated so we'll need to create a uzblctrl (half done - commands can't yet send data back) +* select/fork based instead of the pthread stuff -> drops dependency, more lightweight. +* on website, see if we can
the documentation inside the uzbl project itself, so we need to maintain the stuff on only 1 place +* see if we can use the github bugtracker (anonymous posting allowed?) +* allow user to change bindings for navigation (up,down,left,right, page up, page down etc)and use vim-like defaults +* put on uzbl.org that you can use http://github.com/Dieterbe/uzbl/issues after registering +* make default size configurable, and optional +* on uzbl.org commits overview: add date+time and repository +* how to handle different content types? (text-plain, image/png, application/pdf,... maybe a map of content-type to uzbl/command + xdg already has a spec for this i think + different "opening" modes (open as configured vs ask before opening) + integration with download and new window thingies? +* see if/how we can remove /bin/bash from scripts +* unify internal and external bindings. +* unify command triggering, whether they came in through fifo or keybind +* add to bottom /* vi: set et ts=4: */ +* ideal uri editor: awesome mode like FF, some keyb shortcuts (erase search string, go to end/begin of string,..), history (if you patch dmenu to be in vertical mode and you order correctly, that's it), support copy paste +* get rid of the home page concept. allow user to make keybinds to go to one or more "homepages". a home page is nothing special. +* blinking cursor when not in insert mode is confusing. i suggest dimming it's color if possible +* open in new window -> uzbl: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0. + + +SOMEDAY: +check if we can make the settings loading less hard coded. eg( keep a list of all settings, and for each one, try to load it) +figure out caching with webkit and in general how we can speed up everything +figure out how webkit intercepts key input diff --git a/examples/bookmarks b/examples/bookmarks new file mode 100644 index 0000000..13fcd48 --- /dev/null +++ b/examples/bookmarks @@ -0,0 +1,4 @@ +http://www.archlinux.org linux arch +http://www.uzbl.org uzbl browser +http://dieter.plaetinck.be uzbl +http://www.icanhascheezburger.com lolcats fun diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig new file mode 100644 index 0000000..9796859 --- /dev/null +++ b/examples/configs/sampleconfig @@ -0,0 +1,44 @@ + +# example uzbl config. in a real config, we should obey the xdg spec + +# all keys in the behavior group are optional. if not set, the corresponding behavior is disabed. +# bindings_internal denote keys to trigger actions internally in uzbl +# bindings_external denote keys to trigger scripts outside uzbl + +# keyboard behavior is vimstyle by default (all actions -> 1 key). set +# always_insert_mode to always be in insert mode and disable going out of it. +# if you do this, make sure you've set a modkey so you can reach the actions +# from insert mode by combining them with the modkey + +[behavior] +history_handler = /bin/bash /usr/share/uzbl/examples/scripts/history.sh +download_handler = /bin/bash /usr/share/uzbl/examples/scripts/download.sh +fifo_dir = /tmp +socket_dir = /tmp +always_insert_mode = 0 +modkey = Mod1 +show_status = 1 +status_top = 0 +home_page = http://www.uzbl.org + +[bindings_internal] +back = b +forward = m +stop = s +refresh = r +reload = R +home = h +follow_link_here = f +follow_link_new_tab = F +follow_link_new_window = w +zoom_in = + +zoom_out = - +toggle_status = t +exit = k + +[bindings_external] +/bin/bash /usr/share/uzbl/examples/scripts/insert_bookmark.sh = B +/bin/bash /usr/share/uzbl/examples/scripts/load_url_from_history.sh = u +/bin/bash /usr/share/uzbl/examples/scripts/load_url_from_bookmarks.sh = U + +[network] diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev new file mode 100644 index 0000000..d742147 --- /dev/null +++ b/examples/configs/sampleconfig-dev @@ -0,0 +1,44 @@ + +# example uzbl config. in a real config, we should obey the xdg spec + +# all keys in the behavior group are optional. if not set, the corresponding behavior is disabed. +# bindings_internal denote keys to trigger actions internally in uzbl +# bindings_external denote keys to trigger scripts outside uzbl + +# keyboard behavior is vimstyle by default (all actions -> 1 key). set +# always_insert_mode to always be in insert mode and disable going out of it. +# if you do this, make sure you've set a modkey so you can reach the actions +# from insert mode by combining them with the modkey + +[behavior] +history_handler = /bin/bash ./examples/scripts/history.sh +download_handler = /bin/bash ./examples/scripts/download.sh +fifo_dir = /tmp +socket_dir = /tmp +always_insert_mode = 0 +modkey = Mod1 +show_status = 1 +status_top = 0 +home_page = http://www.uzbl.org + +[bindings_internal] +back = b +forward = m +stop = s +refresh = r +reload = R +home = h +follow_link_here = f +follow_link_new_tab = F +follow_link_new_window = w +zoom_in = + +zoom_out = - +toggle_status = t +exit = k + +[bindings_external] +/bin/bash ./examples/scripts/insert_bookmark.sh = B +/bin/bash ./examples/scripts/load_url_from_history.sh = u +/bin/bash ./examples/scripts/load_url_from_bookmarks.sh = U + +[network] diff --git a/examples/scripts/download.sh b/examples/scripts/download.sh new file mode 100755 index 0000000..41c408e --- /dev/null +++ b/examples/scripts/download.sh @@ -0,0 +1,2 @@ +#!/bin/bash +wget $6 diff --git a/examples/scripts/history.sh b/examples/scripts/history.sh new file mode 100755 index 0000000..b6671fe --- /dev/null +++ b/examples/scripts/history.sh @@ -0,0 +1,4 @@ +#!/bin/bash +#TODO: strip 'http://' part +# you probably really want this in your $XDG_DATA_HOME (eg $HOME/.local/share/uzbl/history) +echo "$8 $6" >> /tmp/uzbl.history diff --git a/examples/scripts/insert_bookmark.sh b/examples/scripts/insert_bookmark.sh new file mode 100755 index 0000000..be17c05 --- /dev/null +++ b/examples/scripts/insert_bookmark.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks) + +if [ -f /usr/share/uzbl/examples/bookmarks ] +then + file=/usr/share/uzbl/examples/bookmarks # you will probably get permission denied errors here. pick a file in your ~ +else + file=./examples/bookmarks #useful when developing +fi + +which zenity &>/dev/null || exit 2 + +entry=`zenity --entry --text="Add bookmark. add tags at the end, separated by commas" --entry-text="$5"` +url=`awk '{print $1}' <<< $entry` +# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags +echo "$entry" >> $file diff --git a/examples/scripts/load_url_from_bookmarks.sh b/examples/scripts/load_url_from_bookmarks.sh new file mode 100755 index 0000000..2a893bf --- /dev/null +++ b/examples/scripts/load_url_from_bookmarks.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks) +if [ -f /usr/share/uzbl/examples/bookmarks ] +then + file=/usr/share/uzbl/examples/bookmarks +else + file=./examples/bookmarks #useful when developing +fi + +goto=`awk '{print $1}' $file | dmenu -i` #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. +#[ -n "$goto" ] && echo "uri $goto" > $4 +[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" diff --git a/examples/scripts/load_url_from_history.sh b/examples/scripts/load_url_from_history.sh new file mode 100755 index 0000000..81a220a --- /dev/null +++ b/examples/scripts/load_url_from_history.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# you probably really want this in your $XDG_DATA_HOME (eg $HOME/.local/share/uzbl/history) +history_file=/tmp/uzbl.history + +goto=`awk '{print $3}' $history_file | sort | uniq | dmenu -i` +#[ -n "$goto" ] && echo "uri $goto" > $4 +[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" diff --git a/misc/dmenu-performancetest-bench.sh b/misc/dmenu-performancetest-bench.sh new file mode 100755 index 0000000..c06df46 --- /dev/null +++ b/misc/dmenu-performancetest-bench.sh @@ -0,0 +1,17 @@ +#!/bin/bash +echo "Run this test more then once. the first read on the file may be uncached. after that, the file is in Linux' block cache" + +echo "Plain awk '{print \$3}':" +time awk '{print $3}' dummy_history_file >/dev/null + +echo "awk + sort" +time awk '{print $3}' dummy_history_file | sort >/dev/null +echo "awk + sort + uniq" +time awk '{print $3}' dummy_history_file | sort | uniq >/dev/null + +echo "Plain dmenu:" +dmenu < dummy_history_file +echo "awked into dmenu:" +awk '{print $3}' dummy_history_file | dmenu +echo "awk + sort + uniq into dmenu:" +awk '{print $3}' dummy_history_file | sort | uniq | dmenu diff --git a/misc/dmenu-performancetest-generate-dummy-history-file.sh b/misc/dmenu-performancetest-generate-dummy-history-file.sh new file mode 100755 index 0000000..17566bd --- /dev/null +++ b/misc/dmenu-performancetest-generate-dummy-history-file.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "Creating dummy file of 50MB in size (625000 entries of 80chars)" +echo "Note: this takes about an hour and a half" +entries_per_iteration=1000 +for i in `seq 1 625` +do + echo "Iteration $i of 625 ( $entries_per_iteration each )" + for j in `seq 1 $entries_per_iteration` + do + echo "`date +'%Y-%m-%d %H:%M:%S'` `date +%s`abcdefhijklmno`date +%s | md5sum`" >> ./dummy_history_file + done +done diff --git a/uzbl.c b/uzbl.c new file mode 100644 index 0000000..1216542 --- /dev/null +++ b/uzbl.c @@ -0,0 +1,812 @@ +// Original code taken from the example webkit-gtk+ application. see notice below. +// Modified code is licensed under the GPL 3. See LICENSE file. + + +/* + * Copyright (C) 2006, 2007 Apple Inc. + * Copyright (C) 2007 Alp Toker + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#define LENGTH(x) (sizeof x / sizeof x[0]) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* housekeeping / internal variables */ +static GtkWidget* main_window; +static GtkWidget* mainbar; +static GtkWidget* mainbar_label; +static WebKitWebView* web_view; +static gchar* main_title; +static gchar selected_url[500] = "\0"; +static gint load_progress; +static Window xwin = 0; +static char fifo_path[64]; +static char socket_path[108]; + +/* state variables (initial values coming from command line arguments but may be changed later) */ +static gchar* uri = NULL; +static gchar* config_file = NULL; +static gchar config_file_path[500]; +static gboolean verbose = FALSE; + +/* settings from config: group behaviour */ +static gchar* history_handler = NULL; +static gchar* fifo_dir = NULL; +static gchar* socket_dir = NULL; +static gchar* download_handler = NULL; +static gboolean always_insert_mode = FALSE; +static gboolean show_status = FALSE; +static gboolean insert_mode = FALSE; +static gboolean status_top = FALSE; +static gchar* modkey = NULL; +static guint modmask = 0; +static gchar* home_page = NULL; + +/* settings from config: group bindings_internal */ +static GHashTable *internal_bindings; + +/* settings from config: group bindings_external */ +static GHashTable *external_bindings; + +/* command list */ +static GHashTable *commands; + +/* commandline arguments (set initial values for the state variables) */ +static GOptionEntry entries[] = +{ + { "uri", 'u', 0, G_OPTION_ARG_STRING, &uri, "Uri to load", NULL }, + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL }, + { "config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Config file", NULL }, + { NULL, 0, 0, 0, NULL, NULL, NULL } +}; + +/* for internal list of commands */ +typedef struct +{ + gpointer command; + void (*func_1_param)(WebKitWebView*); + void (*func_2_params)(WebKitWebView*, const gchar *); +} Command; + +/* XDG stuff */ +char *XDG_CONFIG_HOME_default[256]; +char *XDG_CONFIG_DIRS_default = "/etc/xdg"; + +static void +update_title (GtkWindow* window); + +static void +load_uri ( WebKitWebView * web_view, const gchar * uri); + +static void +new_window_load_uri (const gchar * uri); + +static void +go_home ( WebKitWebView * web_view); + +static void +close_uzbl ( WebKitWebView * web_view); + +static gboolean +run_command(const char *command, const char *args); + +/* --- UTILITY FUNCTIONS --- */ +void +eprint(const char *errstr, ...) { + va_list ap; + vfprintf(stderr, errstr, ap); + va_end(ap); + exit(EXIT_FAILURE); +} + +char * +estrdup(const char *str) { + void *res = strdup(str); + if(!res) + eprint("fatal: could not allocate %u bytes\n", strlen(str)); + return res; +} + +/* --- CALLBACKS --- */ + +static gboolean +new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data) { + (void) web_view; + (void) frame; + (void) navigation_action; + (void) policy_decision; + (void) user_data; + const gchar* uri = webkit_network_request_get_uri (request); + printf("New window requested -> %s \n", uri); + new_window_load_uri(uri); + return (FALSE); +} + +WebKitWebView* +create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data) { + (void) web_view; + (void) frame; + (void) user_data; + if (selected_url[0]!=0) { + printf("\nNew web view -> %s\n",selected_url); + new_window_load_uri(selected_url); + } else { + printf("New web view -> %s\n","Nothing to open, exiting"); + } + return (NULL); +} + +static gboolean +download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) { + (void) web_view; + (void) user_data; + if (download_handler) { + const gchar* uri = webkit_download_get_uri ((WebKitDownload*)download); + printf("Download -> %s\n",uri); + run_command(download_handler, uri); + } + return (FALSE); +} + +static void +go_back_cb (WebKitWebView* page) { + (void) page; + webkit_web_view_go_back (web_view); +} + +static void +go_forward_cb (WebKitWebView* page) { + (void) page; + webkit_web_view_go_forward (web_view); +} + +static void +toggle_status_cb (WebKitWebView* page) { + (void) page; + if (show_status) { + gtk_widget_hide(mainbar); + } else { + gtk_widget_show(mainbar); + } + show_status = !show_status; + update_title (GTK_WINDOW (main_window)); +} + +static void +link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data) { + (void) page; + (void) title; + (void) data; + //ADD HOVER URL TO WINDOW TITLE + selected_url[0] = '\0'; + if (link) { + strcpy (selected_url, link); + } + update_title (GTK_WINDOW (main_window)); +} + +static void +title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data) { + (void) web_view; + (void) web_frame; + (void) data; + if (main_title) + g_free (main_title); + main_title = g_strdup (title); + update_title (GTK_WINDOW (main_window)); +} + +static void +progress_change_cb (WebKitWebView* page, gint progress, gpointer data) { + (void) page; + (void) data; + load_progress = progress; + update_title (GTK_WINDOW (main_window)); +} + +static void +load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { + (void) page; + (void) data; + free (uri); + GString* newuri = g_string_new (webkit_web_frame_get_uri (frame)); + uri = g_string_free (newuri, FALSE); +} + +static void +destroy_cb (GtkWidget* widget, gpointer data) { + (void) widget; + (void) data; + gtk_main_quit (); +} + +static void +log_history_cb () { + if (history_handler) { + time_t rawtime; + struct tm * timeinfo; + char date [80]; + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + strftime (date, 80, "%Y-%m-%d %H:%M:%S", timeinfo); + GString* args = g_string_new (""); + g_string_printf (args, "'%s' '%s' '%s'", uri, "TODO:page title here", date); + run_command(history_handler, args->str); + g_string_free (args, TRUE); + } +} + +/* -- command to callback/function map for things we cannot attach to any signals */ +// TODO: reload, home, quit + +static Command cmdlist[] = +{ + { "back", &go_back_cb, NULL }, + { "forward", &go_forward_cb, NULL }, + { "refresh", &webkit_web_view_reload, NULL }, //Buggy + { "stop", &webkit_web_view_stop_loading, NULL }, + { "zoom_in", &webkit_web_view_zoom_in, NULL }, //Can crash (when max zoom reached?). + { "zoom_out", &webkit_web_view_zoom_out, NULL }, + { "uri", (void *) NULL, &load_uri }, + { "toggle_status", &toggle_status_cb, NULL }, + { "home" , &go_home, NULL }, + { "exit" , &close_uzbl, NULL }, + { NULL, NULL, NULL } +//{ "get uri", &webkit_web_view_get_uri}, +}; + +static void +commands_hash(void) +{ + unsigned int i = 0; + commands = g_hash_table_new(g_str_hash, g_str_equal); + + while(cmdlist[i].command != NULL){ + g_hash_table_insert(commands, cmdlist[i].command, &cmdlist[i]); + i++; + } +} + +/* -- CORE FUNCTIONS -- */ + +static bool +file_exists (const char * filename) { + FILE *file = fopen (filename, "r"); + if (file) { + fclose (file); + return true; + } + return false; +} + +static void +load_uri (WebKitWebView * web_view, const gchar * uri) { + if (uri != NULL) { + GString* newuri = g_string_new (uri); + if (g_strrstr (uri, "://") == NULL) + g_string_prepend (newuri, "http://"); + webkit_web_view_load_uri (web_view, newuri->str); + g_string_free (newuri, TRUE); + } +} + +static void +new_window_load_uri (const gchar * uri) { + GString* to_execute = g_string_new (""); + if (!config_file) { + g_string_printf (to_execute, "uzbl --uri '%s'", uri); + } else { + g_string_printf (to_execute, "uzbl --uri '%s' --config '%s'", uri, config_file); + } + printf("Spawning %s\n",to_execute->str); + if (!g_spawn_command_line_async (to_execute->str, NULL)) { + if (!config_file) { + g_string_printf (to_execute, "./uzbl --uri '%s'", uri); + } else { + g_string_printf (to_execute, "./uzbl --uri '%s' --config '%s'", uri, config_file); + } + printf("Spawning %s\n",to_execute->str); + g_spawn_command_line_async (to_execute->str, NULL); + } + g_string_free (to_execute, TRUE); +} + +static void +go_home (WebKitWebView * web_view) { + if (home_page) + webkit_web_view_load_uri (web_view, home_page); +} + +static void +close_uzbl (WebKitWebView * web_view) { + (void) web_view; + gtk_main_quit (); +} + +// make sure to put '' around args, so that if there is whitespace we can still keep arguments together. +static gboolean +run_command(const char *command, const char *args) { + //command [args] + GString* to_execute = g_string_new (""); + gboolean result; + g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", command, config_file, (int) getpid() , (int) xwin, fifo_path, socket_path); + if(args) { + g_string_append_printf (to_execute, " %s", args); + } + result = g_spawn_command_line_async (to_execute->str, NULL); + printf("Called %s. Result: %s\n", to_execute->str, (result ? "TRUE" : "FALSE" )); + g_string_free (to_execute, TRUE); + return result; +} + +static void +parse_command(const char *cmd) { + Command *c = NULL; + char buffer[512]; + strcpy (buffer, cmd); + char * saveptr; + char * command_name = strtok_r (buffer, " ", &saveptr); + gchar * command_param = strtok_r (NULL, " ,", &saveptr); + + if((c = g_hash_table_lookup(commands, command_name)) != NULL){ + if (c->func_2_params != NULL) { + if (command_param != NULL) { + printf ("command executing: \"%s %s\"\n", command_name, command_param); + c->func_2_params (web_view, command_param); + } else { + if (c->func_1_param != NULL) { + printf ("command executing: \"%s\"\n", command_name); + c->func_1_param (web_view); + } else + fprintf (stderr, "command needs a parameter. \"%s\" is not complete\n", command_name); + } + } else if (c->func_1_param != NULL) { + printf ("command executing: \"%s\"\n", command_name); + c->func_1_param (web_view); + } + } else + fprintf (stderr, "command \"%s\" not understood. ignoring.\n", cmd); + + if(cmd) + free(cmd); +} + +static void +control_fifo(GIOChannel *fd) { + gchar *ctl_line; + gsize ctl_line_length, term_pos; + + if(!fd) + return; + + g_io_channel_read_line(fd, &ctl_line, &ctl_line_length, &term_pos, NULL); //TODO: support partial writes + ctl_line[term_pos] ='\0'; + parse_command(ctl_line); + + return; +} + +static void +create_fifo() { + GIOChannel *chan = NULL; + + if (fifo_dir) { + sprintf (fifo_path, "%s/uzbl_fifo_%d", fifo_dir, (int) xwin); + } else { + sprintf (fifo_path, "/tmp/uzbl_fifo_%d", (int) xwin); + } + printf ("Control fifo opened in %s\n", fifo_path); + if (mkfifo (fifo_path, 0666) == -1) { + printf ("Possible error creating fifo\n"); + } + + if( (chan = g_io_channel_new_file((gchar *) fifo_path, "r+", NULL)) ) + g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, chan); + return; +} + +static void +*control_socket() { + if (socket_dir) { + sprintf (socket_path, "%s/uzbl_socket_%d", socket_dir, (int) xwin); + } else { + sprintf (socket_path, "/tmp/uzbl_socket_%d", (int) xwin); + } + + int sock, clientsock, len; + unsigned int t; + struct sockaddr_un local, remote; + + sock = socket (AF_UNIX, SOCK_STREAM, 0); + + local.sun_family = AF_UNIX; + strcpy (local.sun_path, socket_path); + unlink (local.sun_path); + + len = strlen (local.sun_path) + sizeof (local.sun_family); + bind (sock, (struct sockaddr *) &local, len); + + if (errno == -1) { + printf ("A problem occurred when opening a socket in %s\n", socket_path); + } else { + printf ("Control socket opened in %s\n", socket_path); + } + + listen (sock, 5); + + char buffer[512], *ctl_line; + char temp[128]; + int done, n; + for(;;) { + memset (buffer, 0, sizeof (buffer)); + + t = sizeof (remote); + clientsock = accept (sock, (struct sockaddr *) &remote, &t); + printf ("Connected to client\n"); + + done = 0; + do { + memset (temp, 0, sizeof (temp)); + n = recv (clientsock, temp, 128, 0); + if (n == 0) { + buffer[strlen (buffer)] = '\0'; + done = 1; + } + + if (!done) + strcat (buffer, temp); + } while (!done); + + if (strcmp (buffer, "\n") < 0) { + buffer[strlen (buffer) - 1] = '\0'; + } else { + buffer[strlen (buffer)] = '\0'; + } + + ctl_line = estrdup(buffer); + parse_command (ctl_line); + close (clientsock); + } + + return NULL; +} + +static void +setup_threading () { + pthread_t control_thread; + pthread_create(&control_thread, NULL, control_socket, NULL); +} + +static void +update_title (GtkWindow* window) { + GString* string_long = g_string_new (""); + GString* string_short = g_string_new (""); + if (!always_insert_mode) + g_string_append (string_long, (insert_mode ? "[I] " : "[C] ")); + g_string_append (string_long, main_title); + g_string_append (string_short, main_title); + g_string_append (string_long, " - Uzbl browser"); + g_string_append (string_short, " - Uzbl browser"); + if (load_progress < 100) + g_string_append_printf (string_long, " (%d%%)", load_progress); + + if (selected_url[0]!=0) { + g_string_append_printf (string_long, " -> (%s)", selected_url); + } + + gchar* title_long = g_string_free (string_long, FALSE); + gchar* title_short = g_string_free (string_short, FALSE); + + if (show_status) { + gtk_window_set_title (window, title_short); + gtk_label_set_text(GTK_LABEL(mainbar_label), title_long); + } else { + gtk_window_set_title (window, title_long); + } + + g_free (title_long); + g_free (title_short); +} + +static gboolean +key_press_cb (WebKitWebView* page, GdkEventKey* event) +{ + (void) page; + gpointer act; + gboolean result=FALSE; //TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further. + if (event->type != GDK_KEY_PRESS || event->keyval == GDK_Page_Up || event->keyval == GDK_Page_Down + || event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Left || event->keyval == GDK_Right) + return result; + + //TURN OFF/ON INSERT MODE + if (!always_insert_mode && ((insert_mode && (event->keyval == GDK_Escape)) || (!insert_mode && (event->string[0] == 'i')))) { + insert_mode = !insert_mode; + update_title (GTK_WINDOW (main_window)); + return TRUE; + } + + //INTERNAL BINDINGS + if((act = g_hash_table_lookup(internal_bindings, event->string)) != NULL) + if (!insert_mode || (event->state == modmask)) { + parse_command (act); + result = TRUE; + } + + //EXTERNAL BINDINGS + if((act = g_hash_table_lookup(external_bindings, event->string)) != NULL) + if (!insert_mode || (event->state == modmask)) { + run_command (act, NULL); + result = TRUE; + } + + if (!result) + result = (insert_mode ? FALSE : TRUE); + + return result; +} + +static GtkWidget* +create_browser () { + GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER); //todo: some sort of display of position/total length. like what emacs does + + web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ()); + gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view)); + + g_signal_connect (G_OBJECT (web_view), "title-changed", G_CALLBACK (title_change_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (load_commit_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (log_history_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "key-press-event", G_CALLBACK (key_press_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "new-window-policy-decision-requested", G_CALLBACK (new_window_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "download-requested", G_CALLBACK (download_cb), web_view); + g_signal_connect (G_OBJECT (web_view), "create-web-view", G_CALLBACK (create_web_view_cb), web_view); + + return scrolled_window; +} + +static GtkWidget* +create_mainbar () { + mainbar = gtk_hbox_new (FALSE, 0); + mainbar_label = gtk_label_new (""); + gtk_misc_set_alignment (GTK_MISC(mainbar_label), 0, 0); + gtk_misc_set_padding (GTK_MISC(mainbar_label), 2, 2); + gtk_box_pack_start (GTK_BOX (mainbar), mainbar_label, TRUE, TRUE, 0); + return mainbar; +} + +static +GtkWidget* create_window () { + GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); + gtk_widget_set_name (window, "Uzbl browser"); + g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL); + + return window; +} + +static void +add_binding (char *binding, char *action, bool internal) { + g_hash_table_insert(internal ? internal_bindings : external_bindings, + binding, action); +} + +static void +settings_init () { + GKeyFile* config; + gboolean res = FALSE; + gchar** keysi = NULL; + gchar** keyse = NULL; + char *saveptr; + + if (!config_file) { + const char* XDG_CONFIG_HOME = getenv ("XDG_CONFIG_HOME"); + if (! XDG_CONFIG_HOME || ! strcmp (XDG_CONFIG_HOME, "")) { + XDG_CONFIG_HOME = (char *)XDG_CONFIG_HOME_default; + } + printf("XDG_CONFIG_HOME: %s\n", XDG_CONFIG_HOME); + + strcpy (config_file_path, XDG_CONFIG_HOME); + strcat (config_file_path, "/uzbl/config"); + if (file_exists (config_file_path)) { + printf ("Config file %s found.\n", config_file_path); + config_file = &config_file_path[0]; + } else { + // Now we check $XDG_CONFIG_DIRS + char *XDG_CONFIG_DIRS = getenv ("XDG_CONFIG_DIRS"); + if (! XDG_CONFIG_DIRS || ! strcmp (XDG_CONFIG_DIRS, "")) + XDG_CONFIG_DIRS = XDG_CONFIG_DIRS_default; + + printf("XDG_CONFIG_DIRS: %s\n", XDG_CONFIG_DIRS); + + char buffer[512]; + strcpy (buffer, XDG_CONFIG_DIRS); + const gchar* dir = (char *) strtok_r (buffer, ":", &saveptr); + while (dir && ! file_exists (config_file_path)) { + strcpy (config_file_path, dir); + strcat (config_file_path, "/uzbl/config_file_pathig"); + if (file_exists (config_file_path)) { + printf ("Config file %s found.\n", config_file_path); + config_file = &config_file_path[0]; + } + dir = (char * ) strtok_r (NULL, ":", &saveptr); + } + } + } + + if (config_file) { + config = g_key_file_new (); + res = g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, NULL); + if(res) { + printf ("Config %s loaded\n", config_file); + } else { + fprintf (stderr, "Config %s loading failed\n", config_file); + } + } else { + printf ("No configuration.\n"); + } + + if (res) { + history_handler = g_key_file_get_value (config, "behavior", "history_handler", NULL); + download_handler = g_key_file_get_value (config, "behavior", "download_handler", NULL); + always_insert_mode = g_key_file_get_boolean (config, "behavior", "always_insert_mode", NULL); + show_status = g_key_file_get_boolean (config, "behavior", "show_status", NULL); + modkey = g_key_file_get_value (config, "behavior", "modkey", NULL); + keysi = g_key_file_get_keys (config, "bindings_internal", NULL, NULL); + keyse = g_key_file_get_keys (config, "bindings_external", NULL, NULL); + status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL); + home_page = g_key_file_get_value (config, "behavior", "home_page", NULL); + if (! fifo_dir) + fifo_dir = g_key_file_get_value (config, "behavior", "fifo_dir", NULL); + if (! socket_dir) + socket_dir = g_key_file_get_value (config, "behavior", "socket_dir", NULL); + } + + printf ("History handler: %s\n", (history_handler ? history_handler : "disabled")); + printf ("Download manager: %s\n", (download_handler ? download_handler : "disabled")); + printf ("Fifo directory: %s\n", (fifo_dir ? fifo_dir : "/tmp")); + printf ("Socket directory: %s\n", (socket_dir ? socket_dir : "/tmp")); + printf ("Always insert mode: %s\n", (always_insert_mode ? "TRUE" : "FALSE")); + printf ("Show status: %s\n", (show_status ? "TRUE" : "FALSE")); + printf ("Status top: %s\n", (status_top ? "TRUE" : "FALSE")); + printf ("Modkey: %s\n", (modkey ? modkey : "disabled")); + printf ("Home page: %s\n", (home_page ? home_page : "disabled")); + + if (! modkey) + modkey = ""; + + //POSSIBLE MODKEY VALUES (COMBINATIONS CAN BE USED) + gchar* modkeyup = g_utf8_strup (modkey, -1); + if (g_strrstr (modkeyup,"SHIFT") != NULL) modmask |= GDK_SHIFT_MASK; //the Shift key. + if (g_strrstr (modkeyup,"LOCK") != NULL) modmask |= GDK_LOCK_MASK; //a Lock key (depending on the modifier mapping of the X server this may either be CapsLock or ShiftLock). + if (g_strrstr (modkeyup,"CONTROL") != NULL) modmask |= GDK_CONTROL_MASK; //the Control key. + if (g_strrstr (modkeyup,"MOD1") != NULL) modmask |= GDK_MOD1_MASK; //the fourth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier, but normally it is the Alt key). + if (g_strrstr (modkeyup,"MOD2") != NULL) modmask |= GDK_MOD2_MASK; //the fifth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"MOD3") != NULL) modmask |= GDK_MOD3_MASK; //the sixth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"MOD4") != NULL) modmask |= GDK_MOD4_MASK; //the seventh modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"MOD5") != NULL) modmask |= GDK_MOD5_MASK; //the eighth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"BUTTON1") != NULL) modmask |= GDK_BUTTON1_MASK; //the first mouse button. + if (g_strrstr (modkeyup,"BUTTON2") != NULL) modmask |= GDK_BUTTON2_MASK; //the second mouse button. + if (g_strrstr (modkeyup,"BUTTON3") != NULL) modmask |= GDK_BUTTON3_MASK; //the third mouse button. + if (g_strrstr (modkeyup,"BUTTON4") != NULL) modmask |= GDK_BUTTON4_MASK; //the fourth mouse button. + if (g_strrstr (modkeyup,"BUTTON5") != NULL) modmask |= GDK_BUTTON5_MASK; //the fifth mouse button. + if (g_strrstr (modkeyup,"SUPER") != NULL) modmask |= GDK_SUPER_MASK; //the Super modifier. Since 2.10 + if (g_strrstr (modkeyup,"HYPER") != NULL) modmask |= GDK_HYPER_MASK; //the Hyper modifier. Since 2.10 + if (g_strrstr (modkeyup,"META") != NULL) modmask |= GDK_META_MASK; //the Meta modifier. Since 2.10 */ + free (modkeyup); + + if (keysi) { + int i = 0; + for (i = 0; keysi[i]; i++) { + gchar *binding = g_key_file_get_string (config, "bindings_internal", keysi[i], NULL); + printf ("Action: %s, Binding: %s (internal)\n", g_strdup (keysi[i]), binding); + add_binding (binding, g_strdup (keysi[i]), true); + } + } + if (keyse) { + int i = 0; + for (i = 0; keyse[i]; i++) { + gchar *binding = g_key_file_get_string (config, "bindings_external", keyse[i], NULL); + printf ("Action: %s, Binding: %s (external)\n", g_strdup (keyse[i]), binding); + add_binding (binding, g_strdup (keyse[i]), false); + } + } +} + +int +main (int argc, char* argv[]) { + gtk_init (&argc, &argv); + if (!g_thread_supported ()) + g_thread_init (NULL); + + printf("Uzbl start location: %s\n", argv[0]); + + strcat ((char *) XDG_CONFIG_HOME_default, getenv ("HOME")); + strcat ((char *) XDG_CONFIG_HOME_default, "/.config"); + + GError *error = NULL; + GOptionContext* context = g_option_context_new ("- some stuff here maybe someday"); + g_option_context_add_main_entries (context, entries, NULL); + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + g_option_context_parse (context, &argc, &argv, &error); + /* initialize has tables */ + internal_bindings = g_hash_table_new(g_str_hash, g_str_equal); + external_bindings = g_hash_table_new(g_str_hash, g_str_equal); + + settings_init (); + commands_hash (); + + if (always_insert_mode) + insert_mode = TRUE; + + GtkWidget* vbox = gtk_vbox_new (FALSE, 0); + if (status_top) + gtk_box_pack_start (GTK_BOX (vbox), create_mainbar (), FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), create_browser (), TRUE, TRUE, 0); + if (!status_top) + gtk_box_pack_start (GTK_BOX (vbox), create_mainbar (), FALSE, TRUE, 0); + + main_window = create_window (); + gtk_container_add (GTK_CONTAINER (main_window), vbox); + + load_uri (web_view, uri); + + gtk_widget_grab_focus (GTK_WIDGET (web_view)); + gtk_widget_show_all (main_window); + xwin = GDK_WINDOW_XID (GTK_WIDGET (main_window)->window); + printf("window_id %i\n",(int) xwin); + printf("pid %i\n", getpid ()); + + if (!show_status) + gtk_widget_hide(mainbar); + + setup_threading (); + create_fifo (); + + gtk_main (); + + unlink (socket_path); + unlink (fifo_path); + return 0; +} + +/* vi: set et ts=4: */ diff --git a/uzblctrl.c b/uzblctrl.c new file mode 100644 index 0000000..5415247 --- /dev/null +++ b/uzblctrl.c @@ -0,0 +1,63 @@ +/* Socket code more or less completely copied from here: http://www.ecst.csuchico.edu/~beej/guide/ipc/usock.html */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static gchar* sockpath; +static gchar* command; + +static GOptionEntry entries[] = +{ + { "socket", 's', 0, G_OPTION_ARG_STRING, &sockpath, "Socket path of the client uzbl", NULL }, + { "command", 'c', 0, G_OPTION_ARG_STRING, &command, "The uzbl command to execute", NULL }, + { NULL, 0, 0, 0, NULL, NULL, NULL } +}; + +int +main(int argc, char* argv[]) { + GError *error = NULL; + GOptionContext* context = g_option_context_new ("- some stuff here maybe someday"); + g_option_context_add_main_entries (context, entries, NULL); + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + g_option_context_parse (context, &argc, &argv, &error); + + int s, len; + struct sockaddr_un remote; + + if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1) { + perror ("socket"); + exit (1); + } + + remote.sun_family = AF_UNIX; + strcpy (remote.sun_path, (char *) sockpath); + len = strlen (remote.sun_path) + sizeof (remote.sun_family); + + if (connect (s, (struct sockaddr *) &remote, len) == -1) { + perror ("connect"); + exit (1); + } + + if (send (s, command, strlen (command), 0) == -1) { + perror ("send"); + exit (1); + } + + close(s); + + return 0; +}