├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── config.yml │ ├── feature-request.md │ └── other.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── CI.yml │ └── mdl_style.rb ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── MAINTAINERS.md ├── Makefile ├── README.md ├── RELEASE.md ├── cliff.toml ├── doc └── man │ └── zaman.1.scd ├── res └── completions │ ├── zaman.bash │ ├── zaman.fish │ └── zaman.zsh ├── src └── zaman.sh └── test └── case └── basic_functions.bats /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Antiz96 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug 4 | title: '' 5 | labels: bug 6 | assignees: Antiz96 7 | 8 | --- 9 | 10 | 11 | 12 | ### Environment 13 | 14 | 17 | 18 | - Distribution: 19 | - zaman version: 20 | 21 | ### Description of the bug 22 | 23 | 24 | 25 | ### Screenshots / Logs 26 | 27 | 29 | 30 | ```text 31 | Paste any relevant logs here (if you have some) 32 | ``` 33 | 34 | ### Additional context 35 | 36 | 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Contributing guidelines 4 | url: https://github.com/Antiz96/zaman/blob/main/CONTRIBUTING.md 5 | about: Please, read the contributing guidelines before opening an issue 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea or a new feature 4 | title: '' 5 | labels: feature/request 6 | assignees: Antiz96 7 | 8 | --- 9 | 10 | 11 | 12 | ### Description 13 | 14 | 15 | 16 | ### Motivation and context 17 | 18 | 21 | 22 | ### Screenshots / Logs 23 | 24 | 25 | 26 | ```text 27 | Paste any relevant logs here (if you have some) 28 | ``` 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Other 3 | about: Ask a general question or provide a feedback 4 | title: '' 5 | labels: 'question/feedback' 6 | assignees: Antiz96 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Description 4 | 5 | 6 | 7 | ### Screenshots / Logs 8 | 9 | 10 | 11 | ```text 12 | Paste any relevant logs here (if you have some) 13 | ``` 14 | 15 | ### Fixed bug 16 | 17 | 18 | 19 | Fixes "issue_URL" (if any) 20 | 21 | ### Addressed feature request 22 | 23 | 24 | 25 | Closes "issue_URL" (if any) 26 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: pull_request 3 | 4 | jobs: 5 | Test: 6 | runs-on: 7 | - self-hosted 8 | - CI-CD 9 | 10 | steps: 11 | - name: Clone repo 12 | uses: actions/checkout@v4 13 | 14 | - name: Run actionlint 15 | run: actionlint -ignore 'label "CI-CD" is unknown' .github/workflows/CI.yml 16 | 17 | - name: Run codespell 18 | run: codespell --enable-colors 19 | 20 | - name: Run mdl 21 | run: mdl --style .github/workflows/mdl_style.rb . 22 | 23 | - name: Run shellcheck 24 | run: find . -name '*.sh' -exec shellcheck --color=always {} + 25 | 26 | - name: Run make clean 27 | run: make clean 28 | 29 | - name: Run make 30 | run: make 31 | 32 | - name: Run make test 33 | run: make test 34 | -------------------------------------------------------------------------------- /.github/workflows/mdl_style.rb: -------------------------------------------------------------------------------- 1 | # Include all rules 2 | all 3 | 4 | # Exclude the rules that refers to the line length 5 | exclude_tag :line_length 6 | 7 | # Allow having multiple headers with the same content (for CHANGELOG.md) 8 | exclude_rule 'MD024' 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.1 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## [v1.3.3](https://github.com/Antiz96/zaman/releases/tag/v1.3.3) - 2025-02-17 6 | 7 | ### Styling 8 | 9 | - Remove unconventional dots from output ([#70](https://github.com/Antiz96/zaman/pull/70)) - ([a330014](https://github.com/Antiz96/zaman/commit/a330014db2e46f5f7b0ac914536dfa6b94c61391)) by @Antiz96 10 | 11 | ### Miscellaneous 12 | 13 | - *(man)* Don't compress man pages during build ([#69](https://github.com/Antiz96/zaman/pull/69)) - ([3048a2e](https://github.com/Antiz96/zaman/commit/3048a2ed0358ae7c22921b1d8e3f278af404fbb0)) by @Antiz96 14 | 15 | ## [v1.3.2](https://github.com/Antiz96/zaman/releases/tag/v1.3.2) - 2025-02-07 16 | 17 | ### Styling 18 | 19 | - Add a missing dot in the help msg ([#67](https://github.com/Antiz96/zaman/pull/67)) - ([bcd4b86](https://github.com/Antiz96/zaman/commit/bcd4b86eceafcdff05b113ae6bf3630e0f521c8c)) by @Antiz96 20 | 21 | ### Miscellaneous 22 | 23 | - Get rid of gzip timestamps during build to make Zaman reproducible ([#68](https://github.com/Antiz96/zaman/pull/68)) - ([51efce8](https://github.com/Antiz96/zaman/commit/51efce8d1671e57c4b02ad783923f1446b927456)) by @Antiz96 24 | 25 | ## [v1.3.1](https://github.com/Antiz96/zaman/releases/tag/v1.3.1) - 2025-01-22 26 | 27 | ### Documentation 28 | 29 | - Update help message and man page ([#66](https://github.com/Antiz96/zaman/pull/66)) - ([a28f3de](https://github.com/Antiz96/zaman/commit/a28f3dee7c29169e03dfdde5999e6194072fbe80)) by @Antiz96 30 | 31 | ## [v1.3.0](https://github.com/Antiz96/zaman/releases/tag/v1.3.0) - 2025-01-22 32 | 33 | ### Features 34 | 35 | - Use default PDF reader defined in XDG Mime Application (fallback to zathura) ([#65](https://github.com/Antiz96/zaman/pull/65)) - ([40a6f71](https://github.com/Antiz96/zaman/commit/40a6f719070afab8161e7e66ef81c4a1f582e2cf)) by @Antiz96 36 | - Add dynamic shell completions for man pages ([#64](https://github.com/Antiz96/zaman/pull/64)) - ([8586cb4](https://github.com/Antiz96/zaman/commit/8586cb4fccb3ec03ee802e95ccf78dafb704f5be)) by @Antiz96 37 | - Add the `-D / --debug` option ([#63](https://github.com/Antiz96/zaman/pull/63)) - ([28e6917](https://github.com/Antiz96/zaman/commit/28e69175c61b50293678a252c3bef2e7d312bc7d)) by @Antiz96 38 | 39 | ### Fixes 40 | 41 | - Fix script path in Makefile ([#59](https://github.com/Antiz96/zaman/pull/59)) - ([f1d2efb](https://github.com/Antiz96/zaman/commit/f1d2efbf858ef5bdd48843caea189b31a95891ea)) by @Antiz96 42 | 43 | ### Documentation 44 | 45 | - Add the 'License' section to the table of content in the README ([#60](https://github.com/Antiz96/zaman/pull/60)) - ([2dabea9](https://github.com/Antiz96/zaman/commit/2dabea9565bc5a530d055a7dd62d6433fc7b3621)) by @Antiz96 46 | - Overall documentation rework ([#56](https://github.com/Antiz96/zaman/pull/56)) - ([a08403a](https://github.com/Antiz96/zaman/commit/a08403ad9d096a3a0745bdf31cf74e3fc8fac3b3)) by @Antiz96 47 | 48 | ### Styling 49 | 50 | - *(CONTRIBUTING.md)* Fix typos ([#61](https://github.com/Antiz96/zaman/pull/61)) - ([848e796](https://github.com/Antiz96/zaman/commit/848e796331f4b271eeca4f05b6b8e663f23e6985)) by @Antiz96 51 | 52 | ### Miscellaneous 53 | 54 | - Update mdl rules in CI ([#62](https://github.com/Antiz96/zaman/pull/62)) - ([5902d50](https://github.com/Antiz96/zaman/commit/5902d506cbfcc44a6b479bdb0de1ee37ed4aa65d)) by @Antiz96 55 | - Add Release instructions + Changelog ([#58](https://github.com/Antiz96/zaman/pull/58)) - ([d83b65c](https://github.com/Antiz96/zaman/commit/d83b65c65d0727f8f52b8fe444db4c020f166fe3)) by @Antiz96 56 | - Add simple unit tests with 'bats' ([#57](https://github.com/Antiz96/zaman/pull/57)) - ([7d42d37](https://github.com/Antiz96/zaman/commit/7d42d37d95cb8bfa876f65037ff09ab069214cc6)) by @Antiz96 57 | - Add issues / pull requests templates ([#55](https://github.com/Antiz96/zaman/pull/55)) - ([51a234f](https://github.com/Antiz96/zaman/commit/51a234f71b1de71fa0d328b82ab29b82d0ad984d)) by @Antiz96 58 | - Add CONTRIBUTING.md ([#54](https://github.com/Antiz96/zaman/pull/54)) - ([cc25e41](https://github.com/Antiz96/zaman/commit/cc25e4165098a34081664d8e1e058bcdf6484ffe)) by @Antiz96 59 | 60 | ## [v1.2.3](https://github.com/Antiz96/zaman/releases/tag/v1.2.3) - 2024-04-13 61 | 62 | ### Features 63 | 64 | - Add shell completions for bash, zsh and fish by @Antiz96 in 65 | 66 | ### Improvements 67 | 68 | - Use complete version ref in man page by @Antiz96 in 69 | - Add a trust path for users by @Antiz96 in 70 | - Precise that Zaman is licensed under GPL3+ by @Antiz96 in 71 | - Add comments to the Makefile by @Antiz96 in 72 | 73 | ## [v1.2.2](https://github.com/Antiz96/zaman/releases/tag/v1.2.2) - 2023-06-10 74 | 75 | - Add a GitHub action to run shellcheck on pull requests by @Antiz96 in 76 | - Add basic but useful information at the top of the main script by @Antiz96 in 77 | - Refactoring the script with functions by @Antiz96 in 78 | - Add the '-m / --menu' option by @Antiz96 in 79 | - Add a clear and concise help message (instead of simply printing the man page) for the --help option by @Antiz96 in 80 | - Use separated exit codes for each type of errors by @Antiz96 in 81 | - Bump the script to v1.2.2 by @Antiz96 in 82 | 83 | ## [v1.2.1](https://github.com/Antiz96/zaman/releases/tag/v1.2.1) - 2023-05-13 84 | 85 | - Run the zathura process in the background by @Antiz96 in 86 | 87 | ## [v1.2.0](https://github.com/Antiz96/zaman/releases/tag/v1.2.0) - 2023-03-22 88 | 89 | - Let the users choose their preferred pdf backend between [zathura-pdf-poppler] and [zathura-pdf-mupdf] by @Antiz96 in 90 | - Add rofi support by @Antiz96 in 91 | - Print a proper error if no man page or file path is specified when using the output option by @Antiz96 in 92 | - Stop opening PDF man pages in fullscreen mode by default by @Antiz96 in 93 | - Bump the main script to v1.2.0 by @Antiz96 in 94 | 95 | ## [v1.1.0](https://github.com/Antiz96/zaman/releases/tag/v1.1.0) - 2022-09-21 96 | 97 | - **New feature**: The `-o`/`--output` flag allows you to save the PDF converted man page to a file of your choice (requested in #15 by @SomethingGeneric) 98 | 99 | ```bash 100 | zaman -o ls ~/Documents/man/ls.pdf 101 | ``` 102 | 103 | - **New feature**: The `-O`/`--save` flag allows you to quickly save the PDF converted man page to a local file named `man_.pdf` (requested in #15 by @SomethingGeneric) 104 | 105 | You can either select the man page to save as a PDF file via the dmenu list: 106 | 107 | ```bash 108 | zaman -O 109 | ``` 110 | 111 | Or you can specify the man page to save as a PDF file directly in the command: 112 | 113 | ```bash 114 | zaman -O ls 115 | ``` 116 | 117 | - Added the `-o`/`-O` flags' documentation in both README.md and the `zaman` man page. 118 | - Added various little improvements to the script. 119 | 120 | ## [v1.0.2](https://github.com/Antiz96/zaman/releases/tag/v1.0.2) - 2022-09-14 121 | 122 | - The repo has been restructured to better suit best practices. 123 | - New install/uninstall method: The install.sh and uninstall.sh scripts have been removed in favor of a Makefile; which is cleaner, more standard and way easier to maintain. 124 | - The wiki pages has been merged directly into the README to centralize information (the wiki has therefore been deleted). 125 | - The "dependencies" (and overall) documentation has been improved. 126 | - A LICENSE file has been added to the repo (GLP3). 127 | 128 | ## [v1.0.1](https://github.com/Antiz96/zaman/releases/tag/v1.0.1) - 2022-08-09 129 | 130 | - Added groff as a dependency (also "groff-perl" and "perl(Compress:Zlib)" for RedHat/Fedora based distros) 131 | - Various typo fixes 132 | 133 | ## [v1.0.0](https://github.com/Antiz96/zaman/releases/tag/v1.0.0) - 2022-08-08 134 | 135 | - Initial Release 136 | 137 | 138 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thank you for considering contributing to [zaman](https://github.com/Antiz96/zaman)! 4 | 5 | With the exception of the [general rules](#general-rules) (which **must** be acknowledged and applied in any contribution / interaction in this project), these guidelines represent an ideal target & standards that I would like this project to follow but may not all be **strictly** enforced (depending on the situation). 6 | 7 | Please, don't refrain yourself from contributing if you feel that your contribution may not entirely follow these guidelines (or if you're struggling applying some of them). I value your contributions much more than the strict application of these guidelines! 8 | 9 | ## Table of contents 10 | 11 | - [General rules](#general-rules) 12 | - [Open an issue](#open-an-issue) 13 | - [Open a pull request](#open-a-pull-request) 14 | - [Donations](#donations) 15 | - [Thank you](#thank-you) 16 | 17 | ## General rules 18 | 19 | These general rules apply to **every** contributions (whatever the type). They should **always** be acknowledged and **strictly** followed in any circumstances: 20 | 21 | Basic common sense applies to every contributions & discussions: stay polite and respectful, no flaming / trolling / spamming or any kind of discrimination / harassment, avoid controversial topics *(specifically if it has nothing to do with this project whatsoever)*, etc... 22 | 23 | Use English as much as possible for contributions & discussions. If required, I can also speak French, but it's important that contributions & discussions remain intelligible to most people. 24 | 25 | ## Open an issue 26 | 27 | Before [opening an issue](https://github.com/Antiz96/zaman/issues/new/choose), verify that there isn't one already open on the same (or a similar) subject. 28 | 29 | Make sure to use the correct type for your issue (`Bug Report` or `Feature Request`) and to provide the requested information. If you have a doubt about which one is the most appropriate for your issue (or if you think that none of these types apply to your issue), feel free to use the general `Other` type. 30 | 31 | Providing as much details as possible in your issue will ease its processing. 32 | 33 | ## Open a pull request 34 | 35 | Read the following sub-chapters before opening a pull request. 36 | Make sure to create your merge request from a dedicated branch (do not use the `main` branch) and to provide the information requested in the [pull request template](https://github.com/Antiz96/antiz/blob/main/.github/PULL_REQUEST_TEMPLATE.md). 37 | 38 | ### Open an issue first 39 | 40 | Apart from trivial changes (like simple typo fixes), it is advised to first [open an issue](#open-an-issue) to expose and discuss your changes, verify its feasibility / necessity and agree on the specifications. 41 | 42 | ### Coding style 43 | 44 | When submitting code changes, try to respect the coding style and the overall way things work, as much as possible. 45 | 46 | Bash code is checked with [shellcheck](https://www.shellcheck.net/). 47 | Markdown syntax is checked with [markdownlint](https://github.com/markdownlint/markdownlint). 48 | 49 | ### Commit message format 50 | 51 | Commits must follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. 52 | 53 | This project uses the following commit types: 54 | 55 | - chore: for internal / miscellaneous changes 56 | - feat: for new features (or improvements / additions to existing features) 57 | - fix: for bug fixes 58 | - doc: for documentation only changes 59 | - style: For changes that do not affect the meaning of the code (white-space, formatting, typo fixes, etc...) 60 | 61 | An optional scope can be provided to the commit type if relevant (for instance when a change is specific to a precise part of the project), like so: `type(scope): commit message`. 62 | 63 | If a commit introduces a breaking change, its type must contain a `!` (e.g. `feat!: commit message`) and / or a `BREAKING CHANGE:` mention should be added at the end of your commit message (e.g. `BREAKING CHANGE: description of the breaking change`). 64 | 65 | Here are a few examples of the expected commit format: 66 | 67 | ```text 68 | feat(menu): Add rofi support 69 | 70 | Add rofi support (in addition of dmenu) for the menu option. 71 | 72 | Closes https://github.com/Antiz96/zaman/issues/163 73 | ``` 74 | 75 | ```text 76 | fix: Run the zathura process in the background 77 | 78 | Run the zathura process in the background so people can still use their terminal while reading PDF man pages. 79 | 80 | Fixes https://github.com/Antiz96/zaman/issues/103 81 | ``` 82 | 83 | ```text 84 | doc(man): Add the -m / --menu option to man pages 85 | 86 | The recently introduced -m / --menu option was missing from the man page 87 | ``` 88 | 89 | ```text 90 | style: Typo fixes in README and man page 91 | ``` 92 | 93 | ```text 94 | chore!(code structure): Split the script functions into separate libraries 95 | 96 | Split the functions inside the main script into their own separate libraries scripts to improve readability and ease the overall maintenance and contribution processes. 97 | 98 | Closes https://github.com/Antiz96/zaman/issues/230 99 | 100 | BREAKING CHANGE: People that installed zaman from source will have to either uninstall it (with `make uninstall`) **before** pulling and installing the new version (with `make install`). Otherwise, some files will remain un-tracked on the system. 101 | ``` 102 | 103 | ### License 104 | 105 | By contributing to this project, you agree that your contributions will be licensed under the [GPL-3.0 license](https://github.com/Antiz96/zaman/blob/main/LICENSE) (or any later version of this license). 106 | 107 | ## Donations 108 | 109 | You can also support this project development (and my work in general) by making a donation via my [GitHub sponsor page](https://github.com/sponsors/Antiz96). 110 | 111 | ## Thank you 112 | 113 | Once again, thank you for considering contributing to zaman! 114 | I'd also like to sincerely thank everyone that gave zaman a star, opened issues, feature requests, pull requests or contributed to this project in any other way! :heart: 115 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers 2 | 3 | This file contains the maintainers that are trusted and are allowed to cut and sign git tags and release artifacts for this project. 4 | As a user, you can *(and should)* verify that git tags and auto-generated source tarballs on releases (tar.gz archives) for this project are signed by one of the person listed below (with the associated OpenPGP key). 5 | 6 | If a git tag or an auto-generated source tarball (tar.gz archive) contained in a release of this project cannot be verified (e.g. it is not signed / it is signed with a OpenPGP key or by a person that is not listed below), the associated tag/release/artifact(s) should not be trusted. 7 | 8 | Current maintainers: 9 | 10 | | Name | Mail | OpenPGP Key (ID / Fingerprint) | GitHub username | 11 | | ---- | ---- | ----------------------------- | --------------- | 12 | | Robin Candau | robincandau@protonmail.com | D33FAA16B937F3B2 / A67CCEEBF9613C17FDE96E4ED33FAA16B937F3B2 | @Antiz96 | 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | pkgname=zaman 2 | 3 | PREFIX ?= /usr/local 4 | 5 | .PHONY: build test install clean uninstall 6 | 7 | build: 8 | # Generate man page 9 | scdoc < "doc/man/${pkgname}.1.scd" > "doc/man/${pkgname}.1" 10 | 11 | test: 12 | # Run some simple unit tests on basic functions 13 | bats test/case/basic_functions.bats 14 | 15 | install: 16 | # Install the main script 17 | install -Dm 755 "src/${pkgname}.sh" "${DESTDIR}${PREFIX}/bin/${pkgname}" 18 | 19 | # Install shell completions 20 | install -Dm 644 "res/completions/${pkgname}.bash" "${DESTDIR}${PREFIX}/share/bash-completion/completions/${pkgname}" 21 | install -Dm 644 "res/completions/${pkgname}.zsh" "${DESTDIR}${PREFIX}/share/zsh/site-functions/_${pkgname}" 22 | install -Dm 644 "res/completions/${pkgname}.fish" "${DESTDIR}${PREFIX}/share/fish/vendor_completions.d/${pkgname}.fish" 23 | 24 | # Install man page 25 | install -Dm 644 "doc/man/${pkgname}.1" "${DESTDIR}${PREFIX}/share/man/man1/${pkgname}.1" 26 | 27 | # Install documentation 28 | install -Dm 644 README.md "${DESTDIR}${PREFIX}/share/doc/${pkgname}/README.md" 29 | 30 | clean: 31 | # Delete generated man page 32 | rm -f "doc/man/${pkgname}.1" 33 | 34 | uninstall: 35 | # Delete the main script 36 | rm -f "${DESTDIR}${PREFIX}/bin/${pkgname}" 37 | 38 | # Delete shell completions 39 | rm -f "${DESTDIR}${PREFIX}/share/bash-completion/completions/${pkgname}" 40 | rm -f "${DESTDIR}${PREFIX}/share/zsh/site-functions/_${pkgname}" 41 | rm -f "${DESTDIR}${PREFIX}/share/fish/vendor_completions.d/${pkgname}.fish" 42 | 43 | # Delete man pages 44 | rm -f "${DESTDIR}${PREFIX}/share/man/man1/${pkgname}.1" 45 | 46 | # Delete documentation 47 | rm -rf "${DESTDIR}${PREFIX}/share/doc/${pkgname}/" 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zaman 2 | 3 | ## Table of contents 4 | 5 | - [Description](#description) 6 | - [Installation](#installation) 7 | - [Usage](#usage) 8 | - [Documentation](#documentation) 9 | - [Contributing](#contributing) 10 | - [License](#license) 11 | 12 | ## Description 13 | 14 | A simple CLI tool to display (or save) man pages as PDFs files for an easier reading. 15 | Zaman first looks for the default PDF reader defined in [XDG MIME Applications](https://wiki.archlinux.org/title/XDG_MIME_Applications) and fallback to [Zathura](https://pwmt.org/projects/zathura/) if no default PDF reader is set. 16 | It also allows to navigate through all the man pages available on the system through a dynamic menu via [Rofi](https://davatorium.github.io/rofi/) or [Dmenu](https://tools.suckless.org/dmenu/). 17 | 18 | ## Installation 19 | 20 | ### AUR 21 | 22 | Install the [zaman](https://aur.archlinux.org/packages/zaman) AUR package (also check the list of optional dependencies for anything you may want or need). 23 | 24 | ### From Source 25 | 26 | Install dependencies: 27 | 28 | - Replace `zathura-pdf-poppler` by `zathura-pdf-mupdf` if you prefer to use the `mupdf` backend. 29 | - Replace `rofi` by `dmenu` if you prefer to use that (provided by the `suckless-tools` package on Debian / Ubuntu). 30 | - The second line are build dependencies (not required to run `zaman` once it is installed). 31 | 32 | #### Debian / Ubuntu 33 | 34 | ```bash 35 | sudo apt install man-db groff xdg-utils zathura zathura-pdf-poppler rofi 36 | sudo apt install make bats scdoc 37 | ``` 38 | 39 | #### Fedora 40 | 41 | ```bash 42 | sudo dnf install man-db groff groff-perl "perl(Compress::Zlib)" xdg-utils zathura zathura-pdf-poppler rofi 43 | sudo dnf install make bats scdoc 44 | ``` 45 | 46 | #### Arch Linux 47 | 48 | ```bash 49 | sudo pacman -S man-db groff xdg-utils zathura zathura-pdf-poppler rofi 50 | sudo pacman -S --asdeps make bats scdoc 51 | ``` 52 | 53 | #### Alpine Linux 54 | 55 | ```bash 56 | sudo apk add man-db groff xdg-utils zathura zathura-pdf-poppler rofi 57 | sudo apk add make bats scdoc 58 | ``` 59 | 60 | #### Gentoo 61 | 62 | ```bash 63 | sudo emerge man-db groff xdg-utils zathura zathura-pdf-poppler rofi 64 | sudo emerge make bats scdoc 65 | ``` 66 | 67 | Download the archive of the [latest stable release](https://github.com/Antiz96/zaman/releases/latest) and extract it (alternatively, you can clone this repository with `git`). 68 | 69 | To install `zaman`, go into the extracted/cloned directory and run the following command: 70 | 71 | ```bash 72 | sudo make 73 | sudo make test 74 | sudo make install 75 | ``` 76 | 77 | Once the installation is complete, you may optionally clean up the directory of files generated during installation by running the following command: 78 | 79 | ```bash 80 | sudo make clean 81 | ``` 82 | 83 | To uninstall `zaman`, go into the extracted/cloned directory and run the following command: 84 | 85 | ```bash 86 | sudo make uninstall 87 | ``` 88 | 89 | ## Usage 90 | 91 | Run the `zaman` command in your terminal to display a list of all the available man pages on your system in a dynamic menu (via [Rofi](https://davatorium.github.io/rofi/) or [Dmenu](https://tools.suckless.org/dmenu/)), allowing you to search for the one to display as a PDF. 92 | 93 | ![zaman](https://user-images.githubusercontent.com/53110319/226755165-3080f232-cb9f-4d5b-aa06-b18032cd8eaa.png) 94 | 95 | Alternatively, you can directly specify the man page to open in the command (example below with the "ls" man page): 96 | 97 | ![zaman_cmd](https://user-images.githubusercontent.com/53110319/226755190-9d005cbe-b893-4b96-b6c1-db97a70f3a4b.png) 98 | 99 | The man page is opened as a PDF file in the default PDF reader defined in [XDG Mime Applications](https://wiki.archlinux.org/title/XDG_MIME_Applications) or in [Zathura](https://pwmt.org/projects/zathura/) if no default PDF reader is set. 100 | 101 | ![zaman_pdf](https://github.com/Antiz96/zaman/assets/53110319/fca2f8a7-c428-47f9-a1cd-e3dd295ce3ca) 102 | 103 | You can export a specific man page in a PDF file called "man_`command`.pdf" in your current directory with the `-O` (or `--save`) option *(if you run `zaman -O` without specifying which man page to save, `zaman` will offer you to select one via rofi / dmenu)*: 104 | 105 | ![zaman_save](https://user-images.githubusercontent.com/53110319/226755247-637c4827-9940-43e4-88e9-4978152e4cc4.png) 106 | 107 | Alternatively, you can specify the destination file with the `-o` (or `--output`) option: 108 | 109 | ![zaman_output](https://user-images.githubusercontent.com/53110319/226755261-cb4bf006-fae3-48ea-8187-8c4e1772b7b0.png) 110 | 111 | ## Documentation 112 | 113 | See `zaman --help` and the [zaman(1) man page](https://github.com/Antiz96/zaman/blob/main/doc/man/zaman.1.scd). 114 | 115 | ## Contributing 116 | 117 | See the [contributing guidelines](https://github.com/Antiz96/zaman/blob/main/CONTRIBUTING.md). 118 | 119 | ## License 120 | 121 | zaman is licensed under the [GPL-3.0 license](https://github.com/Antiz96/zaman/blob/main/LICENSE) (or any later version of that license). 122 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Creating a release 2 | 3 | - Make sure that `git-cliff` is installed and `zaman` is up to date on your system. 4 | 5 | - Export a `TAG` variable containing the new tag for the release: 6 | 7 | ```bash 8 | export TAG="X.Y.Z" 9 | ``` 10 | 11 | - Bump version where necessary: 12 | 13 | ```bash 14 | sed -i "s/$(zaman -V | cut -f2 -d " ")/${TAG}/g" doc/man/zaman.* src/zaman.sh 15 | ``` 16 | 17 | - Update changelog: 18 | 19 | ```bash 20 | git-cliff -up CHANGELOG.md 21 | sed -i "s|\[unreleased\]|\[v${TAG}\](https://github.com/Antiz96/zaman/releases/tag/v${TAG})\ -\ $(date '+%Y-%m-%d')|g" CHANGELOG.md 22 | ``` 23 | 24 | - Commit, sign and push changes directly to the **main branch** *(we want the tagged commit to be signed with the [OpenPGP Key](https://keyserver.ubuntu.com/pks/lookup?search=D33FAA16B937F3B2&fingerprint=on&op=index) listed in [MAINTAINERS.md](https://github.com/Antiz96/zaman/blob/main/MAINTAINERS.md) and not with the GitHub signature key automatically used when merging a pull request; this implies **temporarily** allowing administrators to bypass branch protections rules)*: 25 | 26 | ```bash 27 | git add . 28 | git commit -SD33FAA16B937F3B2 -m "chore(release): v${TAG}" 29 | git push 30 | ``` 31 | 32 | - Create, sign and push the new tag: 33 | 34 | ```bash 35 | git tag v${TAG} -u D33FAA16B937F3B2 -m "v${TAG}" 36 | git push origin v${TAG} 37 | ``` 38 | 39 | - Create a release on GitHub, download and sign the auto-generated source tarball: 40 | 41 | ```bash 42 | cd ~/Downloads 43 | gpg --local-user D33FAA16B937F3B2 --armor --detach-sign zaman-${TAG}.tar.gz 44 | sha256sum zaman-${TAG}.tar.gz > zaman-${TAG}.tar.gz.sha256 45 | gpg --local-user D33FAA16B937F3B2 --armor --detach-sign zaman-${TAG}.tar.gz.sha256 46 | rm -f zaman-${TAG}.tar.gz 47 | ``` 48 | 49 | - Upload the 3 produced files as assets in the release, re-enable the branch protection rules on the main branch for administrators and unset the `TAG` variable: 50 | 51 | ```bash 52 | unset TAG 53 | ``` 54 | -------------------------------------------------------------------------------- /cliff.toml: -------------------------------------------------------------------------------- 1 | # git-cliff ~ default configuration file 2 | # https://git-cliff.org/docs/configuration 3 | 4 | [remote.github] 5 | owner = "Antiz96" 6 | repo = "zaman" 7 | 8 | [changelog] 9 | # template for the changelog footer 10 | header = """ 11 | # Changelog\n 12 | All notable changes to this project will be documented in this file.\n 13 | """ 14 | # template for the changelog body 15 | # https://keats.github.io/tera/docs/#introduction 16 | body = """ 17 | {%- macro remote_url() -%} 18 | https://github.com/Antiz96/zaman 19 | {%- endmacro -%} 20 | 21 | {% macro print_commit(commit) -%} 22 | - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ 23 | {% if commit.breaking %}[**breaking**] {% endif %}\ 24 | {{ commit.message | upper_first }} - \ 25 | ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\ 26 | {% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%} 27 | {% endmacro -%} 28 | 29 | {% if version %}\ 30 | ## [{{ version }}]\ 31 | ({{ self::remote_url() }}/releases/tag/{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} 32 | {% else %}\ 33 | ## [unreleased] 34 | {% endif %}\ 35 | 36 | {% for group, commits in commits | group_by(attribute="group") %} 37 | ### {{ group | striptags | trim | upper_first }} 38 | {% for commit in commits 39 | | filter(attribute="scope") 40 | | sort(attribute="scope") %} 41 | {{ self::print_commit(commit=commit) }} 42 | {%- endfor -%} 43 | {% raw %}\n{% endraw %}\ 44 | {%- for commit in commits %} 45 | {%- if not commit.scope -%} 46 | {{ self::print_commit(commit=commit) }} 47 | {% endif -%} 48 | {% endfor -%} 49 | {% endfor %}\n 50 | """ 51 | # template for the changelog footer 52 | footer = """ 53 | 54 | """ 55 | # remove the leading and trailing s 56 | trim = true 57 | # postprocessors 58 | postprocessors = [ 59 | { pattern = '', replace = "https://github.com/Antiz96/zaman" }, # replace repository URL 60 | ] 61 | 62 | [git] 63 | # parse the commits based on https://www.conventionalcommits.org 64 | conventional_commits = true 65 | # filter out the commits that are not conventional 66 | filter_unconventional = false 67 | # process each line of a commit as an individual commit 68 | split_commits = false 69 | # regex for preprocessing the commit messages 70 | commit_preprocessors = [ 71 | { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/pull/${2}))" }, 72 | ] 73 | # regex for parsing and grouping commits 74 | commit_parsers = [ 75 | { message = "^feat", group = "Features" }, 76 | { message = "^fix", group = "Fixes" }, 77 | { message = "^doc", group = "Documentation" }, 78 | { message = "^style", group = "Styling" }, 79 | { message = "^chore\\(release\\): v", skip = true }, 80 | { message = "^chore", group = "Miscellaneous" }, 81 | ] 82 | # protect breaking changes from being skipped due to matching a skipping commit_parser 83 | protect_breaking_commits = false 84 | # filter out the commits that are not matched by commit parsers 85 | filter_commits = false 86 | # regex for matching git tags 87 | # tag_pattern = "v[0-9].*" 88 | # regex for skipping tags 89 | # skip_tags = "" 90 | # regex for ignoring tags 91 | # ignore_tags = "" 92 | # sort the tags topologically 93 | topo_order = false 94 | # sort the commits inside sections by oldest/newest order 95 | sort_commits = "newest" 96 | # limit the number of commits included in the changelog. 97 | # limit_commits = 42 98 | -------------------------------------------------------------------------------- /doc/man/zaman.1.scd: -------------------------------------------------------------------------------- 1 | zaman(1) ["Zaman 1.3.3" ["Zaman Manual"]] 2 | 3 | # NAME 4 | 5 | *Zaman* - A simple CLI tool to display (or save) man pages as PDFs files. 6 | 7 | # DESCRIPTION 8 | 9 | A simple CLI tool to display (or save) man pages as PDFs files for an easier reading. 10 | Zaman first looks for the default PDF reader defined in XDG MIME Applications and fallback to Zathura if no default PDF reader is set. 11 | It also allows to navigate through all the man pages available on the system through a dynamic menu via Rofi or Dmenu. 12 | 13 | # SYNOPSIS 14 | 15 | *zaman* [OPTION] [MAN_PAGE] 16 | 17 | # OPTIONS 18 | 19 | You can directly specify the man page to display as a PDF. For instance, to display the `ls` man page: 20 | 21 | ``` 22 | zaman ls 23 | ``` 24 | 25 | *-m, --menu* 26 | Display the list of all the available man pages in a dynamic menu (rofi or dmenu), allowing you to search for the one to display as a PDF (default operation). 27 | 28 | *-o, --output* 29 | Export into the PDF . 30 | For instance, `zaman -o ls ~/Documents/man/ls.pdf`. 31 | 32 | *-O, --save* 33 | Export into a "man_.pdf" PDF file inside your current directory. 34 | For instance, `zaman -O ls` (which will save the `ls` man page in a file called `man_ls.pdf` PDF file in your current directory). 35 | If isn't specified (`zaman -O`), it opens a dynamic menu listing all man pages available on your system, allowing you to choose the one to export. 36 | 37 | *-D, --debug* 38 | Display debug traces. 39 | 40 | *-V, --version* 41 | Display version information. 42 | 43 | *-h, --help* 44 | Display the help message. 45 | 46 | # EXIT STATUS 47 | 48 | *0* 49 | OK. 50 | 51 | *1* 52 | Invalid option or unknown man page. 53 | 54 | *2* 55 | Neither `rofi` nor `dmenu` are installed. 56 | 57 | *3* 58 | User didn't gave the confirmation to proceed. 59 | 60 | *4* 61 | User didn't specified a man page or a file to export it in to with the `-o / --output` option. 62 | 63 | *5* 64 | No default PDF reader defined in XDG Mime Application and `zathura` isn't installed as well. 65 | 66 | # SEE ALSO 67 | 68 | *man*(1), 69 | *groff*(1), 70 | *xdg-mime*(1), 71 | *xdg-open*(1), 72 | *rofi*(1), 73 | *dmenu*(1), 74 | *zathura*(1) 75 | 76 | # BUGS 77 | 78 | Please report bugs to the GitHub page: https://github.com/Antiz96/zaman 79 | 80 | # AUTHOR 81 | 82 | Robin Candau 83 | -------------------------------------------------------------------------------- /res/completions/zaman.bash: -------------------------------------------------------------------------------- 1 | _zaman() { 2 | local arg="${2}" 3 | local -a opts 4 | 5 | opts=('-m --menu 6 | -o --output 7 | -O --save 8 | -D --debug 9 | -h --help 10 | -V --version') 11 | 12 | local man_pages=$(man -k . | awk '{print $1}') 13 | opts+=("${man_pages}") 14 | 15 | COMPREPLY=( $(compgen -W "${opts[*]}" -- "${arg}") ) 16 | } 17 | 18 | complete -F _zaman zaman 19 | -------------------------------------------------------------------------------- /res/completions/zaman.fish: -------------------------------------------------------------------------------- 1 | complete -c zaman -f 2 | 3 | complete -c zaman -s m -l menu -d 'Print a menu via rofi or dmenu that lists every man pages to choose from (default operation)' 4 | complete -c zaman -s o -l output -d '(Args ) Save into the PDF file' 5 | complete -c zaman -s O -l save -d '(Arg ) Save into the "man_.pdf" file in the current directory' 6 | complete -c zaman -s D -l debug -d 'Display debug traces' 7 | complete -c zaman -s h -l help -d 'Display the help message' 8 | complete -c zaman -s V -l version -d 'Display version information' 9 | 10 | function _zaman_man_pages 11 | man -k . | awk '{print $1}' 12 | end 13 | 14 | complete -c zaman -a "(_zaman_man_pages)" 15 | -------------------------------------------------------------------------------- /res/completions/zaman.zsh: -------------------------------------------------------------------------------- 1 | #compdef zaman 2 | 3 | local -a opts 4 | opts=( 5 | {-m,--menu}'[Print a menu via rofi or dmenu that lists every man pages to choose from (default operation)]' 6 | {-o,--output}'[(Args ) Save into the PDF file]' 7 | {-O,--save}'[(Arg ) Save into the "man_.pdf" file in the current directory]' 8 | {-D,--debug}'[Display debug traces]' 9 | {-h,--help}'[Display the help message]' 10 | {-V,--version}'[Display version information]' 11 | ) 12 | 13 | local man_pages=(${(f)"$(man -k . | awk '{print $1}')"}) 14 | 15 | _arguments $opts '*::man-pages:(${man_pages})' 16 | -------------------------------------------------------------------------------- /src/zaman.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # zaman: A simple CLI tool to display (or save) man pages as PDFs files for an easier reading. 4 | # https://github.com/Antiz96/zaman 5 | # Licensed under the GPL-3.0 license (or any later version of that license). 6 | 7 | # General variables 8 | name="zaman" 9 | version="1.3.3" 10 | option="${1}" 11 | man_selected="${2}" 12 | file="${3}" 13 | 14 | # Create tmp dir if it doesn't exists 15 | tmpdir="${TMPDIR:-/tmp}/${name}-${UID}" 16 | mkdir -p "${tmpdir}" 17 | 18 | # Display debug traces if the -D / --debug argument is passed 19 | for arg in "${@}"; do 20 | case "${arg}" in 21 | -D|--debug) 22 | set -x 23 | ;; 24 | esac 25 | done 26 | 27 | # Reset the option var if it is equal to -D / --debug (to avoid false negative "invalid option" error) 28 | # shellcheck disable=SC2154 29 | case "${option}" in 30 | -D|--debug) 31 | unset option 32 | ;; 33 | esac 34 | 35 | # Definition of the help function: Print the help message 36 | help() { 37 | cat < Save into the PDF file 46 | -O, --save Save into a "man_.pdf" file in the current directory; if isn't specified, open a menu via rofi or dmenu that lists every man pages to choose from 47 | -D, --debug Display debug traces 48 | -h, --help Display this message 49 | -V, --version Display version information 50 | 51 | For more information, see the ${name}(1) man page. 52 | EOF 53 | } 54 | 55 | # Definition of the version function: Print the current version 56 | version() { 57 | echo "${name} ${version}" 58 | } 59 | 60 | # Definition of the invalid_option function: Print an error message, ask the user to check the help and exit 61 | invalid_option() { 62 | echo -e >&2 "${name}: invalid option -- '${option}'\nTry '${name} --help' for more information" 63 | exit 1 64 | } 65 | 66 | # Definition of the check_man_page function: Check if "${man_selected}" matches a man page (used in the "print_to_pdf" and "save_to_file" functions) 67 | check_man_page() { 68 | if ! man -k . | awk '{print $1}' | grep -iq ^"${man_selected}"$; then 69 | echo -e >&2 "${name}: man page not found -- '${man_selected}'\nTry '${name} --help' for more information" 70 | exit 1 71 | fi 72 | } 73 | 74 | # Definition of the print_to_pdf function: Display "${man_selected}" in a PDF file 75 | print_to_pdf() { 76 | check_man_page 77 | 78 | # Check if a default PDF reader is set, otherwise fallback to zathura 79 | if [ -n "$(xdg-mime query default application/pdf)" ]; then 80 | pdf_reader="xdg-open" 81 | elif command -v zathura > /dev/null; then 82 | pdf_reader="zathura" 83 | else 84 | echo -e >&2 "There is no default PDF reader defined and Zathura isn't installed\nPlease, define a default PDF reader in XDG Mime Applications or install Zathura" 85 | exit 5 86 | fi 87 | 88 | man -Tpdf "${man_selected}" > "${tmpdir}/${man_selected}.pdf" 89 | "${pdf_reader}" "${tmpdir}/${man_selected}.pdf" & 90 | } 91 | 92 | # Definition of the menu function: Print the list of available man pages through a `rofi` or `dmenu` menu 93 | menu() { 94 | if command -v rofi > /dev/null; then 95 | man_selected=$(man -k . | awk '{print $1}' | rofi -dmenu -sort) 96 | elif command -v dmenu > /dev/null; then 97 | man_selected=$(man -k . | awk '{print $1}' | dmenu -l 15) 98 | else 99 | echo -e >&2 "A dynamic menu is required to print the list of available man pages\nPlease, install rofi or dmenu" 100 | exit 2 101 | fi 102 | } 103 | 104 | # Definition of the save_to_file function: Save output to "${file}" (used in the "output" and "save" functions) 105 | save_to_file() { 106 | check_man_page 107 | 108 | if [ -f "${file}" ]; then 109 | echo "The ${file} file already exists" 110 | read -rp $'Do you want to overwrite its content? [y/N] ' answer 111 | 112 | case "${answer}" in 113 | [Yy]) 114 | echo 115 | ;; 116 | *) 117 | echo -e >&2 "\nAborting" 118 | exit 3 119 | ;; 120 | esac 121 | fi 122 | 123 | man -Tpdf "${man_selected}" > "${file}" 124 | echo "The ${man_selected} man page has been saved to the ${file} file" 125 | } 126 | 127 | # Definition of the output function: Save the man page to the specified PDF file 128 | output() { 129 | if [ -z "${man_selected}" ] || [ -z "${file}" ]; then 130 | echo -e >&2 "Please, specify a man page to export and a file to save it to: ${name} -o man_page /path/to/file\nTry '${name} --help' for more information" 131 | exit 4 132 | fi 133 | 134 | save_to_file 135 | } 136 | 137 | # Definition of the save function: Save the man page to a PDF file named "man_.pdf" in the current directory 138 | save() { 139 | if [ -z "${man_selected}" ]; then 140 | menu 141 | fi 142 | 143 | file="man_${man_selected}.pdf" 144 | 145 | save_to_file 146 | } 147 | 148 | 149 | # Execute the different functions depending on the option 150 | case "${option}" in 151 | -m|--menu|"") 152 | menu && print_to_pdf 153 | ;; 154 | -o|--output) 155 | output 156 | ;; 157 | -O|--save) 158 | save 159 | ;; 160 | -h|--help) 161 | help 162 | ;; 163 | -V|--version) 164 | version 165 | ;; 166 | *) 167 | if [ "${option:0:1}" == "-" ]; then 168 | invalid_option 169 | else 170 | man_selected="${option}" 171 | print_to_pdf 172 | fi 173 | ;; 174 | esac 175 | -------------------------------------------------------------------------------- /test/case/basic_functions.bats: -------------------------------------------------------------------------------- 1 | @test "version" { 2 | src/zaman.sh --version 3 | } 4 | 5 | @test "help" { 6 | src/zaman.sh --help 7 | } 8 | --------------------------------------------------------------------------------