Skip to content

niksingh710/archwiki-offline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

made-with-bash

ArchWiki Offline Access Script

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.

Features

  • Offline Access: Browse ArchWiki documentation without requiring an active internet connection.

  • Flexible Display Modes: Choose between rofi, dmenu, or fzf for listing and selecting ArchWiki topics.

  • Customizable Opening Method: Open links using xdg-open, firefox, chromium, w3m, or your preferred application. Absolutely, here's the revised installation section with the "manual" method included:

Installation

Manual Installation

  1. Install the arch-wiki-docs package using your package manager:
yay -S arch-wiki-docs
  1. Clone this repository:

    git clone https://github.com/niksingh710/archwiki-offline.git
    cd archwiki-offline
  2. Make the script executable:

    chmod +x archwiki

Using AUR Package (Recommended)

  1. Install the archwiki-offline package from AUR:

    yay -S archwiki-offline

Using the AUR package is the recommended method as it takes care of dependencies and provides a smoother installation experience.

Usage

./archwiki [FLAGS]

Flags:

  • -h: Display help information.
  • -d: Disown the process. (Does not keep the terminal hanging after opening the file in a browser)
  • -m MODE: Select the display mode (rofi, dmenu, or fzf).
  • -o OPENER: Specify the opening method for links (xdg-open, firefox, chromium, w3m, etc.). Default is xdg-open.

Tips

Example with fzf

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:

#!/bin/bash

# Custom script for using fzf with ArchWiki offline access
# Replaces spaces in the selected topic with underscores and opens the corresponding HTML file in w3m for preview

# Usage: ./fzf_archwiki.sh "Selected ArchWiki Topic"

# Replace spaces with underscores
selected_topic=$(echo "$1" | sed 's/ /_/g')

# Open the HTML file using w3m for preview
w3m /usr/share/doc/arch-wiki/html/en/$selected_topic.html

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:

archwiki-offline -m "fzf --preview './fzf_archwiki.sh {}'"

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.

Remember to adjust file paths and names according to your actual setup if needed. This will allow you to preview the selected topic in the terminal itself before opening it in your browser.

  • 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

alias is archwiki

command -v archwiki-offline &>/dev/null && {
	_temp_file="$(mktemp -q)"
	cat <<EOF >"$_temp_file"
#!/bin/bash
# Replace spaces with underscores
selected_topic=\$(echo "\$1" | sed 's/ /_/g')

# Open the HTML file using w3m for preview
w3m /usr/share/doc/arch-wiki/html/en/\$selected_topic.html
EOF
	chmod +x "$_temp_file"

	_cmd="xdg-open"
	command -v fzf &>/dev/null && _cmd="fzf"
	command -v w3m &>/dev/null && _cmd="fzf --preview=\"$_temp_file {}\""
	alias archwiki="archwiki-offline -m '$_cmd'"
}

Dark Mode in Browser

If you prefer using a browser to preview the ArchWiki files instead of w3m, you can take advantage of the Dark Reader 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:

For Chrome

  1. Open a new tab and enter chrome://extensions in the address bar.
  2. Locate "Dark Reader" in the extensions list and click on it.
  3. Enable the option "Allow access to file URLs."

For Firefox

  1. Type about:config in the Firefox address bar and press Enter.
  2. In the search bar, enter security.fileuri.strict_origin_policy.
  3. Double-click on the entry to set it to false.
  4. Restart Firefox to apply the changes.

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. You can also refer to this issue on Dark Reader for more information.

This enhancement will provide users with an option to enjoy the ArchWiki pages in dark mode when using a browser for previewing.

Contribution

Feel free to contribute to this script by opening issues or submitting pull requests on the GitHub repository. Your contributions will be highly appreciated.

Acknowledgements

This project is made possible by the amazing 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.

Special thanks to Lahwaacz for developing and maintaining arch-wiki-docs. Your work has significantly enriched the Arch Linux experience for users like me.

Without the invaluable efforts put into arch-wiki-docs, this project wouldn't have been possible. Thank you!


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.

License

This project is licensed under the MIT License.

About

Simple Script to list archwiki in a listing menu. Depends on arch-wiki-docs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages