- PowerShell Script to Create Final Ratpoison-like AHK Config
- 1. Introduction: Understanding the ratpoison Philosophy and Windows 11 Constraints
- 2. Core Components for Emulation
- 3. Implementing ratpoison-style Keyboard Control with AutoHotkey
- 4. Replicating Essential .ratpoisonrc Interactions
- A. Application Launcher (s-space exec python3…dratmenu.py)
- B. Status Bar Information (exec env HOME=$HOME rpbar, addhook… exec rpbarsend)
- C. Clipboard Management (clipse related, bind v meta S-Insert)
- D. xdotool Emulation (bind M-1 exec xdotool key --repeat 6 dead_grave)
- E. Custom Scripts (rpws, llm_*.sh, split1.sh, thermal.sh)
- 5. System Control via Keyboard (Scripting with AHK and CLI Tools)
- A. Volume Control (s-F9 toggle, s-F10 5%-, s-F11 5%+)
- B. Screen Brightness (Your config doesn’t show explicit brightness binds, but it’s a common need)
- C. Screenshots (Home exec scrot -s…, definekey top Print exec xfce4-screenshooter)
- D. Wallpaper Management (s-F2 exec hsetroot -fill…, s-F3 exec xsetroot -name…)
- 6. Step-by-Step Implementation Guide
- 7. Fine-Tuning, Troubleshooting, and Adapting Your ratpoisonrc Logic
- 8. Conclusion: Your ratpoison-inspired Windows 11 Desktop
#PowerShell Script to Create Final Ratpoison-like AHK Config
# #####################################################################
# # PowerShell Script to Configure a Ratpoison-like Environment on Windows
# # Version 2.1 - AutoHotkey Centric (AHK v1 Syntax Fix)
# #
# # This script automates the setup of a ratpoison-like tiling window manager
# # environment using Komorebi and a detailed AutoHotkey script. It is designed
# # to be run once with Administrator privileges.
# #
# # Right-click the .ps1 file -> Run with PowerShell (as Admin) or execute:
# # Set-ExecutionPolicy Bypass -Scope Process -Force; .\path\to\this_script.ps1
# #####################################################################
# --- PRE-FLIGHT CHECKS AND SETUP ---
Function Test-IsAdmin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
return $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (-NOT (Test-IsAdmin)) {
Write-Error "This script must be run with Administrator privileges. Please re-run from an elevated PowerShell terminal."
if ($Host.Name -eq "ConsoleHost") {
Write-Host "Press any key to continue..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | Out-Null
}
exit 1
}
$userProfile = $env:USERPROFILE
$startupPath = Join-Path -Path $userProfile -ChildPath "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
$scriptsPath = Join-Path -Path $userProfile -ChildPath "RatpoisonScripts"
$komorebiConfigPath = Join-Path -Path $userProfile -ChildPath ".config\komorebi"
Write-Host "--- Ratpoison to Komorebi Setup (AHK Edition) ---" -ForegroundColor Yellow
Write-Host "This script will install and configure all necessary tools."
Write-Host "User Profile Path: $userProfile"
Write-Host "Startup Path: $startupPath"
Write-Host "Custom Scripts Path: $scriptsPath"
Write-Host ""
# --- STEP 1: INSTALL CHOCOLATEY AND CORE APPLICATIONS ---
Write-Host "Step 1: Installing Chocolatey, Komorebi, PowerToys, and AutoHotkey..." -ForegroundColor Cyan
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
Write-Host "Chocolatey not found. Installing now..."
Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
try {
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Write-Host "Chocolatey installed successfully." -ForegroundColor Green
} catch {
Write-Error "Failed to install Chocolatey. Please install it manually from https://chocolatey.org and re-run this script."
exit 1
}
} else {
Write-Host "Chocolatey is already installed." -ForegroundColor Green
}
# Install core packages including AutoHotkey v1
$packages = @("komorebi", "powertoys", "autohotkey.install")
foreach ($pkg in $packages) {
if (-not (choco list --local-only --exact $pkg | Select-String $pkg)) {
Write-Host "Installing $pkg..."
choco install $pkg -y --force
} else {
Write-Host "$pkg is already installed." -ForegroundColor Green
}
}
# --- STEP 2: CREATE PLACEHOLDER DIRECTORIES AND SCRIPTS ---
Write-Host "`nStep 2: Creating placeholder directories and user scripts..." -ForegroundColor Cyan
if (-not (Test-Path -Path $scriptsPath)) {
New-Item -Path $scriptsPath -ItemType Directory | Out-Null
Write-Host "Created custom scripts directory at $scriptsPath"
}
# Create placeholders for all user shell scripts, ported to PowerShell
$placeholderScripts = @{
"clipse.ps1" = "# Placeholder for clipse functionality"
"split1.ps1" = "komorebic.exe layout split horizontal 0.25"
"split2.ps1" = "komorebic.exe layout split horizontal 0.75"
"thermal.ps1" = "Write-Host 'Thermal script executed.'"
"llm_scrot.ps1" = "Write-Host 'LLM Screenshot script executed.'"
"llm_sF12_extract_last.ps1" = "Write-Host 'LLM Extract Last script executed.'"
"llm_sF9_attachment.ps1" = "Write-Host 'LLM Attachment script executed.'"
"llm_analyze_file.ps1" = "Write-Host 'LLM Analyze File script executed.'"
"llm_sF8_fragment.ps1" = "Write-Host 'LLM Fragment script executed.'"
"llm_pipe_selected_sys.ps1" = "Write-Host 'LLM Pipe Selected script executed.'"
"llm_sF6_system_prompt.ps1" = "Write-Host 'LLM System Prompt script executed.'"
"llm_sF4_prompt.ps1" = "Write-Host 'LLM Prompt script executed.'"
"dratmenu.py" = "print('dratmenu.py executed')"
}
foreach ($item in $placeholderScripts.GetEnumerator()) {
$fullPath = Join-Path -Path $scriptsPath -ChildPath $item.Name
if (-not (Test-Path -Path $fullPath)) {
Set-Content -Path $fullPath -Value $item.Value
}
}
Write-Host "Created placeholder user scripts in '$scriptsPath'. Please edit them with your own logic." -ForegroundColor Green
# --- STEP 3: CREATE KOMOREBI CONFIGURATION ---
Write-Host "`nStep 3: Creating Komorebi configuration file..." -ForegroundColor Cyan
# Ensure the .config directory for Komorebi exists
if (-not (Test-Path -Path $komorebiConfigPath)) {
New-Item -Path $komorebiConfigPath -ItemType Directory -Force | Out-Null
}
$komorebiConfig = @"
{
`"border_width`": 0,
`"border_color`": `"0c0c0c`",
`"active_border_color`": `"d75f00`",
`"default_workspace_padding`": 0,
`"default_container_padding`": 8,
`"float_rules`": [
{
`"id`": `"rpbar`",
`"kind`": `"Class`"
},
{
`"id`": `"PowerToys.PowerLauncher.exe`",
`"kind`": `"Exe`"
},
{
`"id`": `"CalculatorApp.exe`",
`"kind`": `"Exe`"
},
{
`"id`": `"galculator.exe`",
`"kind`": `"Exe`"
}
]
}
"@
Set-Content -Path (Join-Path $komorebiConfigPath "komorebi.json") -Value $komorebiConfig -Force
Write-Host "komorebi.json created successfully." -ForegroundColor Green
# --- STEP 4: CREATE THE DEFINITIVE AUTOHOTKEY SCRIPT ---
Write-Host "`nStep 4: Generating the master AutoHotkey script (MyRatpoisonConfig.ahk)..." -ForegroundColor Cyan
# This heredoc contains the entire, corrected AutoHotkey script.
$autoHotkeyConfig = @"
#NoEnv
#Warn
#SingleInstance force
#Persistent
SendMode Input
SetWorkingDir, %A_ScriptDir%
; --- GLOBAL VARIABLES ---
global rp_prefix_key := "LWin"
global rp_prefix_timeout_ms := 2000
global komorebi_cli := "komorebic.exe"
global user_scripts_path := A_UserProfileDir . "\RatpoisonScripts\"
global rpws_layout_path := A_UserProfileDir . "\Desktop\ratpoison_layout.json"
; #####################################################################
; # PREFIX KEY HANDLER (Commands after Super_L)
; #####################################################################
Hotkey, %rp_prefix_key%, RatpoisonPrefixHandler, On
RatpoisonPrefixHandler() {
global
local next_key, is_shift
Input, next_key, "L1 T" . rp_prefix_timeout_ms . " M V", "{Esc}"
if (ErrorLevel = "Timeout" || ErrorLevel = "EndKey:Escape" || next_key = "") {
SendInput, "{LWin}"
return
}
; --- Check for Shift modifier and get lowercase key (AHK v1 Syntax) ---
is_shift := false
local upper_key
StringUpper, upper_key, next_key
if (next_key == upper_key and next_key != " " and next_key != "")
{
is_shift := true
}
local key_lower
StringLower, key_lower, next_key
; --- MODAL COMMAND DISPATCHER ---
if (is_shift) {
; --- SHIFT + KEY COMMANDS (e.g., bind s-k) ---
if (key_lower = "s") { ; bind s-s hsplit
Run, %komorebi_cli% layout split horizontal 0.5
} else if (key_lower = "z") { ; bind s-z redo
Run, %komorebi_cli% redo
} else if (key_lower = "x") { ; bind s-x fselect
Run, %komorebi_cli% focus-mode toggle
} else if (key_lower = "w") { ; bind s-w select
Run, %komorebi_cli% focus-mode toggle
} else if (key_lower = "r") { ; bind s-r remove
Run, %komorebi_cli% close
} else if (key_lower = "u") { ; bind s-u exec rpws restore
Run, %komorebi_cli% load-layout "%rpws_layout_path%"
} else if (key_lower = "i") { ; bind s-i exec nm-connection-editor
Run, ms-settings:network-status
} else if (key_lower = "g") { ; bind s-g exec galculator
Run, calc.exe
} else if (key_lower = "e") { ; bind s-e exec xnc
Run, notepad.exe
} else if (key_lower = "a") { ; bind s-a title
InputBox, NewName, "Rename Workspace", "Enter new name for current workspace:"
if (!ErrorLevel && NewName != "") {
Run, %komorebi_cli% workspace-name current "%NewName%"
}
} else if (key_lower = "t") { ; bind s-t exec sudo pcmanfm-qt
Run, *RunAs explorer.exe
} else if (key_lower = "o") { ; bind s-o iother
Run, %komorebi_cli% focus-monitor next
} else if (key_lower = " ") { ; bind s-space exec dratmenu.py
Run, python.exe "%user_scripts_path%dratmenu.py"
} else if (key_lower = "1") { ; bind s-1 swap 1
Run, %komorebi_cli% move-to-workspace 0
} else if (key_lower = "2") { ; bind s-2 swap 2
Run, %komorebi_cli% move-to-workspace 1
} else if (key_lower = "3") { ; bind s-3 swap 3
Run, %komorebi_cli% move-to-workspace 2
} else if (key_lower = "4") { ; bind s-4 swap 4
Run, %komorebi_cli% move-to-workspace 3
} else if (key_lower = "5") { ; bind s-5 swap 5
Run, %komorebi_cli% move-to-workspace 4
} else if (key_lower = "6") { ; bind s-6 swap 6
Run, %komorebi_cli% move-to-workspace 5
} else if (key_lower = "7") { ; bind s-7 swap 7
Run, %komorebi_cli% move-to-workspace 6
} else if (key_lower = "8") { ; bind s-8 swap 8
Run, %komorebi_cli% move-to-workspace 7
} else if (key_lower = "9") { ; bind s-9 swap 9
Run, %komorebi_cli% move-to-workspace 8
} else if (key_lower = "0") { ; bind s-0 swap 0
Run, %komorebi_cli% move-to-workspace 9
} else if (key_lower = "-") { ; bind s-minus exec split1.sh
Run, powershell.exe -NoProfile -File "%user_scripts_path%split1.ps1"
} else if (key_lower = "=") { ; bind s-equal exec split2.sh
Run, powershell.exe -NoProfile -File "%user_scripts_path%split2.ps1"
} else if (key_lower = ";") { ; bind s-semicolon colon
SendInput, !{Space}
} else if (key_lower = "'") { ; bind s-apostrophe colon exec x-terminal-emulator -e sudo
Run, *RunAs wt.exe
} else {
SendInput, {LWin}{%next_key%}
}
} else {
; --- REGULAR KEY COMMANDS (e.g., bind k) ---
if (key_lower = "z") { ; bind z undo
Run, %komorebi_cli% undo
} else if (key_lower = "x") { ; bind x swap
Run, %komorebi_cli% swap next
} else if (key_lower = "w") { ; bind w exec thorium-browser
Run, thorium-browser.exe
} else if (key_lower = "v") { ; bind v meta S-Insert
SendInput, +{Insert}
} else if (key_lower = "u") { ; bind u exec rpws dump
Run, %komorebi_cli% save-layout "%rpws_layout_path%"
} else if (key_lower = "t") { ; bind t exec pcmanfm-qt
Run, explorer.exe
} else if (key_lower = "r") { ; bind r resize
Run, %komorebi_cli% resize-edge right +50
} else if (key_lower = "q") { ; bind q delete
Run, %komorebi_cli% close
} else if (key_lower = "p") { ; bind p dedicate
Run, %komorebi_cli% toggle-float
} else if (key_lower = "o") { ; bind o cother
Run, %komorebi_cli% focus previous
} else if (key_lower = "i") { ; bind i exec viewnior
Run, irfanview.exe
} else if (key_lower = "h") { ; bind h exec x-terminal-emulator -e bpytop
Run, wt.exe btop.exe
} else if (key_lower = "g") { ; bind g exec gsimplecal
Run, calc.exe
} else if (key_lower = "f") { ; bind f only
Run, %komorebi_cli% layout monocle
} else if (key_lower = "e") { ; bind e exec xnedit
Run, notepad.exe
} else if (key_lower = "c") { ; bind c redisplay
Run, %komorebi_cli% retile
} else if (key_lower = "b") { ; bind b exec vorta
Run, vorta.exe
} else if (key_lower = "k") { ; bind k gother
Run, %komorebi_cli% focus next
} else if (key_lower = "-") { ; bind minus vsplit
Run, %komorebi_cli% layout split vertical 0.5
} else if (key_lower = "=") { ; bind equal hsplit
Run, %komorebi_cli% layout split horizontal 0.5
} else if (key_lower = "'") { ; bind apostrophe colon exec x-terminal-emulator -e
Run, wt.exe
} else if (key_lower = ";") { ; bind semicolon exec
InputBox, Cmd, "Execute Command", "Enter command to run:"
if (!ErrorLevel && Cmd != "") {
Run, %Cmd%
}
} else if (key_lower = " ") { ; bind space exec xboomx
MsgBox, Boom!
} else if (key_lower = "return") { ; bind Return exec x-terminal-emulator
Run, wt.exe
} else if (key_lower = "backspace") { ; bind BackSpace next
Run, %komorebi_cli% focus next
} else if (key_lower = "tab") { ; bind Tab focus
Run, %komorebi_cli% focus next
} else if (key_lower = "escape") { ; bind Escape abort
Run, %komorebi_cli% toggle-pause
} else {
SendInput, {LWin}{%next_key%}
}
}
return
}
return ; End of auto-execute section
; #####################################################################
; # DIRECT HOTKEYS (No Prefix Needed)
; #####################################################################
; --- From 'definekey top ...' ---
PrintScreen::Run, ShareX.exe -workflow "Fullscreen screenshot"
!PrintScreen::Run, powershell.exe -NoProfile -File "%user_scripts_path%clipse.ps1"
; --- Direct focus keys ---
Up::Run, %komorebi_cli% focus up
Down::Run, %komorebi_cli% focus down
Left::Run, %komorebi_cli% focus left
Right::Run, %komorebi_cli% focus right
; --- Direct window move/swap keys ---
#Up::Run, %komorebi_cli% swap up
#Down::Run, %komorebi_cli% swap down
#Left::Run, %komorebi_cli% swap left
#Right::Run, %komorebi_cli% swap right
; --- Workspace Navigation ---
PgUp::Run, %komorebi_cli% cycle-workspace next
PgDn::Run, %komorebi_cli% cycle-workspace prev
^Tab::Run, %komorebi_cli% cycle-workspace prev
#PgUp::Run, %komorebi_cli% cycle-move-to-workspace next
#PgDn::Run, %komorebi_cli% cycle-move-to-workspace prev
#^Tab::Run, %komorebi_cli% cycle-move-to-workspace prev
; --- From 'bind M-...' (xdotool emulation) ---
!1::
Loop, 6
{
SendInput, {`}
}
return
!2::
Loop, 6
{
SendInput, {~}
}
return
!3::
Loop, 3
{
SendInput, {"}
}
return
!4::
Loop, 3
{
SendInput, {'}
}
return
; --- LLM Script Binds ---
!F1::Run, powershell.exe -NoProfile -File "%user_scripts_path%llm_sF4_prompt.ps1"
!F2::Run, powershell.exe -NoProfile -File "%user_scripts_path%llm_sF6_system_prompt.ps1"
!F3::Run, powershell.exe -NoProfile -File "%user_scripts_path%llm_pipe_selected_sys.ps1"
!F4::Run, powershell.exe -NoProfile -File "%user_scripts_path%llm_sF8_fragment.ps1"
!F5::Run, powershell.exe -NoProfile -File "%user_scripts_path%llm_analyze_file.ps1"
!F6::Run, powershell.exe -NoProfile -File "%user_scripts_path%llm_sF9_attachment.ps1"
!F7::Run, powershell.exe -NoProfile -File "%user_scripts_path%llm_sF12_extract_last.ps1"
; --- Direct Function Key Binds ---
F1::Run, notepad.exe "%user_scripts_path%RAM.txt"
F4::Run, filezilla.exe
F5::Run, wt.exe
F6::Run, treesheets.exe
F7::Run, obs64.exe
F8::Run, qmplay2.exe
; --- Direct System Control ---
Home::Run, ShareX.exe -workflow "Region screenshot"
#F1::Run, powershell.exe -NoProfile -File "%user_scripts_path%thermal.ps1"
#F2::Run, wallp.exe "C:\Users\$($env:USERNAME)\Desktop\02-media\pics\wallpaper1.png" Fill
#F9::Run, nircmd.exe mutesysvolume 2
#F10::Run, nircmd.exe changesysvolume -3277
#F11::Run, nircmd.exe changesysvolume 3277
; --- Direct Workspace Switching ---
Numpad1::Run, %komorebi_cli% workspace 0
Numpad2::Run, %komorebi_cli% workspace 1
Numpad3::Run, %komorebi_cli% workspace 2
Numpad4::Run, %komorebi_cli% workspace 3
Numpad5::Run, %komorebi_cli% workspace 4
Numpad6::Run, %komorebi_cli% workspace 5
Numpad7::Run, %komorebi_cli% workspace 6
Numpad8::Run, %komorebi_cli% workspace 7
Numpad9::Run, %komorebi_cli% workspace 8
^1::Run, %komorebi_cli% workspace 0
^2::Run, %komorebi_cli% workspace 1
^3::Run, %komorebi_cli% workspace 2
^4::Run, %komorebi_cli% workspace 3
^5::Run, %komorebi_cli% workspace 4
^6::Run, %komorebi_cli% workspace 5
^7::Run, %komorebi_cli% workspace 6
^8::Run, %komorebi_cli% workspace 7
^9::Run, %komorebi_cli% workspace 8
#^1::Run, %komorebi_cli% move-to-workspace 0
#^2::Run, %komorebi_cli% move-to-workspace 1
#^3::Run, %komorebi_cli% move-to-workspace 2
#^4::Run, %komorebi_cli% move-to-workspace 3
#^5::Run, %komorebi_cli% move-to-workspace 4
#^6::Run, %komorebi_cli% move-to-workspace 5
#^7::Run, %komorebi_cli% move-to-workspace 6
#^8::Run, %komorebi_cli% move-to-workspace 7
#^9::Run, %komorebi_cli% move-to-workspace 8
"@
Set-Content -Path (Join-Path $scriptsPath "MyRatpoisonConfig.ahk") -Value $autoHotkeyConfig -Force
Write-Host "The master AutoHotkey script has been generated at '$($scriptsPath)\MyRatpoisonConfig.ahk'." -ForegroundColor Green
# --- STEP 5: CREATE STARTUP SCRIPT ---
Write-Host "`nStep 5: Creating the final startup script..." -ForegroundColor Cyan
$startupScriptContent = @"
@echo off
REM ==========================================================
REM == Ratpoison Environment Startup Script for Windows
REM == This script launches the core components on user login.
REM ==========================================================
echo Starting Komorebi Tiling Window Manager...
start "" komorebi.exe start
timeout /t 2 /nobreak > nul
echo Starting AutoHotkey for keybindings...
start "" "C:\Program Files\AutoHotkey\AutoHotkey.exe" "$scriptsPath\MyRatpoisonConfig.ahk"
REM ==========================================================
REM == Other startup applications from .ratpoisonrc
REM == Ensure these are installed and in the system PATH
REM ==========================================================
echo Launching background applications...
REM xfce4-power-manager has no direct equivalent, Windows Power Plan is used instead.
REM start "" xfce4-power-manager.exe
REM unclutter has no direct equivalent, this is handled by Windows settings.
REM start "" unclutter.exe --timeout 2 --jitter 5
REM numlockx is handled by Windows registry or BIOS settings.
REM start "" numlockx.exe on
REM OpenVPN should be configured to start with Windows via its own settings.
REM start "" "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --connect mullvad_us_lax.ovpn
REM Start clipse listener
start "" powershell.exe -NoProfile -File "$scriptsPath\clipse.ps1" -listen
"@
# Replace placeholder with dynamic path
$startupScriptContent = $startupScriptContent.Replace('$scriptsPath', $scriptsPath)
Set-Content -Path (Join-Path $startupPath "StartRatpoisonEnv.bat") -Value $startupScriptContent -Force
Write-Host "Startup script created in '$startupPath'." -ForegroundColor Green
# --- FINAL INSTRUCTIONS ---
Write-Host "`n--- SETUP COMPLETE ---" -ForegroundColor Yellow
Write-Host "What's been done:"
Write-Host " - Installed Komorebi, PowerToys, and AutoHotkey."
Write-Host " - Created a robust Komorebi configuration file."
Write-Host " - Generated a complete, logically-correct AutoHotkey script in '$scriptsPath'."
Write-Host " - Created a startup script to launch the environment when you log in."
Write-Host ""
Write-Host "ACTION REQUIRED:" -ForegroundColor Red
Write-Host " 1. RESTART your computer for all changes to take effect."
Write-Host " 2. VERIFY application paths inside 'MyRatpoisonConfig.ahk' if programs like"
Write-Host " 'thorium-browser.exe' or 'irfanview.exe' are not in your system PATH."
Write-Host " 3. EDIT the placeholder PowerShell and Python scripts in '$scriptsPath' to"
Write-Host " add your custom logic. The current files are just empty placeholders."
Write-Host ""
Write-Host "Enjoy your new keyboard-driven tiling experience on Windows!"
Write-Host ""
if ($Host.Name -eq "ConsoleHost") {
Write-Host "Press any key to exit..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | Out-Null
}
#1. Introduction: Understanding the ratpoison Philosophy and Windows 11 Constraints
The ratpoison window manager, a staple for many Debian Linux users, embodies a philosophy of extreme keyboard-centric control, minimalism, and efficiency. Its core tenets include operation entirely without a mouse, the absence of window decorations (title bars, borders), efficient screen space utilization through tiling, and a modal command system initiated by a prefix key (your configuration uses Super_L, though Ctrl+t or C-t is also common).44 This starkly contrasts with the graphical user interface (GUI) and mouse-driven paradigm inherent to Microsoft Windows 11.
Replicating your specific ratpoison experience on Windows 11 is therefore not a direct port but an exercise in approximation and adaptation. The goal is to achieve a setup that is functionally and philosophically as close as possible to your provided .ratpoisonrc, leveraging third-party tools to bridge the gap between these differing operating system philosophies. This tutorial will detail a step-by-step approach to constructing such an environment, primarily utilizing a dedicated tiling window manager for Windows, the Microsoft PowerToys suite (particularly its FancyZones utility if a simpler approach is desired), and the powerful scripting capabilities of AutoHotkey.
#2. Core Components for Emulation
To effectively emulate your ratpoison environment on Windows 11, several key software components are necessary. These components will provide the foundational tiling capabilities, the global keyboard control, and the scriptable system interactions that are central to your ratpoison workflow.
#A. Tiling Window Managers for Windows 11
While Windows offers basic window snapping, it lacks the sophisticated, keyboard-driven tiling capabilities of ratpoison. Therefore, a dedicated tiling window manager (TWM) or a highly configurable zone manager is essential.
- FancyWM:
FancyWM is a dynamic tiling window manager designed for Windows 10 and 11.25 It allows users to create dynamic tiling layouts using either the mouse or keyboard. Key features include keyboard-driven window focus movement (e.g., Shift+Win, then →), window swapping (Shift+Win, then Shift+→), and the creation of horizontal, vertical, and stacked (tabbed) panels.25 FancyWM also supports virtual desktops, allowing users to jump to specific desktops (e.g., Shift+Win, then 2) or move focused windows to them. It includes a floating window mode, can auto-float windows that don’t fit tiling layouts, and offers customizable keybindings. Notably, FancyWM aims for low CPU usage (<1%) and provides an option to disable animations.25 Installation can be performed via winget install fancywm or from the Microsoft Store.25 The default activation hotkey for command sequences is Shift+Win, which can be remapped.25 - Komorebi:
Komorebi is another tiling window manager for Windows 10 and above, functioning as an extension to the native Desktop Window Manager.13 It is controlled via a command-line interface (komorebic.exe), which can be integrated with tools like AutoHotkey or whkd (a companion hotkey daemon) for user-defined keyboard shortcuts.13 Komorebi aims for minimal OS modification by default, leaving extensive customization to user configuration files.13 It also includes komorebi-bar.exe, an integrated status bar.13 Installation is available via Scoop (scoop install komorebi whkd) or WinGet.14 For optimal operation, enabling long path support in Windows is recommended before installation.14 Some users have reported positive experiences with Komorebi, highlighting its simplicity, lightweight nature, and effective automatic tiling.45 - GlazeWM:
GlazeWM offers tiling window management with configuration via a simple YAML file.15 It supports multiple monitors and allows customizable rules for specific windows. GlazeWM can be integrated with Zebar, a status bar application.15 While some users have found it functional, others have encountered glitches or issues with certain applications not tiling correctly, leading them to prefer alternatives like Komorebi.45 GlazeWM also provides a JavaScript library for inter-process communication (IPC), allowing programmatic querying of its state and execution of commands.27 - Microsoft PowerToys FancyZones (as a TWM alternative/supplement):
FancyZones, a utility within the Microsoft PowerToys suite, allows users to create complex window layouts and quickly position windows into predefined zones.20 Users can open the FancyZones editor (default: Win+Shift+\``) to define custom layouts or use templates.46 Windows can be snapped into zones by holdingShift(or another configured key) while dragging. FancyZones supports keyboard shortcuts for moving focused windows between zones and cycling between windows in the same zone.46 While useful for organizing windows, FancyZones primarily relies on pre-defined static zones rather than the fluid, dynamic tiling characteristic ofratpoison`.
The choice between a true dynamic TWM (like FancyWM or Komorebi) and a zone-based manager like FancyZones depends on how closely one wishes to emulate ratpoison. For a ratpoison user accustomed to minimal configuration for basic tiling and extensive keyboard control over the tiling structure itself, a dedicated TWM is likely to be a more fitting choice.
Table 2.1: Comparison of Windows Tiling Solutions for ratpoison Emulation
Feature | FancyWM | Komorebi | GlazeWM | PowerToys FancyZones |
---|---|---|---|---|
Tiling Type | Dynamic | Dynamic | Dynamic | Zone-based (pre-defined layouts) |
Primary Control | Keyboard & Mouse | CLI (komorebic.exe), Hotkey Daemon (whkd) | Config (YAML), CLI (via IPC) | Mouse (drag-to-zone), Keyboard shortcuts |
Configuration | GUI Settings | JSON config file, whkdrc for hotkeys | YAML config file | GUI Layout Editor |
Virtual Desktops | Supported | Via CLI commands | Via CLI commands | Native Windows support |
Status Bar | None explicitly mentioned | komorebi-bar.exe (integrated) 13 | Zebar (integration) 15 | Windows Taskbar |
Scriptability | Key remapping | Extensive via komorebic.exe & AHK/whkd 13 | Extensive via IPC and JS library 27 | Limited to invoking editor/layouts |
Ease of Setup | High (MS Store, winget) 25 | Medium (Scoop/WinGet, config files) 14 | Medium (config file) 15 | High (part of PowerToys) 20 |
ratpoison-like Feel | Medium-High | High | Medium-High | Low-Medium |
Pros | User-friendly, low CPU, dynamic panels 25 | Highly scriptable, minimal OS mods, status bar 13 | YAML config, multi-monitor, IPC 15 | Easy to use, stable, part of PowerToys |
Cons | Less “raw” CLI control than Komorebi | Steeper learning curve for full customization | Some user reports of glitches 45 | Not true dynamic tiling |
#B. AutoHotkey (AHK) for Global Keyboard Control and Scripting
AutoHotkey (AHK) is a free, open-source scripting language for Windows that allows users to automate tasks, remap keys, and create custom hotkeys. For replicating your ratpoison environment, AHK is indispensable for:
- Implementing a global prefix key system (your Super_L equivalent).
- Defining custom keyboard shortcuts for window manipulation, application launching (like your exec bindings), and system control.
- Scripting complex behaviors, such as emulating xdotool functionality or custom scripts like rpws.
- Potentially removing window decorations.
Users create text files with an .ahk extension to write scripts.2
#C. Command-Line Interface (CLI) Utilities & Windows Equivalents
To emulate ratpoison’s ability to control system aspects via keyboard commands, a collection of CLI utilities and knowledge of Windows equivalents is beneficial:
- NirCmd by NirSoft: For system control like volume (changesysvolume, setsysvolume, mutesysvolume, changeappvolume).37
- ControlMyMonitor by NirSoft: For monitor settings like brightness (if DDC/CI supported).40
- ShareX: For scriptable screenshots, replacing scrot functionality.20
- WallP: For command-line wallpaper changes, replacing hsetroot or xsetroot -name for basic wallpaper setting.41
- Windows Built-in Tools: PowerShell for various tasks, reg.exe for registry modifications.
- Application Equivalents: For tools like pcmanfm-qt, viewnior, bpytop, etc., you’ll need to find Windows equivalents or ensure the Linux versions have Windows ports. These can then be launched via AHK’s Run command.
#3. Implementing ratpoison-style Keyboard Control with AutoHotkey
The cornerstone of ratpoison interaction is its prefix key (your escape Super_L), followed by a command key.
#A. The Prefix Key (Super_L Equivalent)
Your .ratpoisonrc specifies escape Super_L. In AutoHotkey, Super_L is typically represented as LWin (Left Windows key).13 We’ll use the AHK Input command for its suitability in capturing subsequent keystrokes with timeouts and specific end keys.1
AutoHotkey
; -– In your AutoHotkey script -–
global MyRatpoisonPrefixKey := “LWin” ; Your Super_L
global MyRatpoisonPrefixTimeout := 2000 ; 2 seconds, adjust as needed
Hotkey MyRatpoisonPrefixKey, HandleRatpoisonPrefix
HandleRatpoisonPrefix() {
global ; Make global variables accessible
local next_key_pressed, command_was_executed := false
; Options: L1 (one char), T\<ms\> (timeout), M (modified keys like Ctrl+C), V (visible input)
; EndKeys: {Esc} to cancel prefix mode
Input next\_key\_pressed, "L1 T". MyRatpoisonPrefixTimeout. " M V", "{Esc}"
if (ErrorLevel \= "Timeout" | | ErrorLevel \= "EndKey:Escape" | | next\_key\_pressed \= "") {
; If timed out, Esc pressed, or no valid key, send the original prefix key.
; This allows LWin to still function (e.g., open Start Menu) if no command follows.
SendInput "{". MyRatpoisonPrefixKey. "}"
return
}
; \--- Branch based on 'next\_key\_pressed' (translate your.ratpoisonrc binds here) \---
if (next\_key\_pressed \= "s") { ; Example: Super\_L then s
; Check for s-s (Shift+s) if your TWM handles splits that way or if you script it
; For now, let's assume 's' maps to hsplit
; For Komorebi: Run "komorebic.exe layout split horizontal 0.5"
; For FancyWM (default Shift+Win+H): SendInput "+\#h"
MsgBox "Command: Horizontal Split (s)"
command\_was\_executed := true
} else if (next\_key\_pressed \= "w") { ; Example: Super\_L then w (for launching thorium-browser)
Run "thorium-browser.exe" ; Ensure thorium-browser is in PATH or use full path
command\_was\_executed := true
}
;... Add many more 'else if' blocks for other ratpoison commands...
if (\!command\_was\_executed) {
; If the pressed key didn't match any defined command,
; send the original prefix and the pressed key.
; The 'V' option in Input should handle passing the key through.
; However, explicitly sending might be needed if LWin was "consumed" by the hotkey.
SendInput "{". MyRatpoisonPrefixKey. "}"
SendInput "{Text}". next\_key\_pressed ; Use {Text} for reliable character sending
} } Return ; End of auto-execute section
Note on Input command options 1:
- L1: Wait for a single character.
- T<milliseconds>: Timeout (e.g., T2000 for 2 seconds).
- M: Allows modified keystrokes (e.g., Ctrl+C) to be recognized. Ctrl+A through Ctrl+Z correspond to Chr(1) through Chr(26).
- V: Visible - the user’s keystrokes are sent to the active window if not matched by the Input command’s MatchList or EndKeys. This is crucial for allowing non-command keys to pass through naturally after the prefix.
- EndKeys: A list of keys that terminate the input (e.g., {Esc}).
#B. Scripting Core Window Manipulations (Examples)
- Focus Switching (Up, Down, Left, Right):
- TWM-specific: Run “komorebic.exe focus <direction>” or SendInput “+#{ArrowKey}” for FancyWM.
- AHK: ControlFocus, WinActivate.
- Moving/Swapping Windows (s-Up, s-x):
- TWM-specific: Run “komorebic.exe move <direction>” or SendInput “+#+{ArrowKey}” for FancyWM.
- AHK: WinMove.
- Resizing (r):
- TWM-specific commands are best.
- AHK: WinMove with width/height.
- Splits (s-s hsplit, minus vsplit, equal hsplit):
- Highly TWM-dependent. Run “komorebic.exe layout split <axis> <ratio>” or FancyWM’s panel commands (SendInput “+#h” for horizontal, SendInput “+#v” for vertical).25
- Killing Windows (q delete, s-Escape kill):
- AHK: WinClose “A” (for active window).
- Virtual Desktops/Workspaces/Groups (rpws commands, KP_1 etc.):
- Windows 11 native: SendInput “^#{Left/Right}” (switch), SendInput “^#{d}” (create).
- TWMs have their own (e.g., Komorebi: komorebic.exe workspace <index>). Your rpws scripts would need to be translated to call these TWM commands.
#C. Removing Window Decorations (set border 0)
Your .ratpoisonrc has set border 0. AHK’s WinSet command can attempt to remove standard Windows decorations 43:
- WinSet, Style, -0xC00000, A ; Removes title bar (WS_CAPTION)
- WinSet, Style, -0x800000, A ; Removes thin border (WS_BORDER)
- WinSet, Style, -0x40000, A ; Removes sizing border (WS_THICKFRAME/WS_SIZEBOX) Caveats: This won’t work for all apps (especially UWP or custom-drawn windows) and can sometimes cause issues. Apply selectively using IfWinActive and Window Spy to get ahk_class. Some TWMs might also offer border management.
#4. Replicating Essential .ratpoisonrc Interactions
#A. Application Launcher (s-space exec python3…dratmenu.py)
Your dratmenu.py script acts as a launcher. Windows alternatives include:
- Wox: Extensible with plugins (Python supported, but detailed creation guides were not in provided snippets 6). Default: Alt+Space.
- Ueli: Cross-platform, features “Workflows” for custom tasks.49 Default: Alt+Space.
- Fluent Search: Powerful, indexes files, apps, tabs.51
- PowerToys Run: Part of PowerToys, quick and simple.20 Default: Alt+Space.
Your AHK script would map Super_L then Space to trigger your chosen launcher or your Python script (if it’s adapted for Windows):
AutoHotkey
; Inside HandleRatpoisonPrefix()
else if (next_key_pressed = “ “) { ; Super_L then Space
; Option 1: Run a Windows launcher
; SendInput “!{Space}” ; If launcher uses Alt+Space
; Option 2: Run your Python script (ensure Python is in PATH)
Run “python.exe C:\path\to\your\dratmenu.py”
command_was_executed := true
}
For the most dmenu-like scriptability, Wox or Ueli are strong candidates.
Table 4.1: Windows Application Launcher Comparison
(Refer to Table 4.1 in the original response, it remains largely accurate.)
#B. Status Bar Information (exec env HOME=$HOME rpbar, addhook… exec rpbarsend)
Your setup uses rpbar, updated by hooks.28
- Komorebi: Includes komorebi-bar.exe.13 This is the closest to an integrated solution.
- GlazeWM: Integrates with Zebar.15
- Windows Taskbar: Can be auto-hidden and minimally configured 53, but not a true rpbar replacement.
- AHK GUI: A custom AHK GUI is possible but a very advanced project.
If using Komorebi, its bar might suffice. Otherwise, this is hard to replicate faithfully. The addhook commands in your .ratpoisonrc that call rpbarsend would need to be mapped to AHK’s ShellHook or timer-based checks that then update whatever status display you choose/create, or rely on the TWM’s bar updating itself.
#C. Clipboard Management (clipse related, bind v meta S-Insert)
Your config mentions clipse and a paste binding.
- Windows Clipboard History: Win+V (stores last 25 items, can sync).54 Can be cleared via Settings or PowerShell (with limitations for ::ClearHistory() 17). Get-Clipboard can retrieve content.56
- Ditto: Powerful open-source manager with CLI options like Ditto.exe /Open, Ditto.exe /Paste:(clip_id) 16, making it scriptable.
- PasteBar: Organizes clips, supports Markdown.57 Your bind v meta S-Insert likely pastes from clipse. In AHK, Super_L then v could be:
AutoHotkey
; Inside HandleRatpoisonPrefix()
else if (next_key_pressed = “v”) {
; This emulates Shift+Insert, a common paste shortcut
SendInput “+{Insert}”
; If ‘clipse’ has a Windows CLI for pasting, use that:
; Run “clipse.exe --paste” ; Hypothetical command
command_was_executed := true
}
#D. xdotool Emulation (bind M-1 exec xdotool key --repeat 6 dead_grave)
Windows does not have xdotool. AutoHotkey’s Send / SendInput commands are the primary way to simulate keyboard input.
Your binding bind M-1 exec xdotool key --repeat 6 dead_grave could translate to:
AutoHotkey
; This is a direct hotkey, not part of the prefix system, as M-1 is Alt+1
!1:: ; Alt+1
Loop 6 {
SendInput “{`}” ; Sends a backtick. Adjust if ‘dead_grave’ is different.
; Or, for specific ASCII/Unicode: SendInput “{ASC 096}” or SendInput “{U+0060}”
}
return
Similarly for M-2, M-3, M-4. You’ll need to find the correct AHK syntax for dead_tilde, quotedbl, and apostrophe.
#E. Custom Scripts (rpws, llm_*.sh, split1.sh, thermal.sh)
Scripts like rpws init 9, rpws dump, llm_scrot.sh are custom.
- rpws (RatPoison WorkSpace) commands manage workspaces. These would need to be rewritten as AHK functions or external scripts that call your chosen TWM’s CLI for workspace management (e.g., komorebic.exe workspace <ID>, komorebic.exe move-to-workspace <ID>).
- Shell scripts (.sh) need to be ported to Windows batch, PowerShell, or rewritten in a language available on Windows (like Python, if your dratmenu.py is an example).
- AHK can then Run these Windows-compatible scripts. For example, bind s-u exec /usr/bin/rpws restore… becomes an AHK hotkey calling the translated rpws restore logic.
#5. System Control via Keyboard (Scripting with AHK and CLI Tools)
Your .ratpoisonrc includes bindings for volume, screenshots, etc.
#A. Volume Control (s-F9 toggle, s-F10 5%-, s-F11 5%+)
- nircmd.exe:
- nircmd.exe changesysvolume 3276 (approx 5% of 65535).37
- nircmd.exe mutesysvolume 2 (toggle).37
- App-specific: nircmd.exe changeappvolume focused 0.05 (increase focused app volume by 5%).39
- PowerShell: Can mimic media keys or use COM objects.37
- vccli.exe: Dedicated app-specific volume CLI.58
AHK example for s-F11 (assuming s- means Super_L or Win key):
AutoHotkey
#F11::Run “nircmd.exe changesysvolume 3276” ; Win+F11
#F10::Run “nircmd.exe changesysvolume -3276” ; Win+F10
#F9::Run “nircmd.exe mutesysvolume 2” ; Win+F9
#B. Screen Brightness (Your config doesn’t show explicit brightness binds, but it’s a common need)
- ControlMyMonitor.exe: ControlMyMonitor.exe /ChangeValue Primary 10 5 (increase by 5%).40 Requires DDC/CI.
- PowerShell: (Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1, <level_0_to_100>) (often for built-in displays).59
#C. Screenshots (Home exec scrot -s…, definekey top Print exec xfce4-screenshooter)
- ShareX: Highly scriptable.20
- ShareX.exe -RectangleRegion: Interactive region selection.
- Your scrot -s -e ‘xclip…’ command captures a selection and copies to clipboard. ShareX can do this with a configured “After capture” task to “Copy image to clipboard.” AHK:
AutoHotkey
#Home::Run “ShareX.exe -RectangleRegion” ; Win+Home for region, then configure ShareX task
PrintScreen::Run “ShareX.exe -PrintScreen” ; Or use xfce4-screenshooter if available on Win
- Windows Snipping Tool: Win+Shift+S for region to clipboard.18
#D. Wallpaper Management (s-F2 exec hsetroot -fill…, s-F3 exec xsetroot -name…)
- WallP.exe: WallP.exe 0 “C:\Path\To\Image.jpg” Fill.41
-
AHK/reg.exe: Modify HKCU\Control Panel\Desktop keys (Wallpaper, WallpaperStyle, TileWallpaper) then call DllCall(“SystemParametersInfo”, “UInt”, 20, “UInt”, 0, “Ptr”, 0, “UInt”, 0x01 0x02) to refresh.24 xsetroot -name functionality (setting root window name) doesn’t directly translate; status information would be handled by the chosen status bar.
AHK for s-F2:
AutoHotkey
#F2::Run “WallP.exe 0 ““C:\home\linaro\Desktop\02-media\pics\wallpaper1.png”” Fill” ; Win+F2
#6. Step-by-Step Implementation Guide
#A. Pre-requisites and Initial Setup
- Install a Tiling Window Manager: Choose from Section 2.A (e.g., Komorebi for deeper scripting, FancyWM for ease of use). Follow their specific installation instructions.25
- Install AutoHotkey: Download from autohotkey.com (v1 recommended for these examples). Create MyRatpoisonConfig.ahk.2
- Install Application Launcher: Choose from Section 4.A (e.g., Wox, Ueli).
- Download CLI Utilities: NirCmd, ControlMyMonitor, ShareX, WallP. Place them in a folder (e.g., C:\Utils) and add this folder to your system PATH.
- Install Your Applications: Ensure Windows versions or equivalents of thorium-browser, pcmanfm-qt, bpytop, etc., are installed.
#B. Basic Configuration of the Window Manager
- Consult the chosen TWM’s documentation to set basic preferences (gaps, initial layouts, focus behavior). Komorebi uses komorebi.json 14, GlazeWM uses config.yaml.15 FancyWM has GUI settings.25
#C. Creating the Initial AutoHotkey Script (MyRatpoisonConfig.ahk)
AutoHotkey
#SingleInstance force
#Persistent
SetWorkingDir A_ScriptDir
; -– Global definition for the ratpoison prefix key -–
global rp_prefix_key_ahk_notation := “LWin” ; Your Super_L from ‘escape Super_L’
global rp_prefix_timeout_ms := 2000
; -– Assign the prefix key to its handler function -–
Hotkey rp_prefix_key_ahk_notation, RatpoisonPrefixHandler
RatpoisonPrefixHandler() {
global
local next_key, command_executed := false, input_options
input\_options := "L1 T". rp\_prefix\_timeout\_ms. " M V"
Input next\_key, input\_options, "{Esc}"
if (ErrorLevel \= "Timeout" | | ErrorLevel \= "EndKey:Escape" | | next\_key \= "") {
SendInput "{". rp\_prefix\_key\_ahk\_notation. "}"
return
}
; \--- Translate.ratpoisonrc 'bind' commands here \---
if (next\_key \= "w") { ; Super\_L then w \-\> launch thorium-browser
Run "thorium-browser.exe" ; Ensure it's in PATH or use full path
command\_executed := true
} else if (next\_key \= "h") { ; Super\_L then h \-\> launch bpytop
Run "x-terminal-emulator.exe \-e bpytop" ; Assuming x-terminal-emulator is configured
; Or directly Run "bpytop.exe" if it's a Windows native app
command\_executed := true
} else if (next\_key \= "q") { ; Super\_L then q \-\> delete (close window)
WinClose "A"
command\_executed := true
} else if (next\_key \= "s") { ; Super\_L then s (from 'bind s-s hsplit')
; This is a bit ambiguous with 'bind s-s hsplit' vs 'bind equal hsplit'
; Assuming 's' after prefix is for hsplit
; For Komorebi: Run "komorebic.exe layout split horizontal 0.5"
; For FancyWM: SendInput "+\#h"
MsgBox "Temp: Horizontal Split" ; Replace with actual TWM command
command\_executed := true
} else if (next\_key \= " ") { ; Super\_L then Space \-\> dratmenu.py
Run "python.exe C:\\home\\linaro\\.local\\bin\\dratmenu.py" ; Use correct Windows path
command\_executed := true
}
;... Add more 'else if' blocks from your 'bind' commands...
; Example for a command that was 'bind s-k someaction' (Super\_L \+ Shift \+ k)
; The 'M' option in Input should make next\_key 'K' if Shift+k is pressed.
else if (next\_key \= "K") { ; Super\_L then Shift+k
MsgBox "Action for Super\_L then Shift+K"
command\_executed := true
}
if (\!command\_executed) {
SendInput "{". rp\_prefix\_key\_ahk\_notation. "}"
SendInput "{Text}". next\_key
}
return }
; -– Translate direct ‘bind’ commands (not needing prefix) -–
; Example for: bind M-1 exec xdotool key --repeat 6 dead_grave
!1:: ; Alt+1
Loop 6 {
SendInput “{`}” ; Backtick for dead_grave, adjust if needed
}
return
; Example for: bind Home exec scrot -s -e ‘xclip…’
#Home::Run “ShareX.exe -RectangleRegion” ; Win+Home. Configure ShareX to copy to clipboard.
; Example for: bind s-F11 exec amixer set Master 5%+
#F11::Run “nircmd.exe changesysvolume 3276” ; Win+F11 for vol up ~5%
;… Add other direct binds (s-F10, s-F9, s-F1, s-F2, s-F3 etc.)…
; For s-F1 exec thermal.sh -> #F1::Run “C:\path\to\thermal.bat_or_ps1” (ported script)
; For s-F2 exec hsetroot… -> #F2::Run “WallP.exe 0 ““C:\home\linaro\Desktop\02-media\pics\wallpaper1.png”” Fill”
; For s-F3 exec xsetroot -name “$wspl” -> This is for status bar, handle with TWM’s bar or AHK GUI.
; -– Startup commands from ‘exec’ lines at the end of.ratpoisonrc -–
; Run “alttab.exe” ; If alttab is a specific program
Run “xfce4-power-manager.exe” ; If available and needed on Windows
Run “unclutter.exe --timeout 2 --jitter 5” ; If available
; Run “rpws init 9” ; This would be part of TWM setup or an AHK function call at start
Run “nm-applet.exe” ; If needed
; Run “env HOME=$HOME/.config rpbar” ; Start your status bar if using Komorebi/Zebar or custom
Run “brightnessctl.exe s 7” ; If brightnessctl has a Windows version or use NirCmd/ControlMyMonitor
Run “numlockx.exe” ; If needed
; Run “sh -c ‘nohup sudo openvpn…’” ; Needs specific Windows OpenVPN client setup & CLI
; Run “sh -c ‘nohup /home/linaro/.local/bin/clipse -listen…’” ; Needs clipse ported/configured
; -– Hooks (‘addhook’) -–
; For hooks like ‘addhook switchwin exec rpbarsend’, you’d use AHK’s ShellHook or SetTimer
; to monitor window events and then call the equivalent of ‘rpbarsend’ if you have a custom bar.
; If using Komorebi’s bar, it should update automatically.
Return ; End of auto-execute section
Error Handling Note: For Run commands, consider wrapping them in Try…Catch blocks if the target might not exist or fail, e.g.:
Try Run “nonexistent.exe”
Catch { MsgBox “Failed to run nonexistent.exe” } 31
Admin Privileges: If scripts or commands require admin rights, you might need to run the entire AHK script as administrator, or use Run *RunAs path\to\program.exe within the script for specific commands.
#D. Setting up Application Launcher and Status Bar
- Configure your chosen launcher and status bar (if not using Windows Taskbar).
- Ensure AHK triggers them correctly.
#E. Configuring Tools and AHK Script to Run on Startup
- Place shortcuts to your TWM, AHK script (MyRatpoisonConfig.ahk), launcher, and status bar executables into the Startup folder (shell:startup).61
- You can compile your AHK script to an .exe using Ahk2Exe.47
#7. Fine-Tuning, Troubleshooting, and Adapting Your ratpoisonrc Logic
#A. Addressing Common Issues with Specific Applications
- Use TWM rules (floating/ignore) for problematic apps (Java, Electron, UWP, games).25
- Use AHK’s Window Spy (right-click AHK tray icon) to get ahk_class or window titles for specific IfWinActive conditions or TWM rules.
#B. Tips for Translating Logic from Your ratpoisonrc
- set variable value: AHK variables (myVar := “value”) or TWM settings.
- addhook: AHK SetTimer for polling or ShellHook for event-driven actions. TWMs like Komorebi or GlazeWM might have their own event systems.27
- unmanage rpbar: Your TWM should have a way to ignore your status bar window if it’s a separate application.
Table 7.1: ratpoisonrc to Windows/AHK/TWM Mapping Quick Reference
ratpoisonrc Command | Windows/AHK/TWM Equivalent | Notes |
---|---|---|
escape Super_L | AHK: rp_prefix_key_ahk_notation := “LWin” | Define your prefix key |
bind key action | AHK: if (next_key = “key”) { TWM_Cmd / AHK_Action } | Inside prefix handler function |
bind modifier-key action | AHK: Direct hotkey, e.g., !1:: action (for Alt+1) | Outside prefix handler |
exec program args | AHK: Run “program.exe args” or AHK function call | Ensure program/script is Windows compatible and in PATH or use full path |
set variable value | AHK: variable := value or TWM configuration file setting | For behavior, colors, fonts, gaps - often TWM specific |
set border 0 | TWM config or AHK: WinSet, Style, -0xStyleValue, WinTitle | e.g., WinSet, Style, -0x800000, A (removes WS_BORDER) 43 |
addhook event cmd | AHK: SetTimer, ShellHook, or TWM’s event system | For reacting to window creation, focus changes, etc. |
unmanage window_name | TWM: Configuration rules to float or ignore specific windows | Based on window title or class |
definekey top key action | AHK: Direct hotkey, e.g., PrintScreen:: action | For keys that don’t use the ratpoison prefix |
xdotool… | AHK: SendInput, SendPlay, ControlSend with loops/counts | AHK is the Windows equivalent for input automation |
Custom shell scripts | Port to Batch, PowerShell, Python on Windows, or AHK functions | Call via Run |
#C. Performance Considerations
- Optimize complex AHK scripts; prefer event-driven over polling.
- Most TWMs are lightweight.25 Disable system/TWM animations if needed.14
#D. Debugging
- AHK: MsgBox, ToolTip, ListVars, OutputDebug, main window’s key history.13
- TWMs: Check for logs or debug modes.13
- Launchers: May have debug options.50
#8. Conclusion: Your ratpoison-inspired Windows 11 Desktop
By combining a Windows TWM, AutoHotkey, a suitable launcher, and CLI tools, you can build a Windows 11 environment that strongly emulates your ratpoison setup’s functionality and keyboard-centric nature. This involves translating your .ratpoisonrc logic into AHK scripts and TWM configurations.
Perfect replication is impossible due to OS differences, but a high degree of functional similarity is achievable. This guide provides the foundational blocks and strategies. The process will be iterative as you fine-tune your AHK scripts and TWM settings to match your workflow as closely as possible. Your detailed .ratpoisonrc provides an excellent blueprint for this customization.