Using your Stream Deck to toggle VSCode presentation mode

Using your Stream Deck to toggle VSCode presentation mode header image

With working from home being the new normal I got a Stream Deck as Christmas present. Not quite sure if I need it still is a nice gadget. I spend some time setting it up during the holidays. During the setup I figured that one of the most common things I do during the day is switching between sharing my screen and writing code.

Presenting code vs Writing code

I already wrote about my ideal setup for working. I also did a blogpost on switching my VSCode settings. I realized that switching between presentation mode and coding mode should be a button. As it turns out you need a plugin to run advanced commands. So I picked the BarRaider – Streamdeck advanced launcher and did my setup from there. Using that plugin you can start any application, including adding arguments. I used my previous script to switch between light and dark mode. I also tweaked the zoom level of VSCode. I put that all in a simple PowerShell Script that would just toggle the presentation mode or not. I then added a new button. The button starts the PowerShell preview application, starting in C:\Program Files\PowerShell\7-preview. By passing the following arguments -File "C:\git\sbx\streamdeck\scripts\vscode.ps1" I am sure that my script is executed.

Stream Deck BarLauncher Config

The script is straight forward, only thing I changed compared to the previous blog is to up the font-size a bit.

$settingsPath = "$env:APPDATA\Code\User\settings.json";
$colorSetting = 'workbench.colorTheme';
$fontSetting = 'editor.fontSize';

$data = $jsondata = Get-Content -Raw -Path $settingsPath -ErrorAction silentlycontinue | ConvertFrom-Json

if($data){
    if($data.$colorSetting) {
        $data.PSObject.Properties.Remove($colorSetting)
    }
    else {
        $data | Add-Member -Name $colorSetting -Value "Default Light+" -MemberType NoteProperty
    }
    if($data.$fontSetting) {
        $data.PSObject.Properties.Remove($fontSetting)
    }
    else {
        $data | Add-Member -Name $fontSetting -Value "25" -MemberType NoteProperty
    }
}

$data | ConvertTo-Json | Out-File $settingsPath -Encoding utf8

Pressing the button on my Stream Deck now switched my VSCode realtime, making switching between working and sharing my screen even easier.

Stream Deck Toggle

I am still looking at switching my screen resolution using the stream deck as well. That way it would be even easier to switch between writing code, presenting or writing documentation. As context switching is hard as it is, anything that makes it easier is worth investing in.

Loading comments…