diff --git a/rofi/appmenu/rofi.rasi b/rofi/appmenu/rofi.rasi deleted file mode 100644 index 99b2106..0000000 --- a/rofi/appmenu/rofi.rasi +++ /dev/null @@ -1,151 +0,0 @@ -configuration { - font: "JetBrainsMono Nerd Font 11"; - show-icons: true; - drun-display-format: "{name}"; - fullscreen: false; - threads: 0; - matching: "fuzzy"; - scroll-method: 0; - disable-history: false; - fullscreen: true; - window-thumbnail: true; - display-drun: ""; - display-run: ""; - display-window: "缾"; -} - -* { - transparent: #00000000; - foreground: #F2F2F2EE; - background-selected: #F2F2F245; - background-active: #F2F2F230; - background-white: #F2F2F211; - background-black: #00000066; - urgent: #E91E6366; - urgent-selected: #E91E6377; -} - -window { - transparency: "real"; - background-color: @transparent; - text-color: @foreground; - location: northwest; - anchor: northwest; -} - -prompt { - enabled: false; -} - -button { - action: "ok"; - str: ""; - font: "JetBrainsMono Nerd Font 11"; - expand: false; - text-color: @foreground; - background-color: @transparent; - vertical-align: 0.7; - horizontal-align: 0.5; -} - -entry { - font: "JetBrainsMono Nerd Font 11"; - background-color: @transparent; - text-color: @foreground; - expand: true; - vertical-align: 0.5; - margin: 0 0 0 10px; - placeholder: "Type to search"; - placeholder-color: @foreground; - blink: true; -} - -case-indicator { - background-color: @transparent; - text-color: @foreground; - vertical-align: 0.5; - horizontal-align: 0.5; -} - -entry-wrapper { - orientation: horizontal; - vertical-align: 0.5; - spacing: 4px; - background-color: @transparent; - children: [ button, entry, case-indicator ]; -} - -inputbar { - background-color: @background-white; - text-color: @foreground; - expand: false; - border-radius: 6px; - margin: 0px calc((80% - 640px) / 2) 0px calc((80% - 640px) / 2); - padding: 10px 10px 10px 10px; - position: north; - children: [ entry-wrapper ]; -} - -listview { - background-color: @transparent; - columns: 6; - spacing: 5px; - cycle: false; - dynamic: true; - layout: vertical; -} - -mainbox { - background-color: @background-black; - children: [ inputbar, listview ]; - spacing: 25px; - padding: 70px 15% 0 15%; -} - -element { - background-color: @transparent; - text-color: @foreground; - orientation: vertical; - border-radius: 12px; - padding: 25px 0 25px 0; -} - -element-icon { - size: 72px; - border: 0; -} - -element-text { - expand: true; - horizontal-align: 0.5; - vertical-align: 0.5; - margin: 0 10px 0 10px; -} - -element normal.urgent, -element alternate.urgent { - background-color: @urgent; - text-color: @foreground; - border-radius: 9px; -} - -element normal.active, -element alternate.active { - background-color: @background-active; - text-color: @foreground; -} - -element selected { - background-color: @background-selected; - text-color: @foreground; -} - -element selected.urgent { - background-color: @urgent-selected; - text-color: @foreground; -} - -element selected.active { - background-color: @background-active; - color: @foreground-selected; -} diff --git a/rofi/global/icons/ddg.svg b/rofi/global/icons/ddg.svg deleted file mode 100644 index 20ea387..0000000 --- a/rofi/global/icons/ddg.svg +++ /dev/null @@ -1,615 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/rofi/global/icons/google.svg b/rofi/global/icons/google.svg deleted file mode 100644 index 21e5bf3..0000000 --- a/rofi/global/icons/google.svg +++ /dev/null @@ -1,365 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/rofi/global/icons/history.svg b/rofi/global/icons/history.svg deleted file mode 100644 index 872bac8..0000000 --- a/rofi/global/icons/history.svg +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - diff --git a/rofi/global/icons/result.svg b/rofi/global/icons/result.svg deleted file mode 100644 index 0f4d883..0000000 --- a/rofi/global/icons/result.svg +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - diff --git a/rofi/global/icons/suggestion.svg b/rofi/global/icons/suggestion.svg deleted file mode 100644 index bf67346..0000000 --- a/rofi/global/icons/suggestion.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/rofi/global/rofi-spotlight.sh b/rofi/global/rofi-spotlight.sh deleted file mode 100755 index d5c4a23..0000000 --- a/rofi/global/rofi-spotlight.sh +++ /dev/null @@ -1,692 +0,0 @@ -#!/usr/bin/env bash - -TMP_DIR="/tmp/rofi/${USER}/" - -PREV_LOC_FILE="${TMP_DIR}rofi_fb_prevloc" -CURRENT_FILE="${TMP_DIR}rofi_fb_current_file" - -MY_PATH="$(realpath "$0" | xargs dirname)" -HIST_FILE="${MY_PATH}/history.txt" - -OPENER=xdg-open -TERM_EMU=kitty -TEXT_EDITOR=$EDITOR -FILE_MANAGER=xdg-open -BLUETOOTH_SEND=blueman-sendto - -CUR_DIR=$PWD -NEXT_DIR="" -FD_INSTALLED=$(command -v fd) - -SHOW_HIDDEN=false - -# Setup menu options -declare -a OPEN_FILE_LOCATION=( - "Open file location in ${TERM_EMU}" - "Open file location in ${FILE_MANAGER}" -) -declare -a RUN_COMMANDS=( - "Run" - "Execute in ${TERM_EMU}" -) -declare -a STANDARD_CONTROLS=( - "Move to trash" - "Delete" - "Back" -) -declare -a SHELL_NO_X_OPTIONS=( - "Edit" - "${OPEN_FILE_LOCATION[@]}" - "${STANDARD_CONTROLS[@]}" -) -declare -a SHELL_OPTIONS=( - "${RUN_COMMANDS[@]}" - "${SHELL_NO_X_OPTIONS[@]}" -) -declare -a BIN_NO_X_OPTIONS=( - "${OPEN_FILE_LOCATION[@]}" - "Back" -) -declare -a BIN_OPTIONS=( - "${RUN_COMMANDS[@]}" - "${BIN_NO_X_OPTIONS[@]}" -) -declare -a TEXT_OPTIONS=("${SHELL_NO_X_OPTIONS[@]}") -declare -a HTML_OPTIONS=( - "Open" - "Edit" - "${OPEN_FILE_LOCATION[@]}" - "${STANDARD_CONTROLS[@]}" -) -declare -a XCF_SVG_OPTIONS=( - "Open" - "${OPEN_FILE_LOCATION[@]}" - "${STANDARD_CONTROLS[@]}" -) -declare -a IMAGE_OPTIONS=( - "Open" - "Send via Bluetooth" - "${OPEN_FILE_LOCATION[@]}" - "${STANDARD_CONTROLS[@]}" -) - -declare -a ALL_OPTIONS=() - -# Combine all context menu -COMBINED_OPTIONS=( - "${SHELL_OPTIONS[@]}" - "${IMAGE_OPTIONS[@]}" -) - -# Remove duplicates -ALL_OPTIONS=("$(printf '%s\n' "${COMBINED_OPTIONS[@]}" | sort -u)") - -# Create tmp dir for rofi -[ ! -d "${TMP_DIR}" ] && mkdir -p "${TMP_DIR}"; - -# Create hist file if it doesn't exist -[ ! -f "${HIST_FILE}" ] && touch "${HIST_FILE}" - -# Help message -if [ -n "$*" ] && [[ "$*" = ":help" ]] -then - echo -en "Rofi Spotlight -A Rofi with file and web searching functionality - -Commands: -:help to print this help message -:h or :hidden to show hidden files/dirs -:sh or :show_hist to show search history -:ch or :clear_hist to clear search history -:xdg to jump to an xdg directory -Examples: - :xdg DOCUMENTS - :xdg DOWNLOADS -Also supports incomplete path: -Examples: - :xdg doc - :xdg down -For more info about XDG dirs, see: -\`man xdg-user-dir\` - -File search syntaxes: -! to search for a file and web suggestions -? to search parent directories -Examples: - !half-life 3 - ?portal 3 - -Web search syntaxes: -! to gets search suggestions -:web/:w to also to gets search suggestions -:webbro/:wb to search directly from your browser -Examples: - !how to install archlinux - :web how to install gentoo - :w how to make a nuclear fission - :webbro how to install wine in windowsxp -Back\0icon\x1fdraw-arrow-back\n" - - exit -fi - -# Return the icon string -function icon_file_type(){ - icon_name="" - mime_type=$(file --mime-type -b "${1}") - - case "${mime_type}" in - "inode/directory") - case "${1}" in - "Desktop/" ) - icon_name='folder-blue-desktop' - ;; - "Documents/" ) - icon_name='folder-blue-documents' - ;; - "Downloads/" ) - icon_name='folder-blue-downloads' - ;; - "Music/" ) - icon_name='folder-blue-music' - ;; - "Pictures/" ) - icon_name='folder-blue-pictures' - ;; - "Public/" ) - icon_name='folder-blue-public' - ;; - "Templates/" ) - icon_name='folder-blue-templates' - ;; - "Videos/" ) - icon_name='folder-blue-videos' - ;; - "root/" ) - icon_name='folder-root' - ;; - "home/" | "${USER}/") - icon_name='folder-home' - ;; - *"$" ) - icon_name='folder-blue' - ;; - *) - icon_name='folder-blue' - ;; - esac - ;; - "inode/symlink" ) - icon_name='inode-symlink' - ;; - "audio/flac" | "audio/mpeg" ) - icon_name='music' - ;; - "video/mp4" ) - icon_name='video-mp4' - ;; - "video/x-matroska" ) - icon_name=video-x-matroska - ;; - "image/x-xcf" ) - # notify-send '123' - icon_name='image-x-xcf' - ;; - "image/jpeg" | "image/png" | "image/svg+xml") - icon_name="${CUR_DIR}/${1}" - ;; - "image/gif" ) - icon_name='gif' - ;; - "image/vnd.adobe.photoshop" ) - icon_name='image-vnd.adobe.photoshop' - ;; - "image/webp" ) - icon_name='gif' - ;; - "application/x-pie-executable" ) - icon_name='binary' - ;; - "application/pdf" ) - icon_name='pdf' - ;; - "application/zip" ) - icon_name='application-zip' - ;; - "application/x-xz" ) - icon_name='application-x-xz-compressed-tar' - ;; - "application/x-7z-compressed" ) - icon_name='application-x-7zip' - ;; - "application/x-rar" ) - icon_name='application-x-rar' - ;; - "application/octet-stream" | "application/x-iso9660-image" ) - icon_name='application-x-iso' - ;; - "application/x-dosexec" ) - icon_name='application-x-ms-dos-executable' - ;; - "text/plain" ) - icon_name='application-text' - ;; - "text/x-shellscript" ) - icon_name='application-x-shellscript' - ;; - "text/html" ) - icon_name='text-html' - ;; - "font/sfnt" | "application/vnd.ms-opentype" ) - icon_name='application-x-font-ttf' - ;; - * ) - case "${1}" in - *."docx" | *".doc" ) - icon_name='application-msword' - ;; - *."apk" ) - icon_name='android-package-archive' - ;; - * ) - icon_name='unknown' - ;; - esac - ;; - esac - - echo -en "$1\0icon\x1f$icon_name\n" -} - -export -f icon_file_type - -# Pass the argument to python script -function web_search() { - # Pass the search query to web-search script - "${MY_PATH}/web-search.py" "${1}" - exit; -} - -# Handles the web search method -if [ ! -z "$@" ] && ([[ "$@" == ":webbro"* ]] || [[ "$@" == ":wb"* ]]) -then - remove='' - [[ "$*" = ":webbro"* ]] && remove=":webbro" || remove=":wb" - - # Search directly from your web browser - web_search "$(printf '%s\n' "${1//$remove/}")" - exit; - -elif [ ! -z "$@" ] && ([[ "$@" == ":web"* ]] || [[ "$@" == ":w"* ]]) -then - remove='' - [[ "$*" = ":web"* ]] && remove=":web" || remove=":w" - - # Get search suggestions - web_search "!$(printf '%s\n' "${1//$remove/}")" - exit; -fi - -function find_query() { - QUERY=${1} - if [[ ! "${QUERY}" =~ ( |\') ]] - then - if [ -z "$FD_INSTALLED" ]; - then - find "${HOME}" -iname *"${QUERY}"* | sed "s/\/home\/$USER/\~/" | - awk -v MY_PATH="${MY_PATH}" '{print $0"\0icon\x1f"MY_PATH"/icons/result.svg\n"}' - else - fd -H ${QUERY} ${HOME} | sed "s/\/home\/$USER/\~/" | - awk -v MY_PATH="${MY_PATH}" '{print $0"\0icon\x1f"MY_PATH"/icons/result.svg\n"}' - fi - fi -} - -# File and calls to the web search -if [ ! -z "$@" ] && ([[ "$@" == ?(\~)/* ]] || [[ "$@" == \?* ]] || [[ "$@" == \!* ]]) -then - QUERY=$@ - - echo "${QUERY}" >> "${HIST_FILE}" - - if [[ "$@" == ?(\~)/* ]] - then - [[ "$*" = \~* ]] && QUERY="${QUERY//"~"/"$HOME"}" - - coproc ${OPENER} "${QUERY}" > /dev/null 2>&1 - exec 1>&- - exit - - elif [[ "$@" == \?* ]] - then - find_query ${QUERY#\?} - - else - # Find the file - find_query ${QUERY#!} - - # Web search - web_search "! ${QUERY#!}" - fi - exit; -fi - -# Create notification if there's an error -function create_notification() { - case "${1}" in - "denied" ) - notify-send -a "Global Search" "Permission denied!" \ - 'You have no permission to access '"${CUR_DIR}!" - ;; - "deleted" ) - notify-send -a "Global Search" "Success!" \ - 'File deleted!' - ;; - "trashed" ) - notify-send -a "Global Search" "Success!" \ - 'The file has been moved to trash!' - ;; - "cleared" ) - notify-send -a "Global Search" "Success!" \ - 'Search history has been successfully cleared!' - ;; - * ) - notify-send -a "Global Search" "Somethings wrong I can feel it!" \ - 'This incident will be reported!' - ;; - esac -} - -# Show the files in the current directory -function navigate_to() { - # process current dir. - if [ -n "${CUR_DIR}" ] - then - CUR_DIR=$(readlink -e "${CUR_DIR}") - if [ ! -d "${CUR_DIR}" ] || [ ! -r "${CUR_DIR}" ] - then - create_notification "denied" - CUR_DIR=$(realpath ${CUR_DIR} | xargs dirname) - echo "${CUR_DIR}" > "${PREV_LOC_FILE}" - else - echo "${CUR_DIR}/" > "${PREV_LOC_FILE}" - fi - pushd "${CUR_DIR}" >/dev/null || exit - fi - - printf "..\0icon\x1fup\n" - - if [[ -z "$FD_INSTALLED" ]] - then - #Group directories - if [[ ${SHOW_HIDDEN} == true ]] - then - for i in .*/ - do - [[ -d "${i}" ]] && ([[ "${i}" != "./" ]] && [[ "${i}" != "../"* ]]) && icon_file_type "${i}" - done - fi - for i in */ - do - [[ -d "${i}" ]] && icon_file_type "${i}" - done - #Group files - if [[ ${SHOW_HIDDEN} = true ]] - then - for i in .* - do - [[ -f "${i}" ]] && icon_file_type "${i}" - done - fi - for i in * - do - [[ -f "${i}" ]] && icon_file_type "${i}" - done - else - THREADS=$(getconf _NPROCESSORS_ONLN) - export CUR_DIR - if [[ ${SHOW_HIDDEN} == true ]] - then - fd -Ht d -d 1 -x bash -c 'icon_file_type "$1/"' _ {} \ | sort -V --parallel=$THREADS - fd -Ht f -d 1 -x bash -c 'icon_file_type "$1"' _ {} \ | sort -V --parallel=$THREADS - else - fd -t d -d 1 -x bash -c 'icon_file_type "$1/"' _ {} \ | sort -V --parallel=$THREADS - fd -t f -d 1 -x bash -c 'icon_file_type "$1"' _ {} \ | sort -V --parallel=$THREADS - fi - fi -} - -# Set XDG dir -function return_xdg_dir() { - target_dir=${1^^} - - if [[ "HOME" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir) - - elif [[ "DESKTOP" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir DESKTOP) - - elif [[ "DOCUMENTS" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir DOCUMENTS) - - elif [[ "DOWNLOADS" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir DOWNLOAD) - - elif [[ "MUSIC" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir MUSIC) - - elif [[ "PICTURES" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir PICTURES) - - elif [[ "PUBLICSHARE" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir PUBLICSHARE) - - elif [[ "TEMPLATES" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir TEMPLATES) - - elif [[ "VIDEOS" == *"${target_dir}"* ]] - then - CUR_DIR=$(xdg-user-dir VIDEOS) - - elif [[ "ROOT" == *"${target_dir}"* ]] - then - CUR_DIR="/" - - else - CUR_DIR="${HOME}" - fi - navigate_to - exit; -} - -# Show and Clear History -if [ ! -z "$@" ] && ([[ "$@" == ":sh" ]] || [[ "$@" == ":show_hist" ]]) -then - hist=$(tac "${HIST_FILE}") - - echo -en "Back\0icon\x1fdraw-arrow-back\n" - [ -z "${hist}" ] && echo -en "No History Yet\0icon\x1ftext-plain\n" - - while IFS= read -r line; - do - echo -en "${line}\0icon\x1f${MY_PATH}/icons/history.svg\n"; - done <<< "${hist}" - - exit; -elif [ ! -z "$@" ] && ([[ "$@" == ":ch" ]] || [[ "$@" == ":clear_hist" ]]) -then - :> "${HIST_FILE}" - create_notification "cleared" - - CUR_DIR="${HOME}" - navigate_to - exit; -fi - -# Accepts XDG command -if [[ ! -z "$@" ]] && [[ "$@" == ":xdg"* ]] -then - NEXT_DIR=${*//":xdg "/} - - [[ -n "$NEXT_DIR" ]] && return_xdg_dir "${NEXT_DIR}" || return_xdg_dir "${HOME}" -fi - -# Read last location, otherwise we default to PWD. -[ -f "${PREV_LOC_FILE}" ] && CUR_DIR=$(< "${PREV_LOC_FILE}") - -if [[ ! -z "$@" ]] && ([[ "$@" == ":h" ]] || [[ "$@" == ":hidden" ]]) -then - SHOW_HIDDEN=true - navigate_to - exit; -fi - -# Handle argument. -[ -n "$*" ] && CUR_DIR="${CUR_DIR}/$*" - -# Context Menu -if [ -n "$*" ] && [[ "${ALL_OPTIONS[*]} " = *"$*"* ]] -then - case "${1}" in - "Run" ) - coproc ( eval "$(< ${CURRENT_FILE})" & > /dev/null 2>&1 ) - kill -9 $(pgrep rofi) - ;; - "Execute in ${TERM_EMU}" ) - coproc ( eval "${TERM_EMU} \"$(< ${CURRENT_FILE})\"" & > /dev/null 2>&1 ) - kill -9 $(pgrep rofi) - ;; - "Open" ) - coproc ( eval "${OPENER} \"$(< ${CURRENT_FILE})\"" & > /dev/null 2>&1 ) - kill -9 $(pgrep rofi) - ;; - "Open file location in ${TERM_EMU}" ) - file_path="$(< ${CURRENT_FILE})" - coproc ( ${TERM_EMU} bash -c "cd ${file_path%/*} ; ${SHELL}" & > /dev/null 2>&1 ) - kill -9 $(pgrep rofi) - ;; - "Open file location in ${FILE_MANAGER}" ) - file_path="$(< "${CURRENT_FILE}")" - coproc ( eval "${FILE_MANAGER} "${file_path%/*}"" & > /dev/null 2>&1 ) - kill -9 $(pgrep rofi) - ;; - "Edit" ) - coproc ( eval "${TERM_EMU} ${TEXT_EDITOR} \"$(< ${CURRENT_FILE})\"" & > /dev/null 2>&1 ) - kill -9 $(pgrep rofi) - ;; - "Move to trash" ) - coproc( gio trash "$(< ${CURRENT_FILE})" & > /dev/null 2>&1 ) - create_notification "trashed" - CUR_DIR="$(dirname "$(< ${CURRENT_FILE})")" - navigate_to - ;; - "Delete" ) - shred "$(< ${CURRENT_FILE})" - rm "$(< ${CURRENT_FILE})" - create_notification "deleted" - CUR_DIR="$(dirname "$(< ${CURRENT_FILE})")" - navigate_to - ;; - "Send via Bluetooth" ) - rfkill unblock bluetooth && bluetoothctl power on - sleep 1 - blueman-sendto "$(< ${CURRENT_FILE})" & > /dev/null 2>&1 - kill -9 $(pgrep rofi) - ;; - "Back" ) - CUR_DIR="$(< ${PREV_LOC_FILE})" - navigate_to - ;; - esac - exit; -fi - -function context_menu_icons() { - - if [[ "${1}" == "Run" ]] - then - echo '\0icon\x1fsystem-run\n' - - elif [[ "${1}" == "Execute in ${TERM_EMU}" ]] - then - echo "\0icon\x1f${TERM_EMU}\n" - - elif [[ "${1}" == "Open" ]] - then - echo "\0icon\x1futilities-x-terminal\n" - - elif [[ "${1}" == "Open file location in ${TERM_EMU}" ]] - then - echo "\0icon\x1f${TERM_EMU}\n" - - elif [[ "${1}" == "Open file location in ${FILE_MANAGER}" ]] - then - echo "\0icon\x1fblue-folder-open\n" - - elif [[ "${1}" == "Edit" ]] - then - echo "\0icon\x1faccessories-text-editor\n" - - elif [[ "${1}" == "Move to trash" ]] - then - echo "\0icon\x1fapplication-x-trash\n" - - elif [[ "${1}" == "Delete" ]] - then - echo "\0icon\x1findicator-trashindicator\n" - - elif [[ "${1}" == "Send via Bluetooth" ]] - then - echo "\0icon\x1fbluetooth\n" - - elif [[ "${1}" == "Back" ]] - then - echo "\0icon\x1fback\n" - fi -} - -function print_context_menu() { - declare -a arg_arr=("${!1}") - - for menu in "${arg_arr[@]}" - do - printf "$menu$(context_menu_icons "${menu}")\n" - done -} - -function context_menu() { - - type="$(file --mime-type -b "${CUR_DIR}")" - - if [ -w "${CUR_DIR}" ] && [[ "${type}" == "text/x-shellscript" ]] - then - if [ -x "${CUR_DIR}" ]; - then - print_context_menu SHELL_OPTIONS[@] - else - print_context_menu SHELL_NO_X_OPTIONS[@] - fi - - elif [[ "${type}" == "application/x-executable" ]] || [[ "${type}" == "application/x-pie-executable" ]] - then - if [ -x "${CUR_DIR}" ] - then - print_context_menu BIN_OPTIONS[@] - else - print_context_menu BIN_NO_X_OPTIONS[@] - fi - - elif [[ "${type}" == "text/plain" ]] - then - print_context_menu TEXT_OPTIONS[@] - - elif [[ "${type}" == "text/html" ]] - then - print_context_menu HTML_OPTIONS[@] - - elif [[ "${type}" == "image/jpeg" ]] || [[ "${type}" == "image/png" ]] - then - print_context_menu IMAGE_OPTIONS[@] - - elif [[ "${type}" == "image/x-xcf" ]] || [[ "${type}" == "image/svg+xml" ]] - then - print_context_menu XCF_SVG_OPTIONS[@] - - elif [ ! -w "${CUR_DIR}" ] && [[ "${type}" == "text/x-shellscript" ]] - then - coproc ( exec "${CUR_DIR}" & > /dev/null 2>&1 ) - - else - if [ ! -d "${CUR_DIR}" ] && [ ! -f "${CUR_DIR}" ] - then - QUERY="${CUR_DIR//*\/\//}" - - echo "${QUERY}" >> "${HIST_FILE}" - - find_query "${QUERY#!}" - - web_search "!${QUERY}" - else - coproc ( ${OPENER} "${CUR_DIR}" & > /dev/null 2>&1 ) - fi - fi - exit; -} - -# If argument is not a directory/folder -if [ ! -d "${CUR_DIR}" ] -then - echo "${CUR_DIR}" > "${CURRENT_FILE}" - context_menu - exit; -fi - -navigate_to diff --git a/rofi/global/rofi.rasi b/rofi/global/rofi.rasi deleted file mode 100644 index d14ecd2..0000000 --- a/rofi/global/rofi.rasi +++ /dev/null @@ -1,157 +0,0 @@ -configuration { - font: "Inter Regular 10"; - sidebar-mode: true; - show-icons: true; - fullscreen: false; - threads: 0; - matching: "fuzzy"; - scroll-method: 0; - monitor: "primary"; -} - -* { - transparent: #00000000; - foreground: #F2F2F2EE; - background-selected: #F2F2F245; - background-active: #F2F2F230; - background-white: #F2F2F211; - background-black: #00000000; - urgent: #E91E6366; - urgent-selected: #E91E6377; -} - -window { - transparency: "real"; - background-color: @transparent; - text-color: @foreground; - location: west; - anchor: west; - x-offset: 0; - height: 100%; - width: 350px; - orientation: vertical; -} - -prompt { - enabled: false; -} - -button { - action: "ok"; - str: " "; - font: "FantasqueSansMono Nerd Font 16"; - expand: false; - text-color: @foreground; - background-color: @transparent; - vertical-align: 0.5; - horizontal-align: 0.5; -} - -entry { - font: "Inter Regular 12"; - background-color: @transparent; - text-color: @foreground; - expand: true; - vertical-align: 0.5; - horizontal-align: 0; - placeholder: "Global Search"; - placeholder-color: @foreground; - blink: true; -} - -entry-wrapper { - orientation: horizontal; - margin: 0 12px 0 12px; - spacing: 24px; - vertical-align: 0.5; - background-color: @transparent; - children: [ button, entry ]; -} - -inputbar { - padding: 14px; - margin: 10px 10px 14px 10px; - background-color: @background-white; - text-color: @foreground; - expand: false; - border-radius: 9px; - position: north; - children: [ entry-wrapper ]; -} - -listview { - background-color: @transparent; - spacing: 0; - cycle: true; - dynamic: true; - scrollbar: true; -} - -mainbox { - width: 200px; - expand: true; - spacing: 12px; - padding: 5px; - background-color: @background-black; - children: [ inputbar, listview ]; -} - -scrollbar { - background-color: @background-white; - handle-width: 0; - margin: 0 0 5px 0; - border-radius: 9px; -} - -element { - background-color: @transparent; - text-color: @foreground; - orientation: horizontal; - border: 0; - border-color: @background-white; - border-radius: 6px; - spacing: 24px; - margin: 0px 12px 0px 12px; - padding: 10px 24px 10px 24px; -} - -element-icon { - size: 24px; - border: 0; - border-color: @transparent; -} - -element-text { - font: "Inter Regular 11"; - expand: true; - horizontal-align: 0; - vertical-align: 0.5; -} - -element normal.urgent, -element alternate.urgent { - background-color: @urgent; - text-color: @foreground; - border-radius: 9px; -} - -element normal.active, -element alternate.active { - background-color: @background-active; - text-color: @foreground; -} - -element selected { - background-color: @background-selected; - text-color: @foreground; -} - -element selected.urgent { - background-color: @urgent-selected; - text-color: @foreground; -} - -element selected.active { - background-color: @background-active; - color: @foreground-selected; -} diff --git a/rofi/global/web-search.py b/rofi/global/web-search.py deleted file mode 100755 index ba314d5..0000000 --- a/rofi/global/web-search.py +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/env python3 - -# MIT License - -# Copyright (c) 2019 Paolo Donadeo - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - -import json -import re -import urllib.parse -import urllib.request -import sys -import os -import datetime -import gzip - -import subprocess as sp - -import html - - -################################################################################ -##### C O N F I G U R A T I O N ###### -################################################################################ -SEARCH_ENGINE = 'google' # or 'duckduckgo' -BROWSER = 'firefox' # or 'firefox', 'chromium', 'brave', 'lynx' -TERMINAL = ['kitty', '--'] # or ['st', '-e'] or something like that -################################################################################ - -CONFIG = { - 'BROWSER_PATH' : { - 'chrome' : ['google-chrome-stable'], - 'firefox' : ['firefox'], - 'chromium' : ['chromium-browser'], - 'brave' : ['brave-browser'], - 'lynx' : TERMINAL + ['lynx'] - }, - 'USER_AGENT' : { - 'chrome' : 'Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', - 'firefox' : 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0', - 'chromium' : 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/76.0.3809.100 Chrome/76.0.3809.100 Safari/537.36', - 'brave' : 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36', - 'lynx' : 'Lynx/2.8.9rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/1.1.1d' - }, - 'SEARCH_ENGINE_NAME' : { - 'google' : 'Google', - 'duckduckgo' : 'DuckDuckGo' - }, - 'SEARCH_URL' : { - 'google' : 'https://www.google.com/search?q=', - 'duckduckgo' : 'https://duckduckgo.com/?q=' - }, - 'SUGGESTION_URL' : { - 'google' : 'https://www.google.com/complete/search?', - 'duckduckgo' : 'https://duckduckgo.com/ac/?' - } -} - -def cleanhtml(txt): - return re.sub(r'<.*?>', '', txt) - -def fetch_suggestions(search_string): - if SEARCH_ENGINE == 'google': - r = { - 'q' : search_string, - 'cp' : '11', - 'client' : 'psy-ab', - 'xssi' : 't', - 'gs_ri' : 'gws-wiz', - 'hl' : 'en-IT', - 'authuser' : '0' - } - url = CONFIG['SUGGESTION_URL'][SEARCH_ENGINE] + urllib.parse.urlencode(r) - headers = { - 'sec-fetch-mode' : 'cors', - 'dnt' : '1', - 'accept-encoding' : 'gzip', - 'accept-language' : 'en-US;q=0.9,en;q=0.8', - 'pragma' : 'no-cache', - 'user-agent' : CONFIG['USER_AGENT'][BROWSER], - 'accept' : '*/*', - 'cache-control' : 'no-cache', - 'authority' : 'www.google.com', - 'referer' : 'https://www.google.com/', - 'sec-fetch-site' : 'same-origin' - } - req = urllib.request.Request(url, headers=headers, method='GET') - - reply_data = gzip.decompress(urllib.request.urlopen(req).read()).split(b'\n')[1] - reply_data = json.loads(reply_data) - return [ cleanhtml(res[0]).strip() for res in reply_data[0] ] - else: # 'duckduckgo' - if search_string.startswith('!'): - bang_search = True - search_string = search_string.lstrip('!') - else: - bang_search = False - r = { - 'q' : search_string, - 'callback' : 'autocompleteCallback', - 'kl' : 'wt-wt', - '_' : str(int((datetime.datetime.now().timestamp())*1000)) - } - url = CONFIG['SUGGESTION_URL'][SEARCH_ENGINE] + urllib.parse.urlencode(r) - if bang_search: - url = url.replace('?q=', '?q=!') - headers = { - 'pragma' : 'no-cache', - 'dnt' : '1', - 'accept-encoding' : 'gzip', - 'accept-language' : 'en-US;q=0.9,en;q=0.8', - 'user-agent' : CONFIG['USER_AGENT'][BROWSER], - 'sec-fetch-mode' : 'no-cors', - 'accept' : '*/*', - 'cache-control' : 'no-cache', - 'authority' : 'duckduckgo.com', - 'referer' : 'https://duckduckgo.com/', - 'sec-fetch-site' : 'same-origin', - } - req = urllib.request.Request(url, headers=headers, method='GET') - reply_data = gzip.decompress(urllib.request.urlopen(req).read()).decode('utf8') - reply_data = json.loads(re.match(r'autocompleteCallback\((.*)\);', reply_data).group(1)) - return [ cleanhtml(res['phrase']).strip() for res in reply_data ] - -def main(): - search_string = html.unescape((' '.join(sys.argv[1:])).strip()) - - path_str = os.path.dirname(os.path.realpath(__file__)) + '/' - icon_path_str = path_str + 'icons/' - icon_name = icon_path_str - - if SEARCH_ENGINE == 'google': - icon_name += 'google.svg' - else: - icon_name += 'ddg.svg' - - if search_string.startswith('!'): - search_string = search_string.rstrip('!').strip() - results = fetch_suggestions(search_string) - for r in results: - print(":wb " + html.unescape(r) + "\0icon\x1f"+icon_name+"\n") - else: - url = CONFIG['SEARCH_URL'][SEARCH_ENGINE] + urllib.parse.quote_plus(search_string) - sp.Popen(CONFIG['BROWSER_PATH'][BROWSER] + [url], stdout=sp.DEVNULL, stderr=sp.DEVNULL, shell=False) - -if __name__ == "__main__": - try: - main() - except Exception as e: - if e: - sys.exit(1) diff --git a/rofi/powermenu/powermenu.rasi b/rofi/powermenu/powermenu.rasi deleted file mode 100644 index 41fc910..0000000 --- a/rofi/powermenu/powermenu.rasi +++ /dev/null @@ -1,93 +0,0 @@ -configuration { - font: "JetBrainsMono Nerd Font 36"; - drun-display-format: "{name}"; - fullscreen: false; - threads: 0; - matching: "fuzzy"; - scroll-method: 0; - disable-history: false; - fullscreen: true; -} - -* { - transparent: #00000000; - foreground: #F2F2F2EE; - background-selected: #F2F2F245; - background-active: #F2F2F230; - background-white: #F2F2F211; - background-black: #00000066; - urgent: #E91E6366; - urgent-selected: #E91E6377; -} - -window { - transparency: "real"; - background-color: @transparent; - text-color: @foreground; - location: northwest; - anchor: northwest; -} - -inputbar { - margin: 0; - padding: 0; - children: [ entry-wrapper ]; -} - -listview { - background-color: @transparent; - lines: 6; - spacing: 5%; - cycle: false; - dynamic: true; - layout: horizontal; -} - -mainbox { - background-color: @background-black; - children: [ inputbar, listview ]; - padding: calc(50% - 70px) 0% 0% 15%; -} - -element { - background-color: @transparent; - text-color: @foreground; - orientation: horizontal; - border-radius: 10px; - padding: 30px; - vertical: 0.5; -} - -element-text { - expand: true; - horizontal-align: 0.5; - vertical-align: 0.5; -} - -element normal.urgent, -element alternate.urgent { - background-color: @urgent; - text-color: @foreground; - border-radius: 9px; -} - -element normal.active, -element alternate.active { - background-color: @background-active; - text-color: @foreground; -} - -element selected { - background-color: #29B6F6; - text-color: #212121; -} - -element selected.urgent { - background-color: @urgent-selected; - text-color: @foreground; -} - -element selected.active { - background-color: @background-active; - color: @foreground-selected; -} diff --git a/rofi/rofi-power-menu b/rofi/rofi-power-menu deleted file mode 100755 index 1c6725b..0000000 --- a/rofi/rofi-power-menu +++ /dev/null @@ -1,246 +0,0 @@ -#!/usr/bin/env bash - -# This script defines just a mode for rofi instead of being a self-contained -# executable that launches rofi by itself. This makes it more flexible than -# running rofi inside this script as now the user can call rofi as one pleases. -# For instance: -# -# rofi -show powermenu -modi powermenu:./rofi-power-menu -# -# See README.md for more information. - -set -e -set -u - -# All supported choices -all=(shutdown reboot suspend hibernate logout lockscreen) - -# By default, show all (i.e., just copy the array) -show=("${all[@]}") - -declare -A texts -texts[lockscreen]="lock screen" -texts[switchuser]="switch user" -texts[logout]="log out" -texts[suspend]="suspend" -texts[hibernate]="hibernate" -texts[reboot]="reboot" -texts[shutdown]="shut down" - -declare -A icons -icons[lockscreen]="\uf023" -icons[switchuser]="\uf518" -icons[logout]="\uf842" -icons[suspend]="\uf9b1" -icons[hibernate]="\uf7c9" -icons[reboot]="\ufc07" -icons[shutdown]="\uf011" -icons[cancel]="\u00d7" - -declare -A actions -actions[lockscreen]="dm-tool lock" -#actions[switchuser]="???" -actions[logout]="loginctl terminate-session ${XDG_SESSION_ID-}" -actions[suspend]="systemctl suspend" -actions[hibernate]="systemctl hibernate" -actions[reboot]="systemctl reboot" -actions[shutdown]="systemctl poweroff" - -# By default, ask for confirmation for actions that are irreversible -confirmations=(reboot shutdown logout) - -# By default, no dry run -dryrun=false -showsymbols=true - -function check_valid { - option="$1" - shift 1 - for entry in "${@}" - do - if [ -z "${actions[$entry]+x}" ] - then - echo "Invalid choice in $1: $entry" >&2 - exit 1 - fi - done -} - -# Parse command-line options -parsed=$(getopt --options=h --longoptions=help,dry-run,confirm:,choices:,choose:,symbols,no-symbols --name "$0" -- "$@") -if [ $? -ne 0 ]; then - echo 'Terminating...' >&2 - exit 1 -fi -eval set -- "$parsed" -unset parsed -while true; do - case "$1" in - "-h"|"--help") - echo "rofi-power-menu - a power menu mode for Rofi" - echo - echo "Usage: rofi-power-menu [--choices CHOICES] [--confirm CHOICES]" - echo " [--choose CHOICE] [--dry-run] [--symbols|--no-symbols]" - echo - echo "Use with Rofi in script mode. For instance, to ask for shutdown or reboot:" - echo - echo " rofi -show menu -modi \"menu:rofi-power-menu --choices=shutdown/reboot\"" - echo - echo "Available options:" - echo " --dry-run Don't perform the selected action but print it to stderr." - echo " --choices CHOICES Show only the selected choices in the given order. Use / " - echo " as the separator. Available choices are lockscreen, logout," - echo " suspend, hibernate, reboot and shutdown. By default, all" - echo " available choices are shown." - echo " --confirm CHOICES Require confirmation for the gives choices only. Use / as" - echo " the separator. Available choices are lockscreen, logout," - echo " suspend, hibernate, reboot and shutdown. By default, only" - echo " irreversible actions logout, reboot and shutdown require" - echo " confirmation." - echo " --choose CHOICE Preselect the given choice and only ask for a confirmation" - echo " (if confirmation is set to be requested). It is strongly" - echo " recommended to combine this option with --confirm=CHOICE" - echo " if the choice wouldn't require confirmation by default." - echo " Available choices are lockscreen, logout, suspend," - echo " hibernate, reboot and shutdown." - echo " --[no-]symbols Show Unicode symbols or not. Requires a font with support" - echo " for the symbols. Use, for instance, fonts from the" - echo " Nerdfonts collection. By default, they are shown" - echo " -h,--help Show this help text." - exit 0 - ;; - "--dry-run") - dryrun=true - shift 1 - ;; - "--confirm") - IFS='/' read -ra confirmations <<< "$2" - check_valid "$1" "${confirmations[@]}" - shift 2 - ;; - "--choices") - IFS='/' read -ra show <<< "$2" - check_valid "$1" "${show[@]}" - shift 2 - ;; - "--choose") - # Check that the choice is valid - check_valid "$1" "$2" - selectionID="$2" - shift 2 - ;; - "--symbols") - showsymbols=true - shift 1 - ;; - "--no-symbols") - showsymbols=false - shift 1 - ;; - "--") - shift - break - ;; - *) - echo "Internal error" >&2 - exit 1 - ;; - esac -done - -# Define the messages after parsing the CLI options so that it is possible to -# configure them in the future. - -function write_message { - icon="$1" - text="$2" - if [ "$showsymbols" = "true" ] - then - echo -n "\u200e$icon \u2068$text\u2069" - else - echo -n "$text" - fi -} - -function print_selection { - echo -e "$1" | $(read -r -d '' entry; echo "echo $entry") -} - -declare -A messages -declare -A confirmationMessages -for entry in "${all[@]}" -do - messages[$entry]=$(write_message "${icons[$entry]}" "${texts[$entry]^}") -done -for entry in "${all[@]}" -do - confirmationMessages[$entry]=$(write_message "${icons[$entry]}" "Yes, ${texts[$entry]}") -done -confirmationMessages[cancel]=$(write_message "${icons[cancel]}" "No, cancel") - -if [ $# -gt 0 ] -then - # If arguments given, use those as the selection - selection="${@}" -else - # Otherwise, use the CLI passed choice if given - if [ -n "${selectionID+x}" ] - then - selection="${messages[$selectionID]}" - fi -fi - -# Don't allow custom entries -echo -e "\0no-custom\x1ftrue" -# Use markup -echo -e "\0markup-rows\x1ftrue" - -if [ -z "${selection+x}" ] -then - echo -e "\0prompt\x1fPower menu" - for entry in "${show[@]}" - do - echo -e "${messages[$entry]}\0icon\x1f${icons[$entry]}" - done -else - for entry in "${show[@]}" - do - if [ "$selection" = "$(print_selection "${messages[$entry]}")" ] - then - # Check if the selected entry is listed in confirmation requirements - for confirmation in "${confirmations[@]}" - do - if [ "$entry" = "$confirmation" ] - then - # Ask for confirmation - echo -e "\0prompt\x1fAre you sure" - echo -e "${confirmationMessages[$entry]}\0icon\x1f${icons[$entry]}" - echo -e "${confirmationMessages[cancel]}\0icon\x1f${icons[cancel]}" - exit 0 - fi - done - # If not, then no confirmation is required, so mark confirmed - selection=$(print_selection "${confirmationMessages[$entry]}") - fi - if [ "$selection" = "$(print_selection "${confirmationMessages[$entry]}")" ] - then - if [ $dryrun = true ] - then - # Tell what would have been done - echo "Selected: $entry" >&2 - else - # Perform the action - ${actions[$entry]} - fi - exit 0 - fi - if [ "$selection" = "$(print_selection "${confirmationMessages[cancel]}")" ] - then - # Do nothing - exit 0 - fi - done - # The selection didn't match anything, so raise an error - echo "Invalid selection: $selection" >&2 - exit 1 -fi diff --git a/rofi/rofi.rasi b/rofi/rofi.rasi index 935b790..7eb2195 100644 --- a/rofi/rofi.rasi +++ b/rofi/rofi.rasi @@ -21,7 +21,6 @@ window { background-color: @background; text-color: @foreground; border: 0px; - border-color: @border; border-radius: 0px; width: 100%; height: 100%; diff --git a/rofi/window.rasi b/rofi/window.rasi index f382c09..58d6ce6 100644 --- a/rofi/window.rasi +++ b/rofi/window.rasi @@ -22,7 +22,6 @@ window { background-color: #21212188; text-color: @foreground; border: 1px; - border-color: @border; border-radius: 25px; //width: 26%; location: center;