4

Most Makefile users use the commandline. Thus they have no need of evoking it in the GUI. But Makefile can be used as an administration tool for the users too.

In my case, a clerk is tasked to maintain a document which changes daily, and as soon as she saves the file, the "source" is changed. I want her to convert it to PDF, stamp the PDF with a given template, encrypt it, merge it with a few other files, and produce three variations for different departments with different stamps.

I have a Makefile for that purpose, already written. Is there a way to let her evoke the Makefile without putting me to the mire of doing additional commandline training? She can save the document, evoke Makefile, and be done.

P.S. This is not about how to execute a shell script or an .EXE file because there is no shell scripts or .EXE files or any executable files in the question at all.

Tankman六四
  • 1,681
  • 2
  • 18
  • 23

3 Answers3

5

I have two solutions for you and I prefer Solution B


Solution A

The simplest way without a terminal is, add a wrapper script in the folder where the Makefile is.

  1. Create a wrapper script

    nano /your/make/file/folder/makeit
    
  2. Add two simple lines

    #!/usr/bin/env bash
    make
    
  3. Make the script executable

    chmod +x /your/make/file/folder/makeit
    
  4. Configure nautilus to ask each time, if you double-click an executable text file

    gsettings set org.gnome.nautilus.preferences executable-text-activation ask
    

    or for a start without asking

    gsettings set org.gnome.nautilus.preferences executable-text-activation launch
    

Solution B

A Makefile has the mimetype

text/x-makefile

Therefore create and use a desktop file with a wrapper script

  1. Create the wrapper script

    mkdir -p ~/bin
    nano ~/bin/makeit
    
  2. Add the code below

    #!/usr/bin/env bash
    cd "$(dirname "$1")" || exit
    make
    
  3. Create a desktop file

    nano ~/.local/share/applications/makeit.desktop
    
  4. Add the configuration below

    [Desktop Entry]
    Name=Make It
    Comment=Start the make command
    Exec=/home/user/bin/makeit
    Icon=
    Terminal=false
    Type=Application
    Categories=Editor;
    StartupNotify=true
    MimeType=text/x-makefile;
    

    IMPORTANT Replace user in the line Exec= with your username, the output of

    echo $USER
    
  5. Restart Unity/GNOME Shell, for the GNOME Shell e.g. Alt-F2, type r and Enter and Nautilus with

    nautilus -q
    
  6. Associate the Makefile with the makeit script

    • Open your file manager and right click on a Makefile

    • Click Open With Other Application

    • Click the button View All Applications

    • Select the entry Make It

A.B.
  • 90,397
0

Just create a cron job (via crontab -e) that runs that Makefile everyday (or even every minute).

heemayl
  • 91,753
Boris Bukh
  • 751
  • 7
  • 16
-1

I discovered "Open in Terminal" feature in nautilus.

  1. Right click the empty space around Makefile
  2. Choose "Open in Terminal"
  3. Type make

This isn't exactly what is asked for, but is the closest solution. Half of the difficulty in training new command-line user is the concept of current directory - in this case probably entire difficulty - making this solution look good.

Tankman六四
  • 1,681
  • 2
  • 18
  • 23