Archives

Mac: swich language with caps-lock

Karabiner-Elements script to:
Switch “en” <-> “he” language using CapsLock.
Shift-CapsLock -> CapsLock

"rules": [
{
    "description": "caps_lock switch en <-> he (grebulon)",
    "manipulators": [
        {
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "mandatory": [
                        "shift"
                    ],
                    "optional": [
                        "caps_lock"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "caps_lock"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "input_sources": [
                        {
                            "language": "en"
                        }
                    ],
                    "type": "input_source_if"
                }
            ],
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "select_input_source": {
                        "language": "he"
                    }
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "input_sources": [
                        {
                            "language": "he"
                        }
                    ],
                    "type": "input_source_if"
                }
            ],
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "select_input_source": {
                        "language": "en"
                    }
                }
            ],
            "type": "basic"
        }
    ]
}
]

This entry was posted on July 2, 2020, in blog, mac.

Android: Customize which radios to disable in Airplane Mode

There are 5 radios in an Android device: Cellular, WiMax, BlueTooth, WiFi and NFC. It is possible to control which are turned off when going into airplane mode.

The first command (settings get) will list the radios that will be turned off when entering airplane mode.
If you don’t want to turn off WiFi and BlueTooth in airplane mode, the second command (settings put) will do that.

> adb shell
$ settings get global airplane_mode_radios
cell,bluetooth,wifi,nfc,wimax
$ settings put global airplane_mode_radios cell,nfc,wimax

Alternatively you can do the same via content resolver:

> adb shell
$ content query --uri content://settings/global --projection name:value --where "name='airplane_mode_radios'"
Row: 0 name=airplane_mode_radios, value=cell,bluetooth,wifi,nfc,wimax
$ content update --uri content://settings/global --bind value:s:'cell,nfc,wimax' --where "name='airplane_mode_radios'"

Moreover, you can control which radios can be toggled on and off while in airplane mode using the following setting:

$ settings get global airplane_mode_toggleable_radios

Via: StackExchange Android and XDA.

This entry was posted on April 24, 2020, in android, blog.

Multi Row Tabs in Firefox 71+

  1. Open about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to true.
  2. Open a new tab on about:support and click the button next to “Profile Folder
  3. Go to the “chrome” directory at the profile folder, or create it if it doesn’t exist.
  4. Create a file named “userChrome.css” (if it doesn’t exist) and open it in a text editor.
  5. Copy the css code from below (based on multi-row_bookmarks.css)
    (copy of the css is at the bottom of this post)
  6. Paste it into userChrome.css and save.
  7. Restart Firefox

More firefox tweaks at firefox-csshacks

userChrome.css

/* Makes tabs to appear on multiple lines */
/* Tab reordering will not work and can't be made to work */
/* You can use multi-row_tabs_window_control_patch.css to move window controls to nav-bar*/

/* It's recommended to move tabs new-tab-button outside tabs toolbar */

/* Change the --multirow-n-rows to change maximum number of rows before the rows will start to scroll  */
/* This maximum visible rows won't work before Fx66 */
/* So this setting does nothing on Fx65 and all tab rows will be shown */
:root{
    --multirow-n-rows: 5;
    --multirow-tab-min-width: 60px;
    --multirow-tab-dynamic-width: 1; /* Change to 0 for fixed-width tabs using the above width. */
}

/* Scrollbar can't be clicked but the rows can be scrolled with mouse wheel */
/* Uncomment the next line if you want to be able to use the scrollbar with mouse clicks */

/* .tabbrowser-arrowscrollbox{ -moz-window-dragging: no-drag } */

/* Uncommenting the above makes you unable to drag the window from empty space in the tab strip but normal draggable spaces will continue to work */

#tabbrowser-tabs{
  min-height: unset !important;
  padding-inline-start: 0px !important
}
/* Selectors for Firefox 71+ */
/* These are not tabs toolbar specific but horizontal scrollbox isn't used elsewhere, except in bookmarks toolbar but there it doesn't have [part] attribute since it's not in shadow-root */
@-moz-document url(chrome://browser/content/browser.xhtml){
  .scrollbutton-up[orient="horizontal"][part]~spacer,
  .scrollbutton-up[orient="horizontal"][part],
  .scrollbutton-down[orient="horizontal"][part]{ display: none }

  scrollbox[part][orient="horizontal"]{
    display: flex;
    flex-wrap: wrap;
    overflow-y: auto;
    max-height: calc(var(--tab-min-height) * var(--multirow-n-rows));
    scrollbar-color: currentColor transparent;
    scrollbar-width: thin;
  }
}

/* Test for Firefox > 66 */
@supports (inset-block:auto){
  #tabbrowser-tabs > .tabbrowser-arrowscrollbox > .arrowscrollbox-scrollbox{
    display: flex;
    flex-wrap: wrap;
    overflow-y: auto;
    max-height: calc(var(--tab-min-height) * var(--multirow-n-rows));
    scrollbar-color: var(--toolbar-bgcolor) var(--lwt-accent-color);
    scrollbar-width: thin;
  }
  #tabbrowser-tabs > .tabbrowser-arrowscrollbox,
  #tabbrowser-arrowscrollbox{
    overflow: -moz-hidden-unscrollable;
    display: block;
  }
}

/* Test for Firefox < 66 */
@supports not (inset-block:auto){
  #tabbrowser-tabs > .tabbrowser-arrowscrollbox{
    min-height: unset !important;
  }
  #tabbrowser-tabs .scrollbox-innerbox{
    display: flex;
    flex-wrap: wrap;
  }
  #tabbrowser-tabs .arrowscrollbox-scrollbox {
    overflow: -moz-hidden-unscrollable;
    display: block;
  }
}

.tabbrowser-tab{ height: var(--tab-min-height); }
#tabbrowser-tabs .tabbrowser-tab[pinned]{
  position: static !important;
  margin-inline-start: 0px !important;
}

.tabbrowser-tab[fadein]:not([pinned]){
  min-width: var(--multirow-tab-min-width) !important;
  flex-grow: var(--multirow-tab-dynamic-width);
  /*
  Uncomment to enable full-width tabs, also makes tab dragging a tiny bit more sensible
  Don't set to none or you'll see errors in console when closing tabs
  */
  /*max-width: 100vw !important;*/
}

.tabbrowser-tab > stack{ width: 100%; height: 100% }

#scrollbutton-up,
#scrollbutton-down,
#scrollbutton-up~spacer,
#tabbrowser-tabs .scrollbutton-up,
#tabbrowser-tabs .scrollbutton-down,
#alltabs-button,
:root:not([customizing]) #TabsToolbar #new-tab-button,
#tabbrowser-tabs spacer,
.tabbrowser-tab::after{ display: none !important }
This entry was posted on December 4, 2019, in blog, firefox.

Show www and https in Chrome omnibar

[OBSOLETE the steady-state options are gone from Chrome – need to find another way]

To prevent chrome from removing “trivial” subdomains follow these steps:

  1. Go to: chrome://flags/#omnibox-ui-hide-steady-state-url-scheme-and-subdomains.
  2. Find “Omnibox UI Hide Steady-State URL Scheme” and change it to Disabled.
  3. Find “Omnibox UI Hide Steady-State URL Trivial Subdomains” and change it to Disabled.
  4. Click “Relaunch Now” .

Firefox tweak: more compact tabs

[OBSOLETE stopped working with firefox 71]

  1. Open about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to true.
  2. Open a new tab on about:support
  3. Click the button next to “Profile Folder”
  4. Go to the “chrome” directory at the profile folder, or create it if it doesn’t exist.
  5. Create a file named “userChrome.css” (if it doesn’t exist) and open it in a text editor.
  6. Copy the css code from github.com/andreicristianpetcu/UserChrome-Tweaks
    (copy of the css is at the bottom of this post)
  7. Paste it into userChrome.css and save.
  8. Restart Firefox

userChrome.css

/* 
* Makes tabs only 22px high rather than the default 29px
* Only works on compact mode, otherwise tab height will be normal
*/

[uidensity="compact"]:root {
  --tab-min-height: 22px !important;
  --newtab-margin: -3px 0 -3px -3px !important;
}

.tabbrowser-tab {
  max-height: var(--tab-min-height) !important;
}

.tabs-newtab-button{
  margin: var(--newtab-margin) !important;
}
This entry was posted on November 28, 2017, in blog, firefox.

Firefox tweaks

Decrease session store interval

Open about:config and set browser.sessionstore.interval to 1800000 (this means 30 minutes). Now, Firefox will save the session once every 30 mins instead of every 15 seconds.

Disable save to pocket icon

Open about:config and set extensions.pocket.enabled to false

This entry was posted on November 27, 2017, in blog, firefox.

Multi Row Tabs in Firefox Quantum

[OBSOLETE stopped working with firefox 71]

The Tab Mix Plus addon stopped working with v57 :-(

  1. Open about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to true.
  2. Open a new tab on about:support
  3. Click the button next to “Profile Folder”
  4. Go to the “chrome” directory at the profile folder, or create it if it doesn’t exist.
  5. Create a file named “userChrome.css” (if it doesn’t exist) and open it in a text editor.
  6. Copy the css code from github.com/andreicristianpetcu/UserChrome-Tweaks
    (copy of the css is at the bottom of this post)
  7. Paste it into userChrome.css and save.
  8. Restart Firefox

Update for v58: Changed .tabbrowser-tabs to #tabbrowser-tabs.

Update for v65: Removed #titlebar related stuff

userChrome.css

.tabbrowser-tab:not([pinned]) {
    flex-grow:1;
    min-width:150px;
}
.tabbrowser-tab,.tab-background {
    height:var(-tab-min-height);
}
.tab-stack {
    width: 100%;
}
#tabbrowser-tabs .scrollbox-innerbox {
    display: flex;
    flex-wrap: wrap;
}
#tabbrowser-tabs .arrowscrollbox-scrollbox {
    overflow: visible;
    display: block;
}
#tabbrowser-tabs .scrollbutton-up,#tabbrowser-tabs .scrollbutton-down,#alltabs-button,.tabbrowser-tab:not([fadein]){
    display: none;
}
#main-window[sizemode="maximized"] #TabsToolbar{
    margin-left:var(-tab-min-height);
}
/*
#titlebar,#titlebar-buttonbox{
    height:var(--tab-min-height) !important;
}
#titlebar{
    margin-bottom:calc(var(--tab-min-height)*-1) !important;
}
#main-window[sizemode="maximized"] #titlebar{
    margin-bottom:calc(6px + var(--tab-min-height)*-1) !important;
}
#titlebar:active{
    margin-bottom:0 !important;
}
#titlebar:active #titlebar-content{
    margin-bottom:var(--tab-min-height) !important;
}
*/

Based on instructions here.