GithubHelp home page GithubHelp logo

mdtrooper / powerline_swissarmyknife Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 142 KB

A usefull Powerline segment. This segment launch a user defined complex command line and show the result.

License: GNU General Public License v3.0

Python 100.00%
powerline powerline-segment swissarmyknife

powerline_swissarmyknife's Introduction

POWERLINE SWISSARMYKNIFE

A Powerline segment. This segment shows the execution of complex command line defined by user.

By Miguel de Dios Matias.

Installation

Using pip

pip install powerline-swissarmyknife

Configuration

You can activate the Powerline Slotmachine segment by adding it to your segment configuration, for example in .config/powerline/themes/shell/default.json:

{
    "function": "powerline_swissarmyknife.execute",
    "priority": 30,
    "args": {
        "commandLine": "ps aux --no-headers | wc -l",
        "postContent": "⚙️"
    }
},

Show the number of processes running in your system.

screenshot number processes

Arguments

  • commandLine (string): The command line to execute, it can be complex (with pipes) (remember python3 runs as /bin/sh, not bash).
  • line (string): The string to format the content of segment.
    • Default: "{preContent}{output}{err}{postContent}"
  • preContent (string): The string to show before the result.
    • Default: ""
  • postContent (string): The string to show after the result.
    • Default: "🤖"
  • successCodes (list(int) or None): The values are success code return (normally 0), the background change to critical success.
    • Default: None
  • failureCodes (list(int) or None): The values are fail code return, the background change to critical failture.
    • Default: None

Examples

Shows the upload and download rate and count of torrents download in Deluge.

{
    "function": "powerline_swissarmyknife.execute",
    "priority": 30,
    "args": {
        "commandLine": "deluge-console status | awk '/Total upload:/{print $3$4} /Total download:/{print $3$4} /Downloading:/{print $2\"D\"}' | tr '\n' ' '",
        "postContent": ""
    }
},

screenshot deluge

Show a random pornstar from redtube api.

{
    "function": "powerline_swissarmyknife.execute",
    "priority": 30,
    "args": {
        "commandLine": "if [ -f /tmp/list.redtube.json ]; then list=$(cat /tmp/list.redtube.json); else list=$(curl 'https://api.redtube.com/?data=redtube.Stars.getStarList&output=json'); echo $list > /tmp/list.redtube.json; fi; list_length=$(echo $list | jq '.stars | length'); rand=$(echo 'ibase=16;' $(openssl rand -hex 4 | tr '[a-z]' '[A-Z]')  | bc); echo $list | jq \".stars[$(echo \\\"$rand % $list_length\\\" | bc)].star.star_name\" -r",
        "postContent": " 🎥"
    }
},

screenshot pornstar

License

Licensed under the GPL3 License.

powerline_swissarmyknife's People

Contributors

mdtrooper avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.