2

quick version:

I want to pass studio.vmoptions arguments to while executing studio.sh directly on the command line, instead of the actual vmoptions file.

Is it possible? How?

for example, something like ./studio.sh -Dhidpi=true.

use case:

latest version of Android Studio adds support for HiDpi screens for Windows and Linux. Adding the -Dhidpi=false or -Dhidpi=true to the studio.vmoptions file will activate/deactivate the feature.

My problem is that sometimes I work on a 24" FullHD screen (-Dhidpi=false) and other times directly on the laptop 11" FullHD screen (-Dhidpi=true).

I would like to quick/easy be able to launch Android Studio with true or false without having to edit the vmoptions every.single.time. I believe that some type of cmd line argument would be the best, but I'm open to suggestions that doesn't involve creating a custom script to modify the vmoptions before launching it.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • 1
    unfortunately you can't provide parameters to the executable. What you could do is to keep two different option files and change `STUDIO_PROPERTIES` env. But, off course, you have to wrap `studio` in a script – Blackbelt May 12 '15 at 08:09
  • thanks @Blackbelt so I guess I'll just have two copies of the vmoptions, like `studio.hidpi` and `studip.lowdpi`, and have another script that replaces the file to the `studio64.vmoptions` and then call `studio.sh` – Budius May 12 '15 at 08:13
  • 1
    if you don't want to replace file, call `export STUDIO_PROPERTIES` with the path of the file you want to use – Blackbelt May 12 '15 at 08:14
  • @Blackbelt I'm not sure what u meant. Would u mind write as a full answer please? – Budius May 12 '15 at 08:14

2 Answers2

1

Following on @Blackbelt advice I've done two .sh scripts and two vmoptions files (all outside android-studio folder so that during updates all goes smoothly.

the .sh script is a very simple two line like this:

export STUDIO_VM_OPTIONS=/home/budius/studio64.vmoptions.hiDpi
/home/budius/android-studio/bin/studio.sh

now I can init any version just calling the correct script.

Budius
  • 39,391
  • 16
  • 102
  • 144
1

Unfortunately is not yet possible. What you could is to provide two different files. The documentation says that you can export the environment variable STUDIO_VM_OPTIONS - which vmoptions file to use -. What you could do is to wrap studio.sh, in another script, and place it in /usr/local/bin. Your script could accept a parameter that indicates you which file to use. Could be for instance the path of the file itself, and export STUDIO_VM_OPTIONS before executing studio.sh.

#!/bin/sh
export STUDIO_VM_OPTIONS=$1
studio.sh
Blackbelt
  • 156,034
  • 29
  • 297
  • 305