Console Application

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
tsmvp
Posts: 10
Joined: Tuesday 03rd November 2020 2:35pm

Console Application

Post by tsmvp » Thursday 30th September 2021 2:21am

Ladies/Gents,

Have a very stupid question I am sure. :D
I am trying to write a console application to help me fix a pulsemixer issue. LOL. The problem is simple. As I have an Elgato Stream Deck, I want to be able to press one key to mute/unmute a particular source. Problem is pulsemixer for whatever reason (or Linux) keeps changing the source 'ID' randomly. So one morning it may show my USB Mic as 'source-3' and the other day as 'source-15'.
So I wrote this small app using Gambas3 that basically runs a shell command to a variable (something like 'pulsemixer -list-sources | grep 'Realtek') and then I massage the string to find the actual source ID that is tied to the 'Realtek USB' input.
When I run it within the Gambas3 IDE, everything works GREAT! I see the mic icon on the taskbar being muted. Just perfect. LOL
Now the problem is, how do I run this on bash (terminal)? I tried simply running the .gambas file but it throws all sorts of errors and resuming, does not work.
How is this achieved?
I want to get this going so I can configure my Stream Deck to mute/unmute that particular input using this Gambas console app. Does it make sense?

Thanks a lot!

CR

User avatar
stevedee
Posts: 459
Joined: Monday 20th March 2017 6:06pm

Re: Console Application

Post by stevedee » Thursday 30th September 2021 8:05am

tsmvp wrote:
Thursday 30th September 2021 2:21am
...When I run it within the Gambas3 IDE, everything works GREAT! I see the mic icon on the taskbar being muted. Just perfect. LOL
Now the problem is, how do I run this on bash (terminal)? I tried simply running the .gambas file but it throws all sorts of errors...
Please post the output from the terminal window when you run the .gambas exe file. The easy way is to left-click in the terminal after the last line, then drag the mouse across all the text, and then hit the keys <ctrl><shift> c
You can then paste this in a text file or directly into your next post using keys <ctrl> v
(sorry if you know all this, but this is the Beginners section)

User avatar
cogier
Site Admin
Posts: 764
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Console Application

Post by cogier » Thursday 30th September 2021 11:05am

What happens if you compile the code in the IDE and add a Desktop icon. Will it run from the Desktop?

Image

tsmvp
Posts: 10
Joined: Tuesday 03rd November 2020 2:35pm

Re: Console Application

Post by tsmvp » Thursday 30th September 2021 12:55pm

It was my own stupidity :D . After you guys mentioned the create a desktop shortcut thing, I did it and then when I tried to double click it, it opened a text file and I could see what was in it, including the command line launching the .gambas file. I copied that and tried from a terminal window and it worked. Then I remember I was trying to launch it using 'sh ./file.gambas' and of course that was the problem.

Thanks for the help! It works a treat now and I do not have to worry about the damn pulsemixer changes any longer!

CR

Post Reply