I'm sure I'm not the only one in this situation: I run Ubuntu 16 on my laptop, and I use that to connect to my workstation in the office.
Now there are a couple things that I have to do every day when I connect to my workstation, such as fixing my bluetooth mouse speed, setting the right resolution for both screens and restoring my wallpaper with nitrogen. For each of these tasks I have a (startup) script which works fine, but when I connect my second screen, the laptop is already booted.
So my question is, next to start-up applications, how could I (i.e.) run nitrogen --restore
and scale down the resolution on my laptop (from 2560x1600 to 1440x900) when I connect the second screen?
What I do now is run all seperate scripts again manually, which isn't a big deal, but we don't use Ubuntu to just accept how it is, right? ;)
To clarify; my question isn't too specific for these tasks, but more in a general sense; how could I fire anything from the terminal on specific actions like "input of display detected"?
Use a tiny indicator that automatically adds your scripts to a menu
Instead of creating multiple watch- procedures for each and every possible event that could take place, I'd suggest using a "one for all" solution like below.
The indicator script automatically adds your scripts to the indicator menu, if you place them in the same directory as the indicator. This way your setup scripts will be easily available from the GUI.
The indicator
How to use
showscripts.py
Copy the icon below (right- click -> save), save it as (exactly)
icon.png
in one and the same directory as the scriptFor each of your settings commands, create a small script:
Name them (no spaces), but make sure to use the
.sh
extension. Copy or move the scripts into the same folder as where you keep the indicator script.Now you can make as many menu items (scripts) as you like,
Test- run the indicator by the command:
If all works fine, add to Startup Applications: Dash > Startup Applications > Add. Add the command:
Explanation
.sh
extension. These files are made executable automatically.Other options?
I would however go for the indicator menu. Once setup, you can easily add, remove or edit functionality by simply moving around small scripts.