-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extremely Improved Bookmarks (Search + Strip URL + More) #1312
Open
emrakyz
wants to merge
16
commits into
LukeSmithxyz:master
Choose a base branch
from
emrakyz:patch-4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Commits on Apr 24, 2023
-
Extremely Improved Bookmarks (Search + Strip URL + More)
The inspiration: (Luke Smith's Video): "Bookmarking for Unix Chads" Instructions & Justifications & Very Detailed Explanation for Everything can be found below. Short Summary - Allows users to manage and navigate bookmarks using dmenu. - The user can perform actions such as adding, deleting, and editing bookmarks. The script also handles searching within specific websites if the bookmarked URL has the word "search" in it. Such as the SearxNG Instance: "paulgo.io/search?q=". - One more interesting feature of it is that it modifies the order of bookmarks by their popularity (how frequently visited by you). - It can work with Dash and it has no bashisms. Execution Time: Instant Required Programs: dash (or bash) | jq | echo | grep | dmenu | notification daemon | browser | xclip (or "wl-paste" on Wayland) Instructions: These directories should exist: ~/.local/share/larbs/ 1. pacman -s jq (it's a very small program (I.E. 690kb) 2. Open a browser and highlight (xclip -o users) or copy (Wayland users) a website's URL (starting with "http") such as "https://github.com" 2. Run the script with a shortcut you created for the window manager that is used. 3. Write "@@" inside the terminal then enter (@@ can be changed of course). This opens the "Action Menu". 4. Select "Add a New Bookmark" option then enter. 5. The bookmark will be added inside the bookmarks menu. It can be edited or deleted later from the action menu that can be opened with "@@". 6. If a website that has the word "search" in it is added inside bookmarks such as a SearxNG instance "paulgo.io/search?q=" , its search function can be used. When selected, it will offer for a new prompt for the desired keywords. Justification: 1. The script uses jq for parsing and modifying JSON data, which is a lightweight and powerful command-line JSON processor. This choice allows for easy manipulation of the JSON file that stores bookmarks. 2. The use of the while loop with the dmenu interface ensures that the user can perform multiple actions (adding, deleting, or editing bookmarks) in a single session without needing to restart the script. 3. The script checks for an existing URLQUERY_FILE and initializes it with an empty JSON array "[]" if it doesn't exist or is empty. This ensures that the file is always in a valid state for the script to operate. 4. The script sorts bookmarks by popularity, allowing users to quickly access their most frequently visited bookmarks. This is achieved by incrementing a popularity value each time a bookmark is opened. 5. The script supports searching within specific websites by checking if the word "search" is in the URL (More words can be added). This feature provides a convenient way to search within bookmarked websites directly from the script. 6. The use of the dash shell (#!/bin/sh) as the interpreter provides a lightweight and fast shell environment for the script, improving performance. Since the script is efficient enough so this performance difference is not huge, so it can also be used with bash. Detailed Explanation 1. URLQUERY_FILE="~/.local/share/larbs/urlquery": Sets the path for the JSON file that will store the bookmarks. 2. The following block checks if the URLQUERY_FILE exists and if it's empty. If either condition is met, it initializes the file with an empty JSON array "[]". If there is no JSON array present, then no bookmark can be added. `if [ ! -f "$URLQUERY_FILE" ] || [ ! -s "$URLQUERY_FILE" ]; then echo "[]" > "$URLQUERY_FILE" fi` 3. ACTION_MENU='@@': Sets a special string for the action menu. 4. The read_bookmarks function reads the contents of the URLQUERY_FILE using jq. The write_bookmarks function writes the contents passed as an argument to a temporary file and then moves it to the URLQUERY_FILE. The update_bookmark_popularity function updates the popularity value of a bookmark, given its name. 5. The contains_search function checks if a given string contains the word "search". It returns 0 if it does, 1 otherwise. 6. bookmarks=$(read_bookmarks): Reads the bookmarks from the file and stores them in a variable. 7. touch "$URLQUERY_FILE": Ensures the URLQUERY_FILE exists by creating it if it doesn't. 8. The following while loop presents a menu to the user for choosing an action (Add, Delete, or Edit bookmark) or a bookmark to open. It continues until the user selects a bookmark to open or provides an empty input. `while true; do SELECTION=$(echo "$bookmarks" | jq -r '. | sort_by(.[2]) | reverse | .[] | .[0]' | rofi -dmenu -p "Bookmark") if [ -z "$SELECTION" ] || [ "$SELECTION" != "$ACTION_MENU" ]; then write_bookmarks "$bookmarks" break fi ACTION=$(echo "Add a New Bookmark\nDelete a Bookmark\nEdit a Bookmark" | rofi -dmenu -p "Action") #... done` 9. The case block inside the while loop performs the selected action (Add, Delete, or Edit) based on the user's input. 10. After the loop, the script checks if a valid bookmark is selected. If so, it updates the popularity value, writes the changes to the file, and opens the bookmark in Firefox or any browser. If the bookmark contains the word "search", it prompts the user for a search query before opening the URL in Firefox. 11. Creating and moving temporary files are for data integrity and safety. It ensures 0 file corruptions. Has no negative effect in terms of performance.
Configuration menu - View commit details
-
Copy full SHA for 943220f - Browse repository at this point
Copy the full SHA 943220fView commit details
Commits on Sep 9, 2023
-
Simplify Further | Remove if statements
1- Used logical operators instead of if statements. 2- Improved indentations and blocks for better readibility. 3- Simplified in general.
Configuration menu - View commit details
-
Copy full SHA for d3035ed - Browse repository at this point
Copy the full SHA d3035edView commit details
Commits on Oct 17, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 4854a85 - Browse repository at this point
Copy the full SHA 4854a85View commit details
Commits on Nov 18, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 083da4d - Browse repository at this point
Copy the full SHA 083da4dView commit details -
Configuration menu - View commit details
-
Copy full SHA for f51d745 - Browse repository at this point
Copy the full SHA f51d745View commit details -
Configuration menu - View commit details
-
Copy full SHA for c9ad701 - Browse repository at this point
Copy the full SHA c9ad701View commit details
Commits on Nov 19, 2023
-
Configuration menu - View commit details
-
Copy full SHA for b71e073 - Browse repository at this point
Copy the full SHA b71e073View commit details -
Configuration menu - View commit details
-
Copy full SHA for 36add3e - Browse repository at this point
Copy the full SHA 36add3eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2a5cf35 - Browse repository at this point
Copy the full SHA 2a5cf35View commit details -
Configuration menu - View commit details
-
Copy full SHA for 56304e5 - Browse repository at this point
Copy the full SHA 56304e5View commit details
Commits on Jan 5, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 5fb8b6c - Browse repository at this point
Copy the full SHA 5fb8b6cView commit details
Commits on Jan 7, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 0eaff5c - Browse repository at this point
Copy the full SHA 0eaff5cView commit details
Commits on Jun 30, 2024
-
Configuration menu - View commit details
-
Copy full SHA for fe2747d - Browse repository at this point
Copy the full SHA fe2747dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d74a86 - Browse repository at this point
Copy the full SHA 7d74a86View commit details -
Configuration menu - View commit details
-
Copy full SHA for 635ac64 - Browse repository at this point
Copy the full SHA 635ac64View commit details -
Configuration menu - View commit details
-
Copy full SHA for 787ae2c - Browse repository at this point
Copy the full SHA 787ae2cView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.