Compare commits

..

2 Commits

Author SHA1 Message Date
Matthias@Dell
d511c4bb42 add xdg-open 2023-10-22 23:27:39 +02:00
Matthias@Dell
723ab384d4 fix window resize issue 2023-10-22 13:37:09 +02:00
2 changed files with 11 additions and 6 deletions

View File

@ -21,17 +21,18 @@ imgsort
## Installation ## Installation
Clone this repository and install it using python-pip. Clone this repository and install it using python-pip.
pip should also install https://github.com/seebye/ueberzug, which lets you view images in a terminal. pip should also install https://github.com/seebye/ueberzug, which lets you view images in a terminal.
https://github.com/jstkdng/ueberzugpp
```shell ```shell
cd ~/Downloads cd ~/Downloads
git clone https://github.com/MatthiasQuintern/imgsort.git git clone https://github.com/MatthiasQuintern/imgsort.git
cd imgsort cd imgsort
python3 -m pip install . python3 -m pip install .
``` ```
You can also install it system-wide using `sudo python3 -m pip install.`
## Changelog ## Changelog
### 1.2 ### 1.2
- Works with ueberzugpp - Works with ueberzugpp
- Added option to open file with `xdg-open`
- Use pyproject.toml for installation - Use pyproject.toml for installation
### 1.1 ### 1.1

View File

@ -122,7 +122,7 @@ class Sorter:
self.pressed_key = self.window.getkey() # wait until user presses something self.pressed_key = self.window.getkey() # wait until user presses something
# check for quit, skip or undo # check for quit, skip, undo or open
if self.pressed_key in self.settings: if self.pressed_key in self.settings:
if self.settings[self.pressed_key] == "quit": if self.settings[self.pressed_key] == "quit":
self.quit(f"Key '{self.pressed_key}' pressed. Canceling image sorting") self.quit(f"Key '{self.pressed_key}' pressed. Canceling image sorting")
@ -142,10 +142,11 @@ class Sorter:
continue continue
elif settings[self.pressed_key] == "open": elif settings[self.pressed_key] == "open":
try: try:
subprocess.run(['xdg-open', self.image]) subprocess.run(['xdg-open', self.image], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
self.message = "Opening with xdg-open" self.message = "Opening with xdg-open"
except Exception as e: except Exception as e:
print(f"open: Error: {e}") print(f"open: Error: {e}")
continue
# move to folder # move to folder
elif self.pressed_key in self.keys: elif self.pressed_key in self.keys:
@ -164,6 +165,7 @@ class Sorter:
Draw lines and text Draw lines and text
""" """
self.window.erase() self.window.erase()
self.win_y, self.win_x = self.window.getmaxyx()
# lines # lines
self.window.hline(self.win_y - FOOTER_HEIGHT, FOOTER_LEFT, '=', self.win_x) self.window.hline(self.win_y - FOOTER_HEIGHT, FOOTER_LEFT, '=', self.win_x)
@ -234,13 +236,15 @@ class Sorter:
return new_path return new_path
def quit(self, message = ""): def quit(self, message = ""):
self.window.clear()
self.window.refresh()
c.endwin()
print(message) print(message)
print(f"Quitting imgsort {version}") print(f"Quitting imgsort {version}")
exit(0) exit(0)
def __del__(self):
self.window.clear()
self.window.refresh()
c.endwin()
def main(): def main():