---
# System prepended metadata

title: PID-1178

---

Crafting a Bash widget for iOS utilizing the Scriptable app is not only feasible but also provides enhanced control over the widget's functionality. Scriptable empowers you to fashion widgets using JavaScript and showcase them on your iOS home screen [2][3]. Below, you'll find an illustration of how to design a basic Bash widget employing the Scriptable app:
1. Install Scriptable: If you haven't already, download and install the Scriptable app from the App Store.
2. Create a New Script: Open the Scriptable app and tap the ``+`` button to create a new script.
3.  Out of the Box: When you first turn on a new iPhone, it goes through the activation process. This process involves connecting to Apple's activation servers to verify the device's legitimacy and linking it to an Apple ID.
    Here's an example of a Scriptable script that runs a Bash command and displays the output in a widget:
    ````javascript
    // Define a function to run a Bash command and return the output
    function runBashCommand(command) {
      let process = new Process();
      process.launchPath = "/bin/bash";
      process.arguments = ["-c", command];
      process.currentDirectory = FileManager.local().documentsDirectory;
      process.environment = {
        ...ProcessInfo.processInfo.environment,
        LANG: "en_US.UTF-8", // Set the locale if needed
      };

      process.startAndWait();
      return process.outputString;
    }

    // Run a Bash command and get the output
    const bashCommand = "echo 'Hello, Bash!'";
    const bashOutput = runBashCommand(bashCommand);

    // Create and configure a widget
    let widget = new ListWidget();
    widget.addText("Bash Widget Example");
    widget.addSpacer();
    widget.addText(bashOutput);

    // Display the widget
    if (config.runsInWidget) {
      Script.setWidget(widget);
    } else {
      widget.presentMedium();
    }

    Script.complete();`
    `````
    This script defines a function `runBashCommand()` to run a Bash command and uses it to execute a Bash command (`echo 'Hello, Bash!` in this example). It then creates a widget with the output and displays it.
4. Configure the Widget: To configure and display the widget on your home screen:
    * Save the script.
    * Tap the script in the Scriptable app.
    * Tap the `Run Script` button to execute the script.
    * When prompted, add the widget to your home screen by tapping the `Add to Home Screen` button.
    * You can also customize the widget's appearance and behavior by modifying the script.

Please note that creating a fully functional shell widget on iOS involves various security and usability concerns, and it may not be allowed by Apple's App Store guidelines. This example demonstrates a basic web-based approach, but building a comprehensive shell widget would require more advanced techniques and potentially dealing with App Store restrictions.