Skip to content

Commit

Permalink
use proper shell commands in config
Browse files Browse the repository at this point in the history
This seems to be less confusing and more flexible than lists of args (see #3 and #6).
  • Loading branch information
akissinger committed Jan 6, 2022
1 parent 5fd97ec commit 59ec013
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ dodo.settings.sent_dir = '/home/user/mail/Work/Sent'

# optional
dodo.settings.theme = dodo.themes.nord
dodo.settings.editor_command = ['kitty', 'nvim', '-c', 'set tw=0']
dodo.settings.file_browser_command = ['fman', '/home/user/Documents/']
dodo.settings.editor_command = "kitty nvim '{file}'"
dodo.settings.file_browser_command = "fman '{dir}' /home/user/Documents"
```

A theme is just a Python dictionary mapping some fixed color names to HTML color codes. Currently, the themes implemented in [themes.py](https://github.com/akissinger/dodo/blob/master/dodo/themes.py) are `nord`, `solarized_light` and `solarized_dark`. If you want more, feel free to roll your own, or (better) send me a pull request!

All of the settings of the form `..._command` are given as a list consisting of the command and its arguments. Additional arguments, such as the relevant folder or file are appended to this list.
All of the settings of the form `..._command` are given as shell command. The `editor_command` setting takes a placeholder `{file}` for the file to edit and `file_browser_command` takes the placeholder `{dir}` for the directory to browse.

The settings above replace the default text editor (`xterm -e vim`) with [neovim](https://neovim.io/) run inside a new [kitty](https://sw.kovidgoyal.net/kitty/) terminal. I am also using Michael Herrmann's excellent dual-pane file manager [fman](https://fman.io/) instead of the default (`nautilus`). With these settings, showing attachments will open `fman` with a fixed directory in the left pane (`/home/user/Documents`) and a directory containing the attachments on the right. A similar effect can be obtained with [ranger](https://github.com/ranger/ranger) using the `multipane` view mode.

Expand Down
2 changes: 1 addition & 1 deletion dodo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, parent=None):

def run(self):
"""Run :func:`~dodo.settings.sync_mail_command` then `notmuch new`"""
subprocess.run(settings.sync_mail_command, stdout=subprocess.PIPE)
subprocess.run(settings.sync_mail_command, stdout=subprocess.PIPE, shell=True)
subprocess.run(['notmuch', 'new'], stdout=subprocess.PIPE)

class Dodo(QApplication):
Expand Down
6 changes: 3 additions & 3 deletions dodo/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def run(self):
f.write(self.panel.message_string)
f.close()

cmd = settings.editor_command + [file]
subprocess.run(cmd)
cmd = settings.editor_command.format(file=file)
subprocess.run(cmd, shell=True)

with open(file, 'r') as f:
self.panel.message_string = f.read()
Expand Down Expand Up @@ -118,7 +118,7 @@ def run(self):
except IOError:
print("Can't read attachment: " + a)

sendmail = Popen(settings.send_mail_command, stdin=PIPE, encoding='utf8')
sendmail = Popen(settings.send_mail_command, stdin=PIPE, encoding='utf8', shell=True)
sendmail.stdin.write(str(eml))
sendmail.stdin.close()
sendmail.wait(30)
Expand Down
8 changes: 4 additions & 4 deletions dodo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
# functional
email_address = ''
sent_dir = ''
editor_command = ['xterm', '-e', 'vim']
file_browser_command = ['nautilus']
send_mail_command = ['msmtp', '-t']
sync_mail_command = ['offlineimap']
editor_command = "xterm -e vim '{file}'"
file_browser_command = "nautilus '{dir}'"
send_mail_command = 'msmtp -t'
sync_mail_command = 'offlineimap'
sync_mail_interval = 300 # seconds
default_to_html = False
remove_temp_dirs = 'ask' # should be 'always', 'never', or 'ask'
Expand Down
3 changes: 2 additions & 1 deletion dodo/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def open_attachments(self):

if temp_dir:
self.temp_dirs.append(temp_dir)
subprocess.Popen(settings.file_browser_command + [temp_dir])
cmd = settings.file_browser_command.format(dir=temp_dir)
subprocess.Popen(cmd, shell=True)


0 comments on commit 59ec013

Please sign in to comment.