diff --git a/Makefile b/Makefile index ff05996..e464c49 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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) @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 2df6c25..5afb753 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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` -

- +### 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 diff --git a/dnd.nim b/dnd.nim index ee2136e..8cb5323 100644 --- a/dnd.nim +++ b/dnd.nim @@ -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 @@ -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 @@ -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 @@ -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() @@ -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) diff --git a/dnd.nimble b/dnd.nimble index 5d2d962..3ccbd3c 100644 --- a/dnd.nimble +++ b/dnd.nimble @@ -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" @@ -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: @@ -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? \ No newline at end of file + rmFile &"{os.getHomeDir()}.local/share/applications/dnd_nimble.desktop" #TODO: doesn't work? \ No newline at end of file