Skip to content

Commit

Permalink
v0.6.0, nimble install,
Browse files Browse the repository at this point in the history
  • Loading branch information
adokitkat committed Feb 12, 2022
1 parent 9fca3cc commit 94067a0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 22 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export DESKTOP_ENTRY

all: build

build: src/dnd.nim
nimble build
build: dnd.nim
nimble build -d:InstallTypeDefine:make --skipProjCfg

run: dnd
./dnd $(ARGS)
Expand All @@ -39,5 +39,8 @@ uninstall:
desktop-entry:
echo "$$DESKTOP_ENTRY" > dnd.desktop

tarball: dnd.nimble dnd src/dnd.nim dnd.cfg README.md resources/dnd.xpm resources/dnd.png
tar -czvf dnd_$(VERSION)_x64.tar.gz dnd src/dnd.nim dnd.nimble dnd.cfg README.md Makefile resources/dnd.xpm resources/dnd.png
tarball: build dnd.nimble dnd dnd.nim dnd.cfg README.md resources/dnd.xpm resources/dnd.png
tar -czvf dnd_$(VERSION)_x64.tar.gz dnd dnd.nim dnd.nimble dnd.cfg README.md Makefile resources/dnd.xpm resources/dnd.png

clear:
rm -f dnd dnd.nims
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,39 @@ Key features:
### Build Requirements

- GTK+ 3 dev packages
- [Nim compiler 1.6.4+](https://nim-lang.org/)
- [Nim compiler 1.6.2+](https://nim-lang.org/)
- [gintro](https://github.com/StefanSalewski/gintro/) (automatically downloaded)

## Getting Started

### Build
You can install it via 2 methods:

```sh
nimble build
```
- Nim's package manager `nimble`
- Manual (Makefile) - Nim not required (when not building)

or
<details><summary>Nimble</summary>
<p>

```sh
make
nimble install dnd
```

### Installation / Uninstallation
- `dnd` symlink is installed to `~/.nimble/bin/dnd` and executable to `~/.nimble/pkgs/dnd-VERSION/dnd`
- `dnd.cfg` is installed to `~/.nimble/pkgs/dnd-VERSION/dnd.cfg`
- Desktop entry is installed to `~/.local/share/applications/dnd.desktop` - `nimble uninstall dnd` cannot remove it automatically?
- Icon `dnd.xpm` is installed to `~/.nimble/pkgs/dnd-VERSION/resources/dnd.xpm`

</p>
</details>

<details><summary>Manual (Makefile)</summary>
<p>

### Download

Download [the latest release](https://github.com/adokitkat/dnd/releases) and unpack it to a folder

### Install / Uninstall

```sh
make install
Expand All @@ -52,7 +67,10 @@ make uninstall
- Desktop entry is installed to `~/.local/share/applications/dnd.desktop`
- Icon `dnd.xpm` is installed to `~/.local/share/icons/dnd.xpm`

### Usage
</p>
</details>

## Usage

```man
dnd - bi-directional drag and drip source / target
Expand Down
19 changes: 13 additions & 6 deletions src/dnd.nim → dnd.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
# Copyright 2022 Adam Múdry (adokitkat)
# Thanks to Michael Homer (mwh) and Dr. Stefan Salewski (StefanSalewski)

import std/[os, parseopt, parsecfg, posix, strformat, strutils, terminal, unicode, uri]
import std/[os, parseopt, parsecfg, posix, strformat, strutils, terminal, uri]
import gintro/[gtk, gdk, glib, gobject, gio]

const
InstallTypeDefine {.strdefine.} = "Unknown"
NimblePkgVersion {.strdefine.} = "Unknown"
InstallType = strip(InstallTypeDefine)
Version = NimblePkgVersion

var # Program default settings
app_name = getAppFilename().rsplit("/", maxsplit=1)[1]
cfg_file = "dnd.cfg"
cfg_path = os.getHomeDir() & ".config/dnd/"
cfg_path1 = os.getHomeDir() & &".nimble/pkgs/dnd-{Version}/" # nimble
cfg_path2 = os.getHomeDir() & ".config/dnd/" # make
dnd_cfg = ""
cfg_preset = "Default" # You can modify presets in dnd.cfg file
w = 200 # app width
Expand Down Expand Up @@ -313,9 +316,12 @@ proc parseCfg() =
of "preset", "p":
if val != "": cfg_preset = val

dnd_cfg = cfg_file
dnd_cfg = absolutePath(dnd_cfg)
if not dnd_cfg.fileExists: # If no config in current dir
dnd_cfg = cfg_path & cfg_file # Set path to cfg installation folder
when InstallType == "nimble":
dnd_cfg = cfg_path1 & cfg_file # Set path to cfg installation folder (nimble)
elif InstallType == "make":
dnd_cfg = cfg_path2 & cfg_file # Set path to cfg installation folder (makefile)

if dnd_cfg.fileExists: # If config exist try to load it
var cfg = dnd_cfg.loadConfig()
Expand Down Expand Up @@ -357,12 +363,12 @@ proc argParse() : ArgParseOutput =
"-h, --help\t\t Show this message"
]
for line in help:
echo " " & line
echo line.indent 2
if dnd_cfg.fileExists:
echo ""
echo &"Presets in current loaded dnd.cfg file ({dnd_cfg}):"
for line in dnd_cfg.lines:
echo " " & line
echo line.indent 2

var
a = drag_all
Expand Down Expand Up @@ -424,6 +430,7 @@ proc argParse() : ArgParseOutput =
quit 0
of "version", "v":
echo &"{app_name} {Version}"
echo &"{InstallType} install"
quit 0

result = (k, t, c, C, d, a, o)
Expand Down
27 changes: 24 additions & 3 deletions dnd.nimble
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
# Package

version = "0.5.0"
version = "0.6.0"
author = "Adam Múdry"
description = "Drag and drop source / target"
license = "GPL-3.0-only"
srcDir = "src"
bin = @["dnd"]
installDirs = @["resources", "examples"]
installFiles = @["dnd.cfg", "README.md"]


# Dependencies

requires "nim >= 1.6.4"
requires "nim >= 1.6.2"
requires "gintro#head"

import os, strformat
before build:
writeFile("dnd.nims", "--define:InstallTypeDefine:nimble")

after build:
rmFile "dnd.nims"

after install:
var desktop_entry = &"""
[Desktop Entry]
Name=dnd
Exec={os.getHomeDir()}.nimble/bin/dnd
Icon={os.getHomeDir()}.nimble/pkgs/dnd-{version}/resources/dnd.xpm
Terminal=false
Type=Application"""
writeFile(&"{os.getHomeDir()}.local/share/applications/dnd.desktop", desktop_entry)

before uninstall:
rmFile &"{os.getHomeDir()}.local/share/applications/dnd.desktop" #TODO: doesn't work?

0 comments on commit 94067a0

Please sign in to comment.