2

On Arch Linux I was able to switch tabs by pressing Alt+[tab_num].

I have to work on Windows, where firefox uses Ctrl+[tab_num].

It's really annoying. Ctrl is not very well positioned for this kind of switching + I am used to Alt+[tab_num] instead of Ctrl+[tab_num].

Is there an easy way how to manage/change this in Firefox ? Any extention that does exactly this ?

Talos
  • 367
  • 3
  • 11

2 Answers2

2

Following the script in https://gist.github.com/zbraniecki/000268ea27154bbccaad190dd479d226. I write a working code(at least in my Firefox) below

manifest.json

{
  "applications": {
    "gecko": {
      "id": "selecttab@braniecki.net",
      "strict_min_version": "48.0"
    }
  },
  "manifest_version": 2,
  "name": "SelectTab Gnome Shortcut Override",
  "version": "1.0",

  "description": "An extension that overrides the default select-tab modifier key.",

  "permissions": ["tabs"],
  "background": {
    "scripts": ["background.js"]
  },
  "commands": {
    "selectTab1": {
      "suggested_key": { "default": "Alt+1" },
      "description": "Activate Tab 1"
    },
    "selectTab2": {
      "suggested_key": { "default": "Alt+2" },
      "description": "Activate Tab 2"
    },
    "selectTab3": {
      "suggested_key": { "default": "Alt+3" },
      "description": "Activate Tab 3"
    },
    "selectTab4": {
      "suggested_key": { "default": "Alt+4" },
      "description": "Activate Tab 4"
    },
    "selectTab5": {
      "suggested_key": { "default": "Alt+5" },
      "description": "Activate Tab 5"
    },
    "selectTab6": {
      "suggested_key": { "default": "Alt+6" },
      "description": "Activate Tab 6"
    },
    "selectTab7": {
      "suggested_key": { "default": "Alt+7" },
      "description": "Activate Tab 7"
    },
    "selectTab8": {
      "suggested_key": { "default": "Alt+8" },
      "description": "Activate Tab 8"
    },
    "selectTab9": {
      "suggested_key": { "default": "Alt+9" },
      "description": "Activate Tab 9"
    }
  }
}

backgroud.js

browser.commands.onCommand.addListener(async (command) => {
  let num = parseInt(command.substr(9, 10)) - 1;
  let tabs = await browser.tabs.query({currentWindow: true});
  if (tabs.length < num) {
    return;
  }

  if (num === 8) {
    browser.tabs.update(tabs[tabs.length-1].id, {active: true});
  } else {
    browser.tabs.update(tabs[num].id, {active: true});
  }
});

Then you may refer to How to publish a FireFox WebExtension for local installation only? to install it permanently.

Ynjxsjmh
  • 16,448
  • 3
  • 17
  • 42
2

I was annoyed at this too, and made an addon to deal with it which you should be able to install from the official website.