PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Profiles in Keyboard Manager

Open saahmedm opened this issue 5 years ago • 19 comments

Have both predefined profiles (e.g. mac/linux/etc) available to user, and also allow the user to create custom profiles. Provide a quick way to switch between profiles.

saahmedm avatar Apr 02 '20 16:04 saahmedm

What's the status of this feature?

snorlaxjones avatar Oct 04 '20 04:10 snorlaxjones

This would be a big improvement. I'm curious if you've considered a simple text file import/export feature as a first iteration, as mentioned in microsoft/PowerToys#4452. This would be less effort to implement and provide a lot of the benefits.

It also provides benefits that the profile feature doesn't

  • Makes sharing settings across systems and with others easy
  • Creating/editing a large number of mappings (more than 5) as text is easier than using the UI
  • PowerToys already targets power users, which want and expect this kind of control
  • Extending this across PowerToys would probably be straightforward as well

freshone avatar Jul 18 '21 20:07 freshone

Even better would be have profiles tied to keyboard ID (I am hoping app could query usb/bluetooth properties of keyboards).

vmiheer avatar Jul 19 '21 20:07 vmiheer

@freshone I did a little bit of digging in the source because I found it hard to believe it wasn't already already set up that way. It will take a little bit of digging, but as far as I can tell, if you navigate to

C:\Users\jchun\AppData\Local\Microsoft\PowerToys\Keyboard Manager

you should see json files and editing/switching them should be fairly straightforward

jonchun avatar Aug 11 '21 17:08 jonchun

For example, this would be amazing for temporarilty turning these keys into a numpad on TKL keyboards. image

drandarov-io avatar Dec 13 '21 17:12 drandarov-io

@jonchun Thanks for pointing to the location where the settings file is stored. This should be added in the documentation, as it is also a partial solution to #4452

Jolt151 avatar Dec 16 '21 00:12 Jolt151

You can prepare your json profiles, for example mac.json and win.json in the C:\Users<your user>\AppData\Local\Microsoft\PowerToys\Keyboard Manager

Then make a powershell script, for example to switch to the win profile:

$ErrorActionPreference = 'SilentlyContinue'
cd $HOME
cd '.\AppData\Local\Microsoft\PowerToys\Keyboard Manager'
cp win.json default.json
taskkill /F /IM PowerToys.KeyboardManagerEngine.exe
& 'C:\Program Files\PowerToys\modules\KeyboardManager\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe'

AndriyTemplafy avatar May 18 '22 16:05 AndriyTemplafy

You can prepare your json profiles, for example mac.json and win.json in the C:\Users\AppData\Local\Microsoft\PowerToys\Keyboard Manager

Then make a powershell script, for example to switch to the win profile:

$ErrorActionPreference = 'SilentlyContinue'
cd $HOME
cd '.\AppData\Local\Microsoft\PowerToys\Keyboard Manager'
cp win.json default.json
taskkill /F /IM PowerToys.KeyboardManagerEngine.exe
& 'C:\Program Files\PowerToys\modules\KeyboardManager\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe'

Thank you so much for this. I agree with https://github.com/microsoft/PowerToys/issues/1881#issuecomment-995321972 this should be added to the docs, just like it already is documented for FancyZones

AJolly avatar Oct 14 '22 21:10 AJolly

Thank you @AndriyTemplafy for your comment's explicit instructions that will allow a user to change keyboard mappings through a shortcut (that points to a copy of the PowerShell script you provided).

Agree with @AJolly that it should be added to the docs.

A digression: Kudos to the folks that worked on the Keyboard-Manager Wiki page. It exemplifies great documentation, especially at a requirements/analysis/design/tech level that seems appropriate for a repository wiki page.

jon-freed avatar Oct 20 '22 14:10 jon-freed

So what's the status of this? Use the workaround provided above and be grateful, or is it coming anytime soon?

After reading the above comments, I took a shot at making a simple powershell GUI selector for profiles based on this list box code: https://learn.microsoft.com/en-us/powershell/scripting/samples/selecting-items-from-a-list-box?view=powershell-7.3 and plopping the below code block toward the end. Hopefully this is useful to anyone else wanting to select different profiles easily, and as you can see it's based off previous work, so here's my incremental addition while we wait for an integrated solution

#get all json files other than settings and default from keyboard manager folder
$ErrorActionPreference = 'SilentlyContinue'
cd $HOME
cd '.\AppData\Local\Microsoft\PowerToys\Keyboard Manager'
$profiles = dir *.json | select Name |Where-Object {$_.name -ne "settings.json" -and  $_.name -ne "default.json"}

#Create backup of default.json first run
$bak = '.\default.json.bak'
if (!(test-path $bak)){
    echo "making backup $bak"
    cp default.json $bak
}

#build list box 
foreach ($profile in $profiles)
{
    [void] $listBox.Items.Add($profile.name) 
}

$form.Controls.Add($listBox)
$form.Topmost = $true
$result = $form.ShowDialog()

#act on result copy selected json file over default.json and restart keyboard manager
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
    $x = $listBox.SelectedItem
    $x
    cp $x default.json
    taskkill /F /IM PowerToys.KeyboardManagerEngine.exe
    & 'C:\Program Files\PowerToys\modules\KeyboardManager\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe'
}

ImCoKeMaN avatar Aug 20 '23 00:08 ImCoKeMaN

Exporting the mappings to a file so that they can be imported (merged!) into another system's mappings is a must-have if you ask me. Especially for painful-to-configure mappings that use keys that are not easy to find in the drop-down listboxes.

sba923 avatar Oct 16 '23 04:10 sba923

I'd really like to see this feature in the near future. Or yesterday.

dolodobendan avatar Oct 31 '23 15:10 dolodobendan

Have both predefined profiles (e.g. mac/linux/etc) available to user, and also allow the user to create custom profiles. Provide a quick way to switch between profiles.

I hope to see this one VERY SOON! Pretty please!

CattronC avatar Jan 07 '24 22:01 CattronC

The feature already exists in Karabiner-Elements for macOS. https://karabiner-elements.pqrs.org/docs/manual/operation/profiles/ https://github.com/pqrs-org/Karabiner-Elements It seems we can take something from them.

j824h avatar Jan 15 '24 16:01 j824h

What is the status of this feature?

hermoron avatar Apr 24 '24 12:04 hermoron

Pinging on this as well. Big pain

therealpeterhua avatar Jul 14 '24 06:07 therealpeterhua