irongit
hygoland/scripts/RofiSearch.sh
36 lines1.1 KBBourne Again Shell (bash)
1#!/bin/bash
2# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
3# For Searching via web browsers
4
5# Define the path to the config file
6config_file=$HOME/.config/hypr/UserConfigs/01-UserDefaults.conf
7
8# Check if the config file exists
9if [[ ! -f "$config_file" ]]; then
10 echo "Error: Configuration file not found!"
11 exit 1
12fi
13
14# Process the config file in memory, removing the $ and fixing spaces
15config_content=$(sed 's/\$//g' "$config_file" | sed 's/ = /=/')
16
17# Source the modified content directly from the variable
18eval "$config_content"
19
20# Check if $term is set correctly
21if [[ -z "$Search_Engine" ]]; then
22 echo "Error: \$Search_Engine is not set in the configuration file!"
23 exit 1
24fi
25
26# Rofi theme and message
27rofi_theme="$HOME/.config/rofi/config-search.rasi"
28msg='‼️ **note** ‼️ search via default web browser'
29
30# Kill Rofi if already running before execution
31if pgrep -x "rofi" >/dev/null; then
32 pkill rofi
33fi
34
35# Open Rofi and pass the selected query to xdg-open for Google search
36echo "" | rofi -dmenu -config "$rofi_theme" -mesg "$msg" | xargs -I{} xdg-open $Search_Engine