Skip to content

Instantly share code, notes, and snippets.

@shalva97
Created November 6, 2020 16:46
Show Gist options
  • Select an option

  • Save shalva97/2f4d7bd5e17c9b7601b6dbba0335a7ff to your computer and use it in GitHub Desktop.

Select an option

Save shalva97/2f4d7bd5e17c9b7601b6dbba0335a7ff to your computer and use it in GitHub Desktop.

Revisions

  1. shalva97 created this gist Nov 6, 2020.
    36 changes: 36 additions & 0 deletions adb-layout-bounds.fish
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    function adb-layout-bounds
    if test $argv[1] != false; and test $argv[1] != true;
    echo wrong arguments, use true or false
    return 1
    end
    switch (__number_of_connected_devices)
    case 0
    echo no devices connected
    return 1
    case 1
    __enable-layout-bounds $argv[1]
    case '*'
    __more-than-one-device $argv[1]
    end
    end

    function __enable-layout-bounds
    adb shell setprop debug.layout $argv[1]
    adb shell service call activity 1599295570
    echo bounds enabled
    end

    function __more-than-one-device
    set chosenDevice (__choose_device)
    adb -s $chosenDevice shell setprop debug.layout $argv[1]
    adb -s $chosenDevice shell service call activity 1599295570
    echo bounds enabled for $chosenDevice
    end

    function __number_of_connected_devices
    echo (adb devices | tail -n +2 | string match -r '.+'| wc -l)
    end

    function __choose_device
    echo (adb devices | tail -n +2 | fzf | awk '{print $1}')
    end