Skip to content

Instantly share code, notes, and snippets.

@theRealCarneiro
Created April 13, 2024 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theRealCarneiro/dc94e4fe624a875d802e2b0c31a89e31 to your computer and use it in GitHub Desktop.
Save theRealCarneiro/dc94e4fe624a875d802e2b0c31a89e31 to your computer and use it in GitHub Desktop.
Borderless Independent Chrome App Shortcuts as Nativefier alternative in Hyprland

Configuration Overview

  • Chrome-based browsers tend to open new windows within an existing instance, unless Chrome operates using a different data directory.
  • To eliminate the toolbar, just set Chrome to open in kiosk mode; however, this action defaults to fullscreen. To address this we add a fakefullscreen and a tile rule in Hyprland.
  • Additionally, assigning a specific class allows us to apply this rule universally, rather than configuring it for each application individually.

Data dir directory

I manage this by setting up a directory specifically for the Chrome apps' data, which I typically locate at ~/.local/share/chrome-apps. CREATE the directory before running the commands

mkdir -p ~/.local/share/chrome-apps

Script

#!/bin/sh

app=$1
app_id=$2

if [ -z "$app_id" ]; then
	chrome --user-data-dir="$XDG_DATA_HOME/chrome-apps/$app" --class=chrome-app
else
	chrome --user-data-dir="$XDG_DATA_HOME/chrome-apps/$app" --class=chrome-app --app-id=$app_id --kiosk
fi

Create shortcut

  • Execute the script using the name of the app you desire (this name only serves as the data directory identifier). For example: chrome-app WhatsApp
  • Chrome will launch; proceed to create a shortcut for your desired application.
  • Navigate to ~/.local/share/applications and locate the .desktop file associated with the shortcut.
  • Retrieve the ID from the Exec line within the file.
  • Run the script again, this time including both the app name and the retrieved ID. Example: chrome-app WhatsApp MY_COOL_ID

Hyprland rules

windowrulev2 = fakefullscreen, class:^(chrome-app)$
windowrulev2 = tile, class:^(chrome-app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment