0

I want to write a program that uses shell commands to make changes to audio such as:

pactl set-sink-volume 0 +10%

As I need it during my podcast I want to be able to quickly interact with it via GUI and also use the keyboard to activate functions. Which language would you suggest for programming it? My first guess would be C++ and QT but maybe there are better options.

JoschJava
  • 141
  • 7
  • Comes down to preference and what you know. I'd use Node.js with Util since I'm not familiar with C++. – Smurfz87 Nov 07 '19 at 11:45
  • C++ and Python are 2 good languages (the 1rst use system, 2nd use check_call), but you can do directly a script if there is nothing more than using shell command; also, don't forget that you can optimize a lot your code with C++ – damadam Nov 07 '19 at 11:46
  • I'm very experienced in Java and have some knowledge of C++ and Python. But I would also learn different languages if necessary. I thought there is maybe a preferable language to do so in terms of performance – JoschJava Nov 07 '19 at 11:47
  • @JoschJava so forget about Java, and according to that question on SO, C++ is faster than Python – damadam Nov 07 '19 at 11:49
  • @damadam Thank you. It's not simply one shell command. There will be different routing options, volume control, etc. similar to a mixer and obviously I need a gui and not type during recording, so simple shell won't do. – JoschJava Nov 07 '19 at 11:49
  • 1
    Just have to ask, will your app ever demand so much from your system that you will need to optimize it? – Smurfz87 Nov 07 '19 at 11:56
  • Not really, it's pretty much just changing volume and connect different program audio streams to another with Virtual Sinks – JoschJava Nov 07 '19 at 11:57
  • Have you tried out the pavucontrol application? It might already provide all features you need. For the rest, I'd personally just use simple bash scripts too and either call them with keyboard shortcuts or make e.g. a .desktop launcher for them. You can also write simple dialog windows with help of e.g. zenity. – Byte Commander Nov 07 '19 at 12:34
  • you could bind shortcut keys to bash scripts, https://askubuntu.com/questions/15050/how-do-i-bind-sh-files-to-keyboard-combination. or a (very) simple gui with bash+zenity, https://help.gnome.org/users/zenity/ – mgor Nov 08 '19 at 12:46

1 Answers1

2

This question may be regarded as opinion-based, because most higher-level programming languages have an interface to the system shell, and the decision is mainly a matter of preference (and only to some part of "the right tool for the right job"). However, here are some hints from my point of view:

  1. If the logic is simple (mainly the calls with fixed or passed parameters, no fancy calculations), use shell scripts. Easy to start with, to implement and to maintain.
  2. For more advanced logic, you'll be better off with a common scripting language like Python, Lua, even Perl if you know how to use it.
  3. C++/Qt makes sense if you want a sophisticated UI experience, but here also Python + PyQt would be an alternative. Altogether compiler languages add some overhead to the development cycle, but provide better runtime performance, which may be an advantage if the application is consuming much processor time and runs permanently.
Murphy
  • 1,677
  • I assume you're familiar with Murphy's law since this answer echoes the logic of Murphy's law in ascending order. The only possible criticism I could make is that Murphy's law to be statistically valid requires a large enough sample size and your sample size is only 3. However I always use bash for shell commands, and if you get in trouble with bash, there always seems to be a handy terminal program in the repos to extend bash's functionality. – karel Nov 07 '19 at 17:12