code: def user_open(url_or_command):
      
      from urllib.parse import urlparse
      scheme = urlparse(url_or_command).scheme
      if scheme == 'http' or scheme == 'https':
          import webbrowser
          import os
          # webbrowser.open() sometimes prints a message for some reason and confuses i3
          # Redirect stdout briefly to prevent this from happening.
          savout = os.dup(1)
          os.close(1)
          os.open(os.devnull, os.O_RDWR)
          try:
              webbrowser.open(url_or_command)
          finally:
              os.dup2(savout, 1)
      else:
          import subprocess
          subprocess.Popen(url_or_command, shell=True)
docs: Open the specified paramater in the web browser if a URL is detected,
      othewrise pass the paramater to the shell as a subprocess. This function
      is inteded to bu used in on_leftclick/on_rightclick callbacks.
  
      :param url_or_command: String containing URL or command