Reflect default browser changes in bindings and webapps (#871)
* Abstract default browser to omarchy-browser (a wrapper) * Fix the omarchy-browser command as it used to loop. Extract info from the browser .desktop files. * Clean up and fix bugs * Cleanup unused change * Fix indentation * Separate out omarchy-browser from omarchy-webapp so that we don't break webapps for browsers other than Chromium or Google Chrome. * Fix incorrect function call * Add a migration script * Migration script fixes * Simplify the browser and webapp commands. Rename commands to align with launch terminology. * Add support for Microsoft Edge, Opera and Vivaldi * Fix errors * Remove --name and --class -- They're not respected when --app is defined * We don't ship with Chrome * Simplify launchers * Use launch commands everywhere --------- Co-authored-by: Ryan Hughes <ryan@heyoodle.com>
This commit is contained in:
parent
d4403051cf
commit
5e3d0d89a5
3
bin/omarchy-launch-browser
Executable file
3
bin/omarchy-launch-browser
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec setsid uwsm app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,/usr}/share/applications/$(xdg-settings get default-web-browser) 2>/dev/null | head -1) ${args[@]} $@
|
10
bin/omarchy-launch-webapp
Executable file
10
bin/omarchy-launch-webapp
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
browser=$(xdg-settings get default-web-browser)
|
||||
|
||||
case $browser in
|
||||
google-chrome* | brave-browser* | microsoft-edge* | opera* | vivaldi*) ;;
|
||||
*) browser="chromium.desktop" ;;
|
||||
esac
|
||||
|
||||
exec setsid uwsm app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,/usr}/share/applications/$browser 2>/dev/null | head -1) --app="$1" "${@:2}"
|
@ -34,10 +34,6 @@ edit_in_nvim() {
|
||||
alacritty -e nvim "$1"
|
||||
}
|
||||
|
||||
open_web() {
|
||||
setsid chromium --new-window --app="$1" &
|
||||
}
|
||||
|
||||
install() {
|
||||
present_terminal "echo 'Installing $1...'; yay -Sy --noconfirm $2"
|
||||
}
|
||||
@ -53,11 +49,11 @@ install_font() {
|
||||
show_learn_menu() {
|
||||
case $(menu "Learn" " Keybindings\n Omarchy\n Hyprland\n Arch\n Neovim\n Bash") in
|
||||
*Keybindings*) omarchy-menu-keybindings ;;
|
||||
*Omarchy*) open_web "https://learn.omacom.io/2/the-omarchy-manual" ;;
|
||||
*Hyprland*) open_web "https://wiki.hypr.land/" ;;
|
||||
*Arch*) open_web "https://wiki.archlinux.org/title/Main_page" ;;
|
||||
*Bash*) open_web "https://devhints.io/bash" ;;
|
||||
*Neovim*) open_web "https://www.lazyvim.org/keymaps" ;;
|
||||
*Omarchy*) omarchy-launch-webapp "https://learn.omacom.io/2/the-omarchy-manual" ;;
|
||||
*Hyprland*) omarchy-launch-webapp "https://wiki.hypr.land/" ;;
|
||||
*Arch*) omarchy-launch-webapp "https://wiki.archlinux.org/title/Main_page" ;;
|
||||
*Bash*) omarchy-launch-webapp "https://devhints.io/bash" ;;
|
||||
*Neovim*) omarchy-launch-webapp "https://www.lazyvim.org/keymaps" ;;
|
||||
*) show_main_menu ;;
|
||||
esac
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ cat >"$DESKTOP_FILE" <<EOF
|
||||
Version=1.0
|
||||
Name=$APP_NAME
|
||||
Comment=$APP_NAME
|
||||
Exec=chromium --new-window --ozone-platform=wayland --app="$APP_URL" --name="$APP_NAME" --class="$APP_NAME"
|
||||
Exec=omarchy-launch-webapp $APP_URL
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=$ICON_PATH
|
||||
|
@ -6,7 +6,7 @@ DESKTOP_DIR="$HOME/.local/share/applications/"
|
||||
if [ "$#" -ne 1 ]; then
|
||||
# Find all web apps
|
||||
while IFS= read -r -d '' file; do
|
||||
if grep -q '^Exec=.*chromium.*--app' "$file"; then
|
||||
if grep -q '^Exec=.*omarchy-launch-webapp.*' "$file"; then
|
||||
WEB_APPS+=("$(basename "${file%.desktop}")")
|
||||
fi
|
||||
done < <(find "$DESKTOP_DIR" -name '*.desktop' -print0)
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Application bindings
|
||||
$terminal = uwsm app -- alacritty
|
||||
$browser = uwsm app -- chromium --new-window
|
||||
$webapp = $browser --app
|
||||
$browser = omarchy-launch-browser
|
||||
|
||||
bindd = SUPER, return, Terminal, exec, $terminal --working-directory $(omarchy-cmd-terminal-cwd)
|
||||
bindd = SUPER, F, File manager, exec, uwsm app -- nautilus --new-window
|
||||
@ -15,15 +14,15 @@ bindd = SUPER, O, Obsidian, exec, uwsm app -- obsidian -disable-gpu
|
||||
bindd = SUPER, slash, Passwords, exec, uwsm app -- 1password
|
||||
|
||||
# If your web app url contains #, type it as ## to prevent hyperland treat it as comments
|
||||
bindd = SUPER, A, ChatGPT, exec, $webapp="https://chatgpt.com"
|
||||
bindd = SUPER SHIFT, A, Grok, exec, $webapp="https://grok.com"
|
||||
bindd = SUPER, C, Calendar, exec, $webapp="https://app.hey.com/calendar/weeks/"
|
||||
bindd = SUPER, E, Email, exec, $webapp="https://app.hey.com"
|
||||
bindd = SUPER, Y, YouTube, exec, $webapp="https://youtube.com/"
|
||||
bindd = SUPER SHIFT, G, WhatsApp, exec, $webapp="https://web.whatsapp.com/"
|
||||
bindd = SUPER ALT, G, Google Messages, exec, $webapp="https://messages.google.com/web/conversations"
|
||||
bindd = SUPER, X, X, exec, $webapp="https://x.com/"
|
||||
bindd = SUPER SHIFT, X, X Post, exec, $webapp="https://x.com/compose/post"
|
||||
bindd = SUPER, A, ChatGPT, exec, omarchy-launch-webapp "https://chatgpt.com"
|
||||
bindd = SUPER SHIFT, A, Grok, exec, omarchy-launch-webapp "https://grok.com"
|
||||
bindd = SUPER, C, Calendar, exec, omarchy-launch-webapp "https://app.hey.com/calendar/weeks/"
|
||||
bindd = SUPER, E, Email, exec, omarchy-launch-webapp "https://app.hey.com"
|
||||
bindd = SUPER, Y, YouTube, exec, omarchy-launch-webapp "https://youtube.com/"
|
||||
bindd = SUPER SHIFT, G, WhatsApp, exec, omarchy-launch-webapp "https://web.whatsapp.com/"
|
||||
bindd = SUPER ALT, G, Google Messages, exec, omarchy-launch-webapp "https://messages.google.com/web/conversations"
|
||||
bindd = SUPER, X, X, exec, omarchy-launch-webapp "https://x.com/"
|
||||
bindd = SUPER SHIFT, X, X Post, exec, omarchy-launch-webapp "https://x.com/compose/post"
|
||||
|
||||
# Overwrite existing bindings, like putting Omarchy Menu on Super + Space
|
||||
# unbind = SUPER, Space
|
||||
|
21
migrations/1755507891.sh
Executable file
21
migrations/1755507891.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Migrating to use omarchy-launch-webapp and omarchy-launch-browser"
|
||||
for desktop_file in ~/.local/share/applications/*.desktop; do
|
||||
if grep -q 'Exec=chromium --new-window --ozone-platform=wayland --app=' "$desktop_file"; then
|
||||
url=$(grep '^Exec=' "$desktop_file" | sed -n 's/.*--app="\?\([^"]*\)"\?.*/\1/p')
|
||||
|
||||
if [[ -n "$url" ]]; then
|
||||
sed -i "s|^Exec=.*|Exec=omarchy-launch-webapp \"$url\"|" "$desktop_file"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Updating Hyprland bindings"
|
||||
HYPR_BINDINGS_FILE="$HOME/.config/hypr/bindings.conf"
|
||||
if [ -f "$HYPR_BINDINGS_FILE" ]; then
|
||||
sed -i 's/\$browser =.*chromium.*$/\$browser = omarchy-launch-browser/' "$HYPR_BINDINGS_FILE"
|
||||
sed -i 's/\$webapp="/omarchy-launch-webapp "/g' "$HYPR_BINDINGS_FILE"
|
||||
sed -i '/^\$webapp = \$browser --app/d' "$HYPR_BINDINGS_FILE"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user