Last week I was approached by a colleague who wanted to have some customizations for his computer in his classroom. They were all things that you could adjust quite quickly in the system settings, but if you have to do that after every start, it’s annoying. So we needed a solution how to do these things from the command line, so that we could put the desired changes into a script, that is executed on login. So here are some quick command line tips.
In our Ubuntu image the sound is muted by default. This makes sense in most cases — especially in the computer lab In some rooms, e.g. in the music room or at the teacher’s computers in general, it would be more user-friendly if the sound is switched on automatically. This can be done with the following command:
# unmute sound$ pactl set-sink-mute 0 0
If you want to mute the sound again, the last zero must be replaced by a “1”:
# mute sound$ pactl set-sink-mute 0 1
In most rooms, the screen is mirrored by default when a projector or screen is connected via a HDMI switch. In this specific case the colleague uses the computer in “his” room more or less alone and wanted a setup with an extended screen. Ubuntu, however, places the launcher on the screen with the higher resolution by default. Here we needed a solution how to change the primary screen via command line so that the main screen is the monitor at the teacher’s desk. This can be easily solved with xrandr.
$ xrandr --output DVI-0 --primary
DVI-0 is the output to which the monitor on the teacher’s desk is connected. Via xrandr -q you can display all available connections.
How can I set the acceleration of the mouse pointer via command line? There are different ways e.g. with xset or xinput. We have decided to use xinput. In general, you can set the properties of an input device as follows:
$ xinput --set-prop device-ID property-ID value
We get the device ID by executing xinput without parameters or with –list. Here in the example a wireless mouse is connected.
Next, we need the correct property ID. We can get this from the following command (“9” is our device ID):
$ xinput --list-props 9
To set the mouse acceleration, we need to change the Accel Speed value (property ID is 290). Values between -1 and +1 are allowed. For example, to slow down the mouse acceleration, we can do this with this command:
$ xinput --set-prop 9 290 -1
We packed all these small changes into a script and then distributed them via postsync to the appropriate computer. This flexibility, which Ubuntu and linuxmuster.net offers, is one of the main arguments why we use it.
What nice and useful command line tips do you know?
Originally published at openschoolsolutions.org.