Fala pessoal! Para quem usa Linux em um laptop com a tecnologia optimus da NVIDIA, e usa o bumblebee para gerenciar as duas placas de vídeo, às vezes se vê rodando seus aplicativos ou jogos favoritos pelo terminal apenas para poder ativar a placa de vídeo de alta performance com o comando primusrun ou optirun.

Bom, sua dor de cabeça acaba aqui, a não ser que você realmente curta ficar vendo a saída do terminal enquanto joga, por que faz você parecer muito mais cool, neste caso, está tudo certo!

Segue abaixo um passo a passo para fazer seus aplicativos sempre rodar na sua placa de vídeo NVIDIA por padrão, ao invés da placa de vídeo Intel de baixa performance.

1. Criar um alias para o comando

Dessa forma, sempre que você rodar o comando no terminal, ou qualquer outro aplicativo exerno que execute este comando, ele será executado com primusrun. Esta é a solução mais generalizada possível para o problema. No meu exemplo, estarei editando o comando obs para rodar com primusrun.

Execute estes comandos no terminal:

echo 'alias obs="primusrun obs"' >> ~/.bashrc
source ~/.bashrc

Agora, sempre que você executar o comando obs no termina, ele irá rodar primusrun obs.

Se por algum motivo você precisar rodar o comando sem primusrun, será então necessário fazer uma chamada ao caminho absoluto de seu executável. Isso é fácil:

$ /usr/bin/obs

Isso também irá funcionar para os atalhos na área de trabalho e menus do desktop, no caso de estes também executarem este comando relativo. Mas caso eles chamem a executável de forma absoluta, como acima, você terá que editar o lançador também. Para isso, veja o passo 2.

2. Editar o lançador

Encontre onde o arquivo .desktop está. Se for uma aplicação de usuário (como aplicativos instalados no Wine), ele deve estar em ~/.local/share/applications, caso não, estará em /usr/share/applications.

Encontre o arquivo (pode ser um tanto difícil, pois alguns gerenciadores de arquivos mostram o título do aplicativo ao invés do nome do arquivo) e edite com o seu editor de texto favorito.
sudo nano /usr/share/applications/obs.desktop
Encontre a linha Exec= e adicione primusrun ou optirun antes do comando;

[Desktop Entry]
GenericName=Streaming/Recording Software
Comment=Free and Open Source Streaming/Recording Software
Comment[ru]=Бесплатная программа с открытым кодом для записи/трансляции видео
Exec=primusrun /usr/bin/obs
Salve e feche.

Tenha em mente que se o lançador executa o comando relative (somente obs ao invés de /usr/bin/obs), isso irá efetivamente fazer com que o aplicativo seja executado com dois primusrun, como em primusrun primusrun obs, mas isso não causa nenhum problema.

Hi, welcome to my blog! Usually I don't write in english but rather in portuguese, but I decided to share here as well a tutorial I written in Android Enthusiasts SE about how to resize the /system partition of a Samsung Galaxy S2.

This is specially interesting to be able to upgrade your ROM and still be able to flash the most up-to-date version of Google Apps, as with the stock allocated size, it wouldn't be possible anymore.

Before the tutorial, I'd like to note that if I receive good feedbck here, and can create a secondary blog and post there in english as well! I'm a Web developer, and usually I write about technology-related stuff, Linux, Windows and sometimes games.

Alright, now to the tutorial!

Firstly and most important, the credits:

I made this following this great tutorial at XDA-Developers by user metalgearhathaway:http://forum.xda-developers.com/galaxy-s2/development-derivatives/mod-partition-internal-memory-app-t2538947
I used PIT files (I'll explain what they are, don't worry) made from user ElGamal from XDA also, located here (comment number 509).
And a little bit of help from user CrackDaddy, also from XDA.

Second, what you'll need:

  • A machine running Windows. I used Windows 7 Ultimate 64-bits;
  • Odin 3.07. Careful when installing, it is full of optional AdWares. There's also a Linux and Mac version available called JOdin3, but I didn't try it;
  • Flashable ClockWorkMod 6 for Galaxy S II (it is a .tar file with a file named zImage inside);
  • PIT file with desired partition table configuration;
  • Samsung drivers for Galaxy S2. Usually you can install Samsung Kies but there's also a installer just with drivers available;
  • Your original stock unrooted Samsung Jellybean firmware. You can find it at sammobile.com;
  • Any ROM of your choice. I highly recommend the last nightly build of Cyanogenmod 11;
  • Optionally: GApps 20140606 or newer.
I made most of those available in the following bundle file: https://drive.google.com/open?id=0BxccpydIocBpd21FOE5MaGJiMkU&authuser=0
What is missing is GApps, CyanogenMod, and a stock Samsung JellyBean ROM (as it depends of country and carrier, and might not be legal to provide it here).

Third, the default warning:

I am not responsible for anything that might go wrong with your device, neither any of the mentioned users nor anyone here at Stack Overflow or XDA-Developers. This procedure will root your phone if it isn't already and also void your warranty if it isn't already. If anything goes wrong, don't panic, it is most likely fixable by reflashing the stock ROM and starting over again.

Finally, how to:

This will only work with the 16GB International version (GT-I9100) of Samsung Galaxy S II

Firstly, copy CyanogenMod 11 .zip file (or your desired ROM) and optionally GApps .zip file to your external SD card;
Make a backup of everything inside your internal storage, copy it to your computer or somewhere else. It will be completelly erased. Don't worry about your external SD Card, it won't be touched.
Make a NAnd backup of your current ROM, you'll be able to restore it after the repartition. To do it, you must have ClockWorkMod recovery installed, then boot your phone into recovery mode (Volume UP + Home + Power), select backups and restore, then backup to /storage/sdcard1;
When backup finishes, reboot your phone into Download mode (Volume DOWN + Home + Power) and connect your phone to the computer. Let Windows install the drivers. If it fails, try to install Samsung Kies or just the drivers provided in the bundle I made available, and try again.
Open Odin3 as Administrator and connect the phone. It should detect your phone and show it under the label ID:COM, and also in the Message. If it didn't, try to restart your computer, phone, reinstall drivers, check your USB cable, etc., and try again.
Now you'll need to choose a PIT file. PIT means Partition Information Table and it is a Samsung-only thing. In the bundle file, I made available ElGamal's PIT file (I91001GB_6GB.pit) which also resizes /system partition to 1GB, /data to 6GB and the rest goes to internal storage. If you wish different sizes, check the thread at XDA-Developers as he made many different versions available. I also included a PIT file for the default configuration (I9100_2GB-STOCK.pit) if you wish to go back to as it was later.
When you have chosen your PIT file, go to Odin and tick the following checkboxes: Re-PartitionAuto Reboot and F. Reset Time. In the Re-Partition section, click on the PITbutton and select your chosen PIT file. In the Files (Download) section, click on the AP button and select Samsung's stock JellyBean ROM. Double check everything and click Start. This can take a while, go grab a coffee.
After everything finishes, your phone will reboot into the stock Samsung JellyBean ROM. Two things can happen now, or it will work normally and if so you can use it and check if everything is as you want. Or it can ask you for a password to access the "encrypted volume", which is nothing but your internal storage that is not formatted. In both ways, unplug your phone (it it's still plugged) and reboot it into Download mode again.
It is interesting to close and reopen Odin3 to reset the settings. Plug your phone again and wait until Odin3 detects it. This time, leave checked just Auto Reboot and F. Reset Time and make sure Re-Partition is NOT checked. Click on AP button and select the ClockWorkMod Recovery .tar file, then click Start. This one is faster, but if you feel sleepy, go for another coffee ;)
When it finishes, you should have ClockWorkMod Recovery 6 installed in your phone, so go ahead and reboot into Recovery mode. Go to mounts and storage, select format /storage/sdcard0and format it as exfat (if for some reason you have write problems in your internal storage later, come back here and select another format until it works, but exfat should do the trick).
When it finishes, still in Recovery mode, Wipe data/factory resetWipe cache and Wipe Dalvik cache. Let's be sure nothing remains from the previous ROMs.
Now, install zip -> choose zip from /storage/sdcard1 and select the CyanogenMod 11 .zip file (or of your desired ROM) and flash it. Optionally also flash GApps afterwards. Reboot your phone and check if everything is right.
If everything is right, reboot your phone into Recovery mode again, do a new wipe data/factory resetwipe cache and wipe Dalvik cache, and then recover your backed up ROM from the beginning. Reboot your phone.
Check again if everything works right. A few apps might need to be reinstalled (Spotify and Waze are examples) to work correctly again, but that's be only major issue.
Hope everything goes well.