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.

(Un)Mute Sound

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:

If you want to mute the sound again, the last zero must be replaced by a “1”:

Set Primary Screen

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.

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.

Setting the Mouse Pointer Acceleration

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:

We get the device ID by executing xinput without parameters or with –list. Here in the example a wireless mouse is connected.

xinput devices list

Next, we need the correct property ID. We can get this from the following command (“9” is our device ID):

mouse acceleration

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:

Conclusion

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?

Categories: HowTo

Stephan

Stephan

I'm a teacher and IT system administrator in an international school. I love open source software and I used it over a decade in my private and work life. My passion is to solve problems with open source software!