Replace Firefox with Librewolf

I had to switch to using `ahk_exe` for identifying the windows rather
than `ahk_class` because Librewolf's windows' class is
`MozillaWindowClass`, just like Firefox. That means that, if there was
already a Firefox window open, my shortcut would activate that window
instead of launching Librewolf.
This commit is contained in:
Fernando Schauenburg 2025-03-14 15:12:55 +01:00
parent 93997c2cdf
commit fd356cdc61

View file

@ -7,7 +7,7 @@
try TraySetIcon("img\win_manager.ico") try TraySetIcon("img\win_manager.ico")
TERMINAL_WIN := "ahk_class mintty" TERMINAL_EXE := "ahk_exe mintty.exe"
TERMINAL_CMD := " TERMINAL_CMD := "
(LTrim Join`s (LTrim Join`s
C:\Users\fernando.schauenburg\AppData\Local\wsltty\bin\mintty.exe C:\Users\fernando.schauenburg\AppData\Local\wsltty\bin\mintty.exe
@ -17,9 +17,8 @@ TERMINAL_CMD := "
- -
)" )"
BROWSER_WIN:= "ahk_class MozillaWindowClass" BROWSER_EXE := "ahk_exe librewolf.exe"
; BROWSER_CMD:= "C:\Program Files\Mozilla Firefox\firefox.exe" BROWSER_CMD := "C:\Program Files\LibreWolf\librewolf.exe"
BROWSER_CMD:= "C:\Users\fernando.schauenburg\AppData\Local\Mozilla\Firefox\firefox.exe"
; Returns the rectangle (position & size) of a given monitor. ; Returns the rectangle (position & size) of a given monitor.
MonitorGetRect(N) MonitorGetRect(N)
@ -109,15 +108,15 @@ WinSetMonitor(target, WinTitle:="A")
WinSetRelativeRect(WinGetRelativeRect(WinTitle), target, WinTitle) WinSetRelativeRect(WinGetRelativeRect(WinTitle), target, WinTitle)
} }
openProgram(WinTitle, Target, WorkingDir, rect?) openProgram(WinExe, Target, WorkingDir, rect?)
{ {
if WinExist(WinTitle) { if WinExist(WinExe) {
WinActivate(WinTitle) WinActivate(WinExe)
} else { } else {
Run(Target, WorkingDir) Run(Target, WorkingDir)
if IsSet(rect) if IsSet(rect)
if WinWait(WinTitle,,5) if WinWait(WinExe,,5)
WinSetRelativeRect(rect, 1, WinTitle) WinSetRelativeRect(rect, 1, WinExe)
} }
} }
@ -187,6 +186,6 @@ step := 50 ; dx dy
!^Numpad6:: WinTranslate( step, 0) ; right (L) !^Numpad6:: WinTranslate( step, 0) ; right (L)
; Launch programs ; Launch programs
!^+t::openProgram(TERMINAL_WIN, TERMINAL_CMD, A_Temp, POS.mainFocus) !^+t::openProgram(TERMINAL_EXE, TERMINAL_CMD, A_Temp, POS.mainFocus)
!^+b::openProgram(BROWSER_WIN, BROWSER_CMD, A_Temp, POS.mainFocus) !^+b::openProgram(BROWSER_EXE, BROWSER_CMD, A_Temp, POS.mainFocus)