Skip to content

Commit

Permalink
v0.7.0, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adokitkat committed Sep 24, 2022
1 parent 11ed306 commit 1e9a859
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ VERSION = $(shell grep -ohP -m 1 "(\d+\.\d+\.\d+)" dnd.nimble)
define DESKTOP_ENTRY
[Desktop Entry]
Name=dnd
Exec=$(PREFIX)/bin/dnd
Exec=$(PREFIX)/bin/dnd %F
TryExec=$(PREFIX)/bin/dnd
Icon=$(PREFIX)/share/icons/dnd.xpm
Comment=Bi-directional drag and drop source/target (make)
Terminal=false
Type=Application
endef
Expand All @@ -17,7 +19,7 @@ export DESKTOP_ENTRY
all: build

build: dnd.nim
nimble build -d:InstallTypeDefine:make --skipProjCfg
nimble build -d:release -d:InstallTypeDefine:make --skipProjCfg

run: dnd
./dnd $(ARGS)
Expand All @@ -30,17 +32,18 @@ install: dnd
cp -f dnd.cfg $(HOME)/.config/dnd/dnd.cfg
cp -f resources/dnd.xpm $(PREFIX)/share/icons/dnd.xpm
echo "$$DESKTOP_ENTRY" > dnd.desktop
cp -f dnd.desktop $(PREFIX)/share/applications/dnd.desktop
cp -f dnd.desktop $(PREFIX)/share/applications/dnd_make.desktop
rm -f dnd.desktop

uninstall:
rm -f $(PREFIX)/bin/dnd $(HOME)/.config/dnd.cfg $(PREFIX)/share/applications/dnd.desktop $(PREFIX)/share/icons/dnd.xpm
rm -f $(PREFIX)/bin/dnd $(HOME)/.config/dnd.cfg $(PREFIX)/share/applications/dnd.desktop \
$(PREFIX)/share/applications/dnd_make.desktop $(PREFIX)/share/icons/dnd.xpm

desktop-entry:
echo "$$DESKTOP_ENTRY" > dnd.desktop

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
tar -czvf dnd_$(VERSION)_linux_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
33 changes: 15 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,21 @@ Key features:

You can install it via 2 methods:

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

### Nimble

```sh
nimble install dnd
```

- `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`
- Nim's package manager `nimble`

### Manual (Makefile)

#### Download
Download [the latest release](https://github.com/adokitkat/dnd/releases) and unpack it to a folder (`tar -zxf FILENAME`)

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

#### Install / Uninstall
To install:

```sh
make install
```

To uninstall:

```sh
make uninstall
```
Expand All @@ -62,8 +51,16 @@ make uninstall
- Desktop entry is installed to `~/.local/share/applications/dnd.desktop`
- Icon `dnd.xpm` is installed to `~/.local/share/icons/dnd.xpm`

</p>
</details>
### Nimble

```sh
nimble install dnd
```

- `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`

## Usage

Expand Down
22 changes: 12 additions & 10 deletions dnd.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const
var # Program default settings
app_name = getAppFilename().rsplit("/", maxsplit=1)[1]
cfg_file = "dnd.cfg"
cfg_path1 = os.getHomeDir() & &".nimble/pkgs/dnd-{Version}/" # nimble
cfg_path2 = os.getHomeDir() & ".config/dnd/" # make
cfg_path = ""
dnd_cfg = ""
cfg_preset = "Default" # You can modify presets in dnd.cfg file
w = 200 # app width
Expand All @@ -32,6 +31,11 @@ var # Program default settings
verbose = false
print_path = true

when InstallType == "nimble":
cfg_path = os.getHomeDir() & &".nimble/pkgs/dnd-{Version}/" # nimble
elif InstallType == "make":
cfg_path = os.getHomeDir() & ".config/dnd/" # make

var # Variables
window: ApplicationWindow
vbox: Box
Expand All @@ -47,8 +51,7 @@ type # Custom types
Uri = 2

DraggableThing = ref object
text: string
uri: string
text, uri: string

ArgParseOutput = tuple
keep, always_on_top, center_mouse, center_screen, decorated, drag_all: bool
Expand Down Expand Up @@ -316,12 +319,9 @@ proc parseCfg() =
of "preset", "p":
if val != "": cfg_preset = val

dnd_cfg = absolutePath(dnd_cfg)
dnd_cfg = absolutePath(cfg_file)
if not dnd_cfg.fileExists: # If no config in current dir
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)
dnd_cfg = cfg_path & 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 @@ -430,7 +430,9 @@ proc argParse() : ArgParseOutput =
quit 0
of "version", "v":
echo &"{app_name} {Version}"
echo &"{InstallType} install"
echo &"{InstallType} build"
echo &"bin path: {os.getAppFilename()}"
echo &"cfg path: {dnd_cfg}"
quit 0

result = (k, t, c, C, d, a, o)
Expand Down
12 changes: 7 additions & 5 deletions dnd.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.6.1"
version = "0.7.0"
author = "Adam Múdry"
description = "Drag and drop source / target"
license = "GPL-3.0-only"
Expand All @@ -12,7 +12,7 @@ installFiles = @["dnd.cfg", "README.md"]
# Dependencies

requires "nim >= 1.6.2"
requires "gintro#d9a5fba5a39fd50c2014a175140f7e9c7635a091" # TODO: update when new version is available
requires "gintro == 0.9.9"

import os, strformat
before build:
Expand All @@ -25,11 +25,13 @@ after install:
var desktop_entry = &"""
[Desktop Entry]
Name=dnd
Exec={os.getHomeDir()}.nimble/bin/dnd
Exec={os.getHomeDir()}.nimble/bin/dnd %F
TryExec={os.getHomeDir()}.nimble/bin/dnd
Icon={os.getHomeDir()}.nimble/pkgs/dnd-{version}/resources/dnd.xpm
Comment=Bi-directional drag and drop source/target (nimble)
Terminal=false
Type=Application"""
writeFile(&"{os.getHomeDir()}.local/share/applications/dnd.desktop", desktop_entry)
writeFile(&"{os.getHomeDir()}.local/share/applications/dnd_nimble.desktop", desktop_entry)

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

0 comments on commit 1e9a859

Please sign in to comment.