Coder Social home page Coder Social logo

dbus-app-launcher's Introduction

dbus-app-launcher

A simple service that allows executing a program via D-Bus.

Note: Allowing D-Bus clients to execute arbitrary programs may pose a security risk. Use carefully.

Installation

There is a number of ways to install. Choose one and follow the given steps.

The following installation options provide a complete package which already include a D-Bus service configuration file, so require no extra steps after installing:

The following installation options only provide you with the executable and leave it up to you to set up the D-Bus service configuration file, for which you will need to follow the steps in the section below:

If none of the above options work for you, you can also follow the instructions below to build the executable from source yourself.

Building from source

To build the code, you will need Haskell and the stack command line utility. Get them here.

To build and install, run stack install. This will build the code and copy the executable to ~/.local/bin.

Next, follow the steps to set up the D-Bus service.

Build a static executable using Docker

To build a static executable (the same as made available on the releases page), you can use the following Docker command:

docker run -v $PWD:/dbus-app-launcher --rm benz0li/ghc-musl:9.6.4 sh -c "cd /dbus-app-launcher && exec stack --allow-different-user build --no-install-ghc --system-ghc --ghc-options='-static -optl-static'"

This will start a ghc-musl container, mount the current directory (where you've checked out the code) into it, and build a statically linked version of the service which should be able to run on any system with the same CPU architecture.

When the build succeeded, the executable can be found at the following path: .stack-work/dist/x86_64-linux/ghc-9.6.4/build/dbus-app-launcher/dbus-app-launcher

Setting up the D-Bus service configuration

To set up a D-Bus service description that will automatically launch the new service whenever it is accessed, create the following file:

/usr/share/dbus-1/services/nl.dvdgiessen.dbusapplauncher.service

[D-BUS Service]
Name=nl.dvdgiessen.dbusapplauncher
Exec=/home/USERNAME/.local/bin/dbus-app-launcher

Replace the path in Exec= with the actual location of the executable.

Using the D-Bus service from your own code

The service currently exports one interface, Exec. Calling any of the methods of this interface will start the program using the exec() syscall.

  • Service name: nl.dvdgiessen.dbusapplauncher
  • Object path: /nl/dvdgiessen/DBusAppLauncher
  • Interface: nl.dvdgiessen.dbusapplauncher.Exec
  • Methods:
    • Cmd(String cmd)
    • CmdArgs(String cmd, List<String> args)
    • CmdArgsEnv(String cmd, List<String> args, Map<String,String> env)

Issues and contributing

This is my first Haskell program, so there's probably plenty that could be improved upon. Feel free to fork it or open pull requests if you find a bug.

I might add more functionality in the future, for example for running programs and returning their exit code and stdout/stderr output. Currently my own use case for this program is for starting applications from KWin scripts (see kwin-toggleterminal if you're interested in that sort of thing), so adding more functionality probably won't be a priority until I have a need for it myself.

License

dbus-app-launcher is freely distributable under the terms of the MIT license.

dbus-app-launcher's People

Contributors

dvdgiessen 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.