LGUG2Z / komorebi

A tiling window manager for Windows 🍉
https://lgug2z.github.io/komorebi/
Other
9.59k stars 198 forks source link

Launch on startup #383

Closed gldtn closed 1 year ago

gldtn commented 1 year ago

Can someone help/explain and maybe @LGUG2Z can add to the readme on how to launch komorebi at startup?

Yabai does it through brew services, does scoop have anything similar?

@LGUG2Z Thanks for creating this, been looking for something alike for years to run on my work computer 😄

hanzsalat commented 1 year ago

My solution was to add an shortcut into my user startup folder which opens up PowerShell with the given start command

here is my code to generate the shortcut file with the start command and other parameters:

# create shortcuts in startup for komorebi and nircmd
# path to windows startup folder
    $startupPath = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup"

# scriptblock for creating a shortcut
    $createLink = {
        param($name,$sourceExe,$argumentsExe,$destination)
        $WshShell = New-Object -comObject WScript.Shell
        $shortcut = $WshShell.CreateShortcut("$destination\$name.lnk")
        $shortcut.TargetPath = $sourceExe
        $shortcut.Arguments = $argumentsExe
        $shortcut.Save()
    }

# init $list as arraylist
    $list = [System.Collections.ArrayList]::new()

# add nircmd to list
    [void]$list.Add(@{
        name = 'nircmd'
        sourceExe = (Get-Command nircmd).Path
        argumentsExe = 'win trans class Shell_TrayWnd 255'
        destination = $startupPath
    })

# add komorebi to list
    [void]$list.Add(@{
        name = 'komorebi'
        sourceExe = "powershell.exe"
        argumentsExe = '-WindowStyle hidden -Command komorebic start --await-configuration'
        destination = $startupPath
    })

# create shortcut for every item in $list
    foreach ($item in $list) {
        if (!(Test-Path -Path "$startupPath\$($item.name).lnk")) {
            & $createLink @item
        } else {
            $null = Remove-Item -Path "$startupPath\$($item.name).lnk"
            & $createLink @item
        }
    }

then use the .config folder to add your configuration to komorebi, its explained in the README / Install manual how to do so

devkinetic commented 1 year ago

You can do the same thing in task scheduler image

gldtn commented 1 year ago

Thanks for the reply guys.. got it to work 😁

NormTurtle commented 1 year ago

any easy ? way without tweaking system internal settings?

devkinetic commented 1 year ago

@omaru-ok If you can't edit settings, for example from a limited account, your best bet would be to just make a desktop shortcut.

NormTurtle commented 1 year ago

not that one @devkinetic i mean to say , can i put
*.ps1 in shell:startup

azinsharaf commented 1 year ago

i put a startup.bat in shell:startup folder with the following context: komorebic start --await-configuration It works fine. I just can't run it completely silent yet.

marad commented 1 year ago

TBH I simply added this lines to beginning of my AutoHotkey configuration:

Stop()
Run, komorebic.exe start, , Hide

The Hide option makes it completely silent @azinsharaf. The Stop() instruction handles AHK script reloads

And the shortcut to my AHK configuration I just put into shell:startup. Works like a charm.

Sidenote for anyone wondering what the heck does shell:startup means: If you press Windows+R then the Run window will popup. If you type in shell:startup and press enter it will open your autostart directory - any executable file placed there would run at Windows startup. Pic related: image

Maybe some hints on how to run on startup could be placed in the readme or some docs to help others?

azinsharaf commented 1 year ago

not sure why auto start is not working for me. If i double click on vbs file it works but it doesn't auto start (it is in shel:startup folder)

QuinnCiccoretti commented 1 year ago

TBH I simply added this lines to beginning of my AutoHotkey configuration:

@marad Are you referring to the komorebi.ahk? Or a different autohotkey configuration? Thanks.

marad commented 1 year ago

Yes I have this in my hotkey configuration script at the top. If you add Ahk code BEFORE first hotkey definition it will run at startup.

LGUG2Z commented 1 year ago

v0.1.17 has been released which includes static configuration loading.

I would be interested to see feedback from you all about the reliability of autostarting when using the komorebic start --config your-config.json --whkd command.

LGUG2Z commented 1 year ago

I have verified the following method as working on a W11 VM:

I believe this is pretty much what @hanzsalat suggested in an earlier post.

I'll be closing this and related issues, and working towards commands that automate the creation of this shortcut file for autostarting komorebi on boot, based on espanso's approach (https://github.com/espanso/espanso/commit/64886ff436c9d0af4758a0cc6f04d991b8ad0134), which also uses the Startup folder shortcut method.