From f12285b7f729e2a369873e9a4f39c9eb7d56fc83 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 18 Jun 2026 21:27:03 -0700 Subject: [PATCH] Add x.com Chrome app scratchpad --- docs/tiling-wm-experience.md | 6 ++- dotfiles/config/hypr/hyprland/binds.lua | 3 ++ dotfiles/config/hypr/hyprland/scratchpads.lua | 6 +++ dotfiles/config/river-xmonad/Main.hs | 3 ++ dotfiles/config/xmonad/xmonad.hs | 8 ++++ nixos/desktop.nix | 44 +++++++++++++++++++ 6 files changed, 68 insertions(+), 2 deletions(-) diff --git a/docs/tiling-wm-experience.md b/docs/tiling-wm-experience.md index ee657698..4572743d 100644 --- a/docs/tiling-wm-experience.md +++ b/docs/tiling-wm-experience.md @@ -258,9 +258,10 @@ Required behavior: - A named scratchpad exists for spotify. - A named scratchpad exists for transmission. - A named scratchpad exists for volume. +- A named scratchpad exists for x.com. - Scratchpads appear near-fullscreen and centered by default. -- The codex scratchpad can be tiled into the normal workspace when desired, - while retaining its summon/dismiss toggle. +- The codex, claude, and x.com scratchpads can be tiled into the normal + workspace when desired, while retaining their summon/dismiss toggles. - Toggling a scratchpad deactivates fullscreen/tabbed state first. - Floating scratchpads are hidden from normal workspace and window listings. @@ -447,6 +448,7 @@ Required behavior: - `Super+Alt+s` toggles the spotify scratchpad. - `Super+Alt+t` toggles the transmission scratchpad. - `Super+Alt+v` toggles the volume scratchpad. +- `Super+Alt+x` toggles the x.com scratchpad. Important behavior: diff --git a/dotfiles/config/hypr/hyprland/binds.lua b/dotfiles/config/hypr/hyprland/binds.lua index f390a8e1..9e2050c5 100644 --- a/dotfiles/config/hypr/hyprland/binds.lua +++ b/dotfiles/config/hypr/hyprland/binds.lua @@ -291,6 +291,9 @@ function M.setup(ctx) bind(mod_alt .. " + V", function() toggle_scratchpad("volume") end, desc("Toggle volume scratchpad")) + bind(mod_alt .. " + X", function() + toggle_scratchpad("x_com") + end, desc("Toggle X scratchpad")) bind(mod_alt .. " + grave", function() toggle_scratchpad("dropdown") end, desc("Toggle dropdown scratchpad")) diff --git a/dotfiles/config/hypr/hyprland/scratchpads.lua b/dotfiles/config/hypr/hyprland/scratchpads.lua index d2f0b4e3..f237cc4f 100644 --- a/dotfiles/config/hypr/hyprland/scratchpads.lua +++ b/dotfiles/config/hypr/hyprland/scratchpads.lua @@ -51,6 +51,12 @@ function M.setup(ctx) command = "google-chrome-stable --profile-directory=Default --app=https://messages.google.com/web/conversations", class = "chrome-messages.google.com", }, + x_com = { + command = "x-com-pwa", + classes = { "x-com-pwa", "chrome-x.com" }, + title = "X", + allow_tiling = true, + }, transmission = { command = "transmission-gtk", class = "transmission-gtk", diff --git a/dotfiles/config/river-xmonad/Main.hs b/dotfiles/config/river-xmonad/Main.hs index 0a671093..550fa3b6 100644 --- a/dotfiles/config/river-xmonad/Main.hs +++ b/dotfiles/config/river-xmonad/Main.hs @@ -147,6 +147,7 @@ spawnBindings = , key (super .|. alt) xK_s (toggleScratchpad "spotify") , key (super .|. alt) xK_t (toggleScratchpad "transmission") , key (super .|. alt) xK_v (toggleScratchpad "volume") + , key (super .|. alt) xK_x (toggleScratchpad "x-com") , key (super .|. alt) xK_c (spawnAction "google-chrome-stable") , key super xK_e (spawnAction "emacsclient --eval '(emacs-everywhere)'") , key (super .|. ctrl) xK_e (shiftFocusedToNextEmptyWorkspace False) @@ -297,6 +298,8 @@ scratchpadDefinitions = anyMatcher [titleContains "Transmission", appIdContains "transmission"] , ScratchpadDefinition "volume" "pavucontrol" $ anyMatcher [appIdMatches "Pavucontrol", appIdContains "pavucontrol"] + , ScratchpadDefinition "x-com" "x-com-pwa" $ + anyMatcher [appIdMatches "x-com-pwa", appIdContains "chrome-x.com"] ] anyMatcher :: [RiverWMWindowState -> Bool] -> RiverWMWindowState -> Bool diff --git a/dotfiles/config/xmonad/xmonad.hs b/dotfiles/config/xmonad/xmonad.hs index 8e2c581d..b88e69f7 100644 --- a/dotfiles/config/xmonad/xmonad.hs +++ b/dotfiles/config/xmonad/xmonad.hs @@ -244,6 +244,11 @@ slackSelector = className =? "Slack" spotifySelector = className =? "Spotify" transmissionSelector = fmap (isPrefixOf "Transmission") title volumeSelector = className =? "Pavucontrol" +xComSelector = + className =? "x-com-pwa" + <||> fmap ("chrome-x.com" `isInfixOf`) className + <||> (chromeSelectorBase <&&> title =? "X") + <||> fmap ("x.com" `isInfixOf`) title virtualClasses = [ (chromeSelector, "Chrome") @@ -261,6 +266,7 @@ slackCommand = "slack" spotifyCommand = "spotify" transmissionCommand = "transmission-gtk" volumeCommand = "pavucontrol" +xComCommand = "x-com-pwa" -- Startup hook @@ -811,6 +817,7 @@ scratchpads = , NS "spotify" spotifyCommand spotifySelector nearFullFloat , NS "transmission" transmissionCommand transmissionSelector nearFullFloat , NS "volume" volumeCommand volumeSelector nearFullFloat + , NS "x-com" xComCommand xComSelector nearFullFloat ] @@ -1018,6 +1025,7 @@ addKeys conf@XConfig { modMask = modm } = , ((modalt, xK_s), doScratchpad "spotify") , ((modalt, xK_t), doScratchpad "transmission") , ((modalt, xK_v), doScratchpad "volume") + , ((modalt, xK_x), doScratchpad "x-com") -- Specific program spawning diff --git a/nixos/desktop.nix b/nixos/desktop.nix index 30708341..406a0e2f 100644 --- a/nixos/desktop.nix +++ b/nixos/desktop.nix @@ -86,6 +86,34 @@ exec google-chrome-stable --profile-directory="$profile_dir" --new-window ''; }; + xComPwa = pkgs.writeShellApplication { + name = "x-com-pwa"; + runtimeInputs = [ + googleChromeCommandWrappers + pkgs.jq + ]; + text = '' + profile_args=() + local_state="''${CHROME_USER_DATA_DIR:-$HOME/.config/google-chrome}/Local State" + + if [ -r "$local_state" ]; then + profile_dir="$( + jq -r ' + (.profile.info_cache // {}) + | to_entries + | sort_by(if .key == "Default" then 0 else 1 end, -(.value.active_time // 0)) + | .[0].key // empty + ' "$local_state" 2>/dev/null || true + )" + + if [ -n "$profile_dir" ]; then + profile_args+=(--profile-directory="$profile_dir") + fi + fi + + exec google-chrome-stable "''${profile_args[@]}" --class=x-com-pwa --app=https://x.com/ + ''; + }; googleChromeDesktopEntries = pkgs.runCommand "google-chrome-desktop-entries" {nativeBuildInputs = [pkgs.gnused];} '' mkdir -p "$out/share/applications" @@ -242,6 +270,21 @@ }; }; + xdg.desktopEntries.x-com-pwa = { + name = "X"; + genericName = "Social Network"; + comment = "Open x.com in a dedicated Chrome app window"; + icon = "google-chrome"; + terminal = false; + type = "Application"; + categories = ["Network"]; + startupNotify = true; + exec = "${xComPwa}/bin/x-com-pwa"; + settings = { + StartupWMClass = "x-com-pwa"; + }; + }; + xdg.configFile."ghostty/config" = { force = true; text = '' @@ -354,6 +397,7 @@ spotify spotifyWaylandPatch tor-browser + xComPwa # vscode zulip ]