How to run an external script

Home Forums General Programming How to run an external script

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #65085
    amagnolo
    Participant
      • Topics: 1
      • Replies: 6
      • Total: 7

      I would like to run an external program (script) when a button is clicked in a panel.
      Is this possible? How should it be done?
      Thank you

      #67619
      amagnolo
      Participant
        • Topics: 1
        • Replies: 6
        • Total: 7

        Self-answer: Yes, it is possible, using LUA. It was not so obvoius to me. 🙂

        #67785
        goodweather
        Participant
          • Topics: 45
          • Replies: 550
          • Total: 595
          • ★★★

          Can you put an example of code? Thx. I’ll include that in the Step by Step guide…

          #67950
          amagnolo
          Participant
            • Topics: 1
            • Replies: 6
            • Total: 7

            Hello, here is the LUA code.
            I needed a button to switch the CPU frequency between power saving and performance modes. So, the code first checks if the panel is running in Windows or in Linux/OS X, then calls the external script.
            You can find the actual scripts in my panel distribution, at http://blog.magnolo.com/pianoteq-touch-panel/

            set_governor = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
            	if value==0 then
            		governor="powersave"
            	else
            		governor="performance"
            	end
            	if package.config:sub(1,1) == '\\' then -- windows
            		os.execute( "%UserProfile%\\set_governor.bat "..governor)
            	else -- OSX and Linux
            		os.execute( "~/set_governor.sh "..governor)
            	end
            end

            By the way, your guide was very useful to understand how to begin with Ctrlr, thank you very much!

            • This reply was modified 8 years, 3 months ago by amagnolo.
          Viewing 4 posts - 1 through 4 (of 4 total)
          • The forum ‘Programming’ is closed to new topics and replies.
          There is currently 0 users and 94 guests online
          No users are currently active
          Forum Statistics
          Threads: 2,495, Posts: 17,374, Members: 77,605
          Most users ever online was 12 on January 22, 2019 3:47 pm
          Ctrlr