commit 6336a2f1250608803010a77d7ee0c4c207960215 Author: Riley Apeldoorn Date: Tue Mar 2 07:50:54 2021 +0100 added the file diff --git a/entile b/entile new file mode 100755 index 0000000..f4361e3 --- /dev/null +++ b/entile @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +regex='m/\-\ (http(s|)\:\/\/([\w_-]+[\w.,^#@%?+&\/_-]*))/; print $1' +alias='/home/riley/.config/entile/alias.conf' +browser='chromium' + +if [[ "$@" =~ ^-[h?]$ ]] || [[ "$1" = "" ]] +then + echo "urlapp - open url as google chrome app" + echo "" + echo "Usage: urlapp [-u|-i] -c|-t|url" + echo -e " -c\tClose focused chrome tab and reopen it as a chrome app" + echo -e " -u\tOpen only if no other windows with that name exist, otherwise focus that window" + echo -e " -i\tOpen in incognito" + echo "" + echo "Dependencies: xdotool, chromium, i3-wm, perl" + exit 0 +fi + +if [[ "$@" =~ -\w*t\w* ]] +then + url=$(xdotool getactivewindow getwindowname | perl -nle "$regex") +elif [[ "$@" =~ -\w*c\w* ]] +then + url=$(xclip -o -clip) +else + arg=${*: -1} + maybe_alias=$(cat $alias | grep "$arg" | cut -d ' ' -f 2) + [ ! -z "$tmp" ] && url=$maybe_alias || url=$arg +fi + +if [[ "$@" =~ -\w*u\w* ]] && [[ "$(xdotool search $url)" ]] +then + i3-msg [id="$(xdotool search $url | head -n 1)"] focus +else + if [[ "$@" =~ -\w*n\w* ]] + then + browser='chromium --incognito' + fi + url=$(echo "$url" | rg .*:// || echo "https://""$url") + $browser --app="$url" & +fi