Add x.com Chrome app scratchpad

This commit is contained in:
2026-06-18 21:27:03 -07:00
parent 0efb55f23f
commit f12285b7f7
6 changed files with 68 additions and 2 deletions

View File

@@ -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:

View File

@@ -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"))

View File

@@ -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",

View File

@@ -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

View File

@@ -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

View File

@@ -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
]