Giter Club home page Giter Club logo

lima-xbar-plugin's Introduction

lima-xbar-plugin

License Awesomebot Megalinter codeql GitHub stars

Table of Contents

Lima is an alternative to using Docker Desktop on your Mac.

Description

This plugin is compatible with xbar and SwiftBar, and provides a menubar app that creates a Lima menubar option with submenus for each Lima VM on your machine. For each VM, you can:

  • start/stop the VM
  • stop, start or remove stopped containers
  • pull or remove images from the VM
  • Run an arbitrary command inside the VM with lima

Screen shots

Screen shot of xbar menu with container submenu for a running vm

Screen shot of xbar menu with image submenu for a running vm

Installation

Copy lima-plugin to ~/Library/Application\ Support/xbar/plugins/lima-plugin.30s, or run make install

Dependencies

  • xbar or SwiftBar - Both allow you to make custom menubar apps with simple scripts.

lima-xbar-plugin's People

Contributors

colindean avatar dependabot[bot] avatar unixorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lima-xbar-plugin's Issues

FileNotFoundError: No such file or directory: '/usr/local/bin/limactl'

I'm getting the following error in xbar:

 [2021-10-09 09:05:07,468][    INFO][lima-plugin:543 -                 main() ] argv[0] ./lima-plugin
🐋 🏃 | color=#29cc00
---
Traceback (most recent call last):
  File "/Users/salvot/Library/Application Support/xbar/plugins/./lima-plugin", line 567, in <module>
    main()
  File "/Users/salvot/Library/Application Support/xbar/plugins/./lima-plugin", line 545, in main
    xbarMenu()
  File "/Users/salvot/Library/Application Support/xbar/plugins/./lima-plugin", line 526, in xbarMenu
    aboutMenu()
  File "/Users/salvot/Library/Application Support/xbar/plugins/./lima-plugin", line 418, in aboutMenu
    limaVersion = subprocess.run(
  File "/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/limactl'

I've tried a few permutations of adding /usr/local/bin and /opt/homebrew/bin to the command, as well as checking environment variables.

Ultimately, I had to symlink lima and limactl into /usr/local/bin. Is this expected, and should this be part of the Makefile?

Python3 rewrite

Using jq to go over lists of objects in bash is getting to be a pita.

Rewrite in stock python3.

The plugin does not work properly if we change the destination of the homebrew installation

If we have changed the installation destination of homebrew, unable to find limactl.
Is there any better solution?

What's happening

Exception

exit status 1: Traceback (most recent call last):
  File "./lima-plugin", line 600, in <module>
    main()
  File "./lima-plugin”, line 578, in main
    xbarMenu()
  File "./lima-plugin", line 556, in xbarMenu
    vms = listVMs()  
  File "./lima-plugin”, line 256, in listVMs
    vmRaw = subprocess.run(
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'limactl'

image

xbar or swiftbar starts the plugin with PATH as follows:

PATH=/usr/bin:/bin:/usr/sbin:/sbin

My installation directory of homebrew:

% brew --prefix
/Users/${USER}/homebrew

lima-xbar-plugin cannot call limactl because brew --prefix cannot be used.

Temporary workaround

Add the homebrew/bin path directly to extrapaths

extrapaths = ["/usr/local/bin", "/opt/homebrew/bin", "/opt/local/bin", "/Users/${USER}/homebrew/bin"]

Expected results

The path of homebrew/bin is automatically resolved and limactl can be called.
Then xbar or swiftbar will not generate any errors.

Suggestion: use `limactl list --json`

First, thanks a lot for working on this

for limavm in $(limactl list | grep -v 'NAME STATUS SSH ARCH DIR' | awk '{ print $1 }')

The grep above doesn't seem robust, and will probably break soon with a future version of Lima.
I'd suggest using limactl list --json and use jq for parsing JSON.

$ limactl list --json  | jq .
{
  "name": "default",
  "status": "Running",
  "dir": "/Users/suda/.lima/default",
  "arch": "x86_64",
  "sshLocalPort": 60022,
  "hostAgentPID": 1968,
  "qemuPID": 1972
}

Logging in Swiftbar

Hi ! I tried using this plugin in SwiftBar but when it is displayed in the menu bar all of the logging are present, it is not the case when using xbar

SwiftBar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.