mirror of
https://github.com/danielepintore/dotfiles.git
synced 2026-07-14 09:15:13 +02:00
adds a custom shell script to generate a desktop entry of a web app
This commit is contained in:
@@ -90,3 +90,5 @@ bindkey -s ^n "tmux-sessionizer\n"
|
||||
|
||||
# Zsh syntax highlighting
|
||||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
|
||||
source ~/.config/zsh/functions
|
||||
|
||||
50
.config/zsh/functions
Normal file
50
.config/zsh/functions
Normal file
@@ -0,0 +1,50 @@
|
||||
# Create a desktop launcher for a web app
|
||||
web2app() {
|
||||
if [ "$#" -ne 3 ]; then
|
||||
echo "Usage: web2app <AppName> <AppURL> <IconURL> (IconURL must be in PNG -- use https://dashboardicons.com)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local APP_NAME="$1"
|
||||
local APP_URL="$2"
|
||||
local ICON_URL="$3"
|
||||
local ICON_DIR="$HOME/.local/share/applications/icons"
|
||||
local DESKTOP_FILE="$HOME/.local/share/applications/${APP_NAME}.desktop"
|
||||
local ICON_PATH="${ICON_DIR}/${APP_NAME}.png"
|
||||
|
||||
mkdir -p "$ICON_DIR"
|
||||
|
||||
if ! curl -sL -o "$ICON_PATH" "$ICON_URL"; then
|
||||
echo "Error: Failed to download icon."
|
||||
return 1
|
||||
fi
|
||||
|
||||
cat > "$DESKTOP_FILE" <<EOF
|
||||
[Desktop Entry]
|
||||
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"
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=$ICON_PATH
|
||||
StartupNotify=true
|
||||
EOF
|
||||
|
||||
chmod +x "$DESKTOP_FILE"
|
||||
}
|
||||
|
||||
web2app-remove() {
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: web2app-remove <AppName>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local APP_NAME="$1"
|
||||
local ICON_DIR="$HOME/.local/share/applications/icons"
|
||||
local DESKTOP_FILE="$HOME/.local/share/applications/${APP_NAME}.desktop"
|
||||
local ICON_PATH="${ICON_DIR}/${APP_NAME}.png"
|
||||
|
||||
rm "$DESKTOP_FILE"
|
||||
rm "$ICON_PATH"
|
||||
}
|
||||
Reference in New Issue
Block a user