├── LICENSE ├── archwiki-offline └── Readme.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Nikhil Singh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /archwiki-offline: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Nikhil Singh 4 | # This will make searching archwikki easy. 5 | 6 | # Variables 7 | _menu_cmd="rofi -dmenu -i -p ArchWiki " 8 | _opener="xdg-open" 9 | _disown=false 10 | _lang="en" # for future possibilities to have different lang support 11 | 12 | check() { 13 | command -v "$1" >/dev/null 2>&1 14 | } 15 | 16 | notify() { 17 | # shellcheck disable=SC2015 18 | check notify-send && { 19 | notify-send "$@" 20 | } || { 21 | echo "$@" 22 | } 23 | } 24 | 25 | main() { 26 | [ -d /usr/share/doc/arch-wiki/html ] || { 27 | notify "arch-wiki-docs not installed" 28 | exit 1 29 | } 30 | 31 | wikidir="/usr/share/doc/arch-wiki/html/en" 32 | wikidocs="$(find ${wikidir} -iname "*.html")" 33 | 34 | choice=$(echo "$wikidocs" | sed -e "s|${wikidir}/||g" | sed -e "s|.html||g" | sed 's/_/ /g' | sort -n | eval "$_menu_cmd") 35 | [ -z "$choice" ] && exit 0 36 | article=$(printf "%s\n" "${wikidir}/${choice}.html" | sed 's/ /_/g') 37 | if $_disown; then 38 | $_opener "$article" &>/dev/null & 39 | else 40 | $_opener "$article" 41 | fi 42 | } 43 | 44 | help() { 45 | cat < 2 | 3 | [![made-with-bash](https://img.shields.io/badge/-Made%20with%20Bash-1f425f.svg?logo=image%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTExIDc5LjE1ODMyNSwgMjAxNS8wOS8xMC0wMToxMDoyMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9w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ohNfni%2Bx6OMUMMNe%2Fgf7ocbw0v0acKg6J8Ql0q%2BT%2FAXR5PNi5dz9c71upuQqCKFAD%2BYhrZLEAmpodaHO3Qy6TI3NhBpbrshGtOWKOSMYwYGQM8nJzoFJNxP2HjyIQho4PewK6hBktoDcUwtIln4PjOWzflQ%2Be5yl0yCCYgYikTclGlxadio%2BBQCSiW1UXoVGrKYwH4RgMrjU1HAB4vR6LzWYfFUCKxfS8Ftk5qxHoCUQAUkRJaSEokkV6Y%2F%2BJUOC4hn6A39NVXVBYeNP8piH6HeA4fPbpdBQV5KOx0QaL1YppX3Jgk0TwH2Vg6S3u%2BdB91%2B%2FpuNYPYFl5uP5V7ZqvsrX7jxqMXR6ff3gCQSTzFI0a1TX3wIs8ul%2Bq4HuWAAiM39vhOuR1O1fQ2gT%2F26Z8Z5vrl2OHi9OXZn995nLV9aFfS6UC9JeJPfuK0NBohWpCHMSAAsFe74WWP%2BvT25wtP9Bpob6uGqqyDnOtaeumjRu%2ByFu36VntK%2FPA5umTJeUtPWZSU9BCgud661odVp3DZtkc7AnYR33RRC708PrVi1larW7XwZIjLnd7R6SgSqWSNjU1B3F72pz5TZbXmX5vV81Yb7Lg7XT%2FUXriu8XLVqw6c6XqWnBKiiYU%2BMt3wWF7u7i91XlSEITwSAZ%2FCzAAHsJVbwXYFFEAAAAASUVORK5CYII%3D)](https://www.gnu.org/software/bash/) 4 | 5 | 6 | 7 | # ArchWiki Offline Access Script 8 | 9 | **ArchWiki Offline Access Script** is a powerful tool to fetch and search the ArchWiki documentation offline right from your terminal. It relies on the `arch-wiki-docs` package to provide you with a seamless experience of browsing and troubleshooting Arch Linux related topics. 10 | 11 | ## Features 12 | 13 | - **Offline Access**: Browse ArchWiki documentation without requiring an active internet connection. 14 | 15 | - **Flexible Display Modes**: Choose between `rofi`, `dmenu`, or `fzf` for listing and selecting ArchWiki topics. 16 | 17 | - **Customizable Opening Method**: Open links using `xdg-open`, `firefox`, `chromium`, `w3m`, or your preferred application. 18 | Absolutely, here's the revised installation section with the "manual" method included: 19 | 20 | ## Installation 21 | 22 | ### Manual Installation 23 | 1. Install the arch-wiki-docs package using your package manager: 24 | ```bash 25 | yay -S arch-wiki-docs 26 | ``` 27 | 28 | 2. Clone this repository: 29 | 30 | ```bash 31 | git clone https://github.com/niksingh710/archwiki-offline.git 32 | cd archwiki-offline 33 | ``` 34 | 35 | 3. Make the script executable: 36 | 37 | ```bash 38 | chmod +x archwiki 39 | ``` 40 | 41 | ### Using AUR Package (Recommended) 42 | 1. Install the `archwiki-offline` package from AUR: 43 | 44 | ```bash 45 | yay -S archwiki-offline 46 | ``` 47 | 48 | Using the AUR package is the recommended method as it takes care of dependencies and provides a smoother installation experience. 49 | 50 | ## Usage 51 | 52 | ```bash 53 | ./archwiki [FLAGS] 54 | ``` 55 | 56 | **Flags**: 57 | 58 | - `-h`: Display help information. 59 | - `-d`: Disown the process. (Does not keep the terminal hanging after opening the file in a browser) 60 | - `-m MODE`: Select the display mode (`rofi`, `dmenu`, or `fzf`). 61 | - `-o OPENER`: Specify the opening method for links (`xdg-open`, `firefox`, `chromium`, `w3m`, etc.). Default is `xdg-open`. 62 | 63 | ## Tips 64 | 65 | ### Example with fzf 66 | 67 | For a seamless experience with `fzf`, consider creating a wrapper script that formats the page titles for better readability and uses `w3m` to display a preview of the selected page: 68 | 69 | ```bash 70 | #!/bin/bash 71 | 72 | # Custom script for using fzf with ArchWiki offline access 73 | # Replaces spaces in the selected topic with underscores and opens the corresponding HTML file in w3m for preview 74 | 75 | # Usage: ./fzf_archwiki.sh "Selected ArchWiki Topic" 76 | 77 | # Replace spaces with underscores 78 | selected_topic=$(echo "$1" | sed 's/ /_/g') 79 | 80 | # Open the HTML file using w3m for preview 81 | w3m /usr/share/doc/arch-wiki/html/en/$selected_topic.html 82 | ``` 83 | 84 | You can save this script as `fzf_archwiki.sh`, make it executable (`chmod +x fzf_archwiki.sh`), and use it along with your main script. Here's how you can use it: 85 | 86 | ```bash 87 | archwiki-offline -m "fzf --preview './fzf_archwiki.sh {}'" 88 | ``` 89 | 90 | With this script, the selected ArchWiki topic will be passed to the `fzf_archwiki.sh` script, which will replace spaces with underscores and open the corresponding HTML file using `w3m` for a preview. 91 | 92 | Remember to adjust file paths and names according to your actual setup if needed. 93 | This will allow you to preview the selected topic in the terminal itself before opening it in your browser. 94 | 95 | * *If you Don't Prefer Other script* you can add this to your .bashrc or .zshrc this will give you an alias to open archwiki in fzf with preview 96 | 97 | alias is archwiki 98 | 99 | ```bash 100 | command -v archwiki-offline &>/dev/null && { 101 | _temp_file="$(mktemp -q)" 102 | cat <"$_temp_file" 103 | #!/bin/bash 104 | # Replace spaces with underscores 105 | selected_topic=\$(echo "\$1" | sed 's/ /_/g') 106 | 107 | # Open the HTML file using w3m for preview 108 | w3m /usr/share/doc/arch-wiki/html/en/\$selected_topic.html 109 | EOF 110 | chmod +x "$_temp_file" 111 | 112 | _cmd="xdg-open" 113 | command -v fzf &>/dev/null && _cmd="fzf" 114 | command -v w3m &>/dev/null && _cmd="fzf --preview=\"$_temp_file {}\"" 115 | alias archwiki="archwiki-offline -m '$_cmd'" 116 | } 117 | ``` 118 | 119 | ### Dark Mode in Browser 120 | 121 | If you prefer using a browser to preview the ArchWiki files instead of `w3m`, you can take advantage of the [Dark Reader](https://darkreader.org/) extension to enable dark mode for the ArchWiki pages. However, there's a catch: when the pages are fetched from the system in offline mode, Dark Reader might not automatically apply the dark theme. To ensure it works seamlessly, follow the instructions below: 122 | 123 | #### For Chrome 124 | 125 | 1. Open a new tab and enter `chrome://extensions` in the address bar. 126 | 2. Locate "Dark Reader" in the extensions list and click on it. 127 | 3. Enable the option "Allow access to file URLs." 128 | 129 | #### For Firefox 130 | 131 | 1. Type `about:config` in the Firefox address bar and press Enter. 132 | 2. In the search bar, enter `security.fileuri.strict_origin_policy`. 133 | 3. Double-click on the entry to set it to `false`. 134 | 4. Restart Firefox to apply the changes. 135 | 136 | These adjustments will ensure that Dark Reader can successfully apply dark mode to the offline ArchWiki pages. If you encounter any issues or have further questions, feel free to create an issue on the [GitHub repository](https://github.com/niksingh710/archwiki-offline). You can also refer to [this issue on Dark Reader](https://github.com/darkreader/darkreader/issues/475) for more information. 137 | 138 | This enhancement will provide users with an option to enjoy the ArchWiki pages in dark mode when using a browser for previewing. 139 | ## Contribution 140 | 141 | Feel free to contribute to this script by opening issues or submitting pull requests on the [GitHub repository](https://github.com/niksingh710/archwiki-offline). Your contributions will be highly appreciated. 142 | 143 | 144 | ## Acknowledgements 145 | 146 | This project is made possible by the amazing [`arch-wiki-docs`](https://github.com/lahwaacz/arch-wiki-docs) project, which provides the backbone for offline ArchWiki access. A big thank you to the creators and maintainers of this tool for their dedication to the Arch Linux community. 147 | 148 | Special thanks to [Lahwaacz](https://github.com/lahwaacz) for developing and maintaining `arch-wiki-docs`. Your work has significantly enriched the Arch Linux experience for users like me. 149 | 150 | Without the invaluable efforts put into `arch-wiki-docs`, this project wouldn't have been possible. Thank you! 151 | 152 | --- 153 | 154 | **Note:** This project is not affiliated with or endorsed by `arch-wiki-docs`. It simply builds upon the functionality provided by that project to offer a more streamlined offline ArchWiki access experience. 155 | 156 | ## License 157 | 158 | This project is licensed under the [MIT License](LICENSE). 159 | 160 | --------------------------------------------------------------------------------