Working on neomutt setup and some other small fixes

This commit is contained in:
Marko Korhonen 2020-11-25 10:06:19 +02:00
parent 91836193e7
commit bf10ef8645
36 changed files with 152 additions and 155 deletions

View file

@ -1,13 +0,0 @@
{
"host": "imap.migadu.com",
"port": 993,
"tls": true,
"tlsOptions": {
"rejectUnauthorized": true
},
"username": "admin@korhonen.cc",
"password": "{{@@ env['PASS_EMAIL_ADMIN'] @@}}",
"onNewMail": "mbsync admin@korhonen.cc",
"onNewMailPost": "",
"boxes": [ "INBOX" ]
}

View file

@ -0,0 +1,19 @@
var child_process = require("child_process");
function getStdout(cmd) {
var stdout = child_process.execSync(cmd);
return stdout.toString().trim();
}
exports.host = "imap.migadu.com";
exports.port = 993;
exports.tls = true;
exports.tlsOptions = {
rejectUnauthorized: true,
};
exports.username = "admin@korhonen.cc";
exports.password = "{{@@ env['PASS_EMAIL_ADMIN'] @@}}";
exports.onNewMail = "mbsync admin@korhonen.cc";
exports.onNewMailPost =
"~/git/dotfiles/scripts/mail/notify-new-mail.sh admin@korhonen.cc";
exports.boxes = ["INBOX"];

View file

@ -0,0 +1,19 @@
var child_process = require("child_process");
function getStdout(cmd) {
var stdout = child_process.execSync(cmd);
return stdout.toString().trim();
}
exports.host = "imap.migadu.com";
exports.port = 993;
exports.tls = true;
exports.tlsOptions = {
rejectUnauthorized: true,
};
exports.username = "functionalhacker@korhonen.cc";
exports.password = "{{@@ env['PASS_EMAIL_HACKER'] @@}}";
exports.onNewMail = "mbsync functionalhacker@korhonen.cc";
exports.onNewMailPost =
"~/git/dotfiles/scripts/mail/notify-new-mail.sh functionalhacker@korhonen.cc";
exports.boxes = ["INBOX"];

View file

@ -1,13 +0,0 @@
{
"host": "imap.migadu.com",
"port": 993,
"tls": true,
"tlsOptions": {
"rejectUnauthorized": true
},
"username": "marko@korhonen.cc",
"password": "{{@@ env['PASS_EMAIL_MARKO'] @@}}",
"onNewMail": "mbsync marko@korhonen.cc",
"onNewMailPost": "",
"boxes": [ "INBOX" ]
}

View file

@ -0,0 +1,19 @@
var child_process = require("child_process");
function getStdout(cmd) {
var stdout = child_process.execSync(cmd);
return stdout.toString().trim();
}
exports.host = "imap.migadu.com";
exports.port = 993;
exports.tls = true;
exports.tlsOptions = {
rejectUnauthorized: true,
};
exports.username = "marko@korhonen.cc";
exports.password = "{{@@ env['PASS_EMAIL_MARKO'] @@}}";
exports.onNewMail = "mbsync marko@korhonen.cc";
exports.onNewMailPost =
"~/git/dotfiles/scripts/mail/notify-new-mail.sh marko@korhonen.cc";
exports.boxes = ["INBOX"];

View file

@ -1,31 +1,31 @@
umpv %U
mpvqueue %U
^https?://invidio.us/.*
umpv %U
mpvqueue %U
^https?://(m.)?(www.)?youtube.com/watch\?.*v=
umpv %U
mpvqueue %U
^https?://(www.)?youtube.com/playlist\?.*list=
umpv %U
mpvqueue %U
^https?://(www.)?youtu.be/
umpv %U
mpvqueue %U
^https?://(www.)?(m.)?twitch.tv/
umpv %U
mpvqueue %U
^https?://(?:[a-z0-9\-]+\.)+[a-z]{2,6}(?:/[^/#?]+)+\.(?:mp4|mkv|webm|avi|3gp|gif|gifv)
umpv %U
mpvqueue %U
^https?://www.facebook.com/.*/videos/
umpv %U
mpvqueue %U
^https?://gfycat.com/.*
umpv %U
mpvqueue %U
^https?://vimeo.com/.*
umpv %U
mpvqueue %U
^https?://v.redd.it/.*
imgurviewer %U

View file

@ -1,5 +1,5 @@
music_directory "~/Music"
playlist_directory "~/Music/Playlists"
music_directory "~/music"
playlist_directory "~/music/Playlists"
db_file "~/.mpd/database"
log_file "~/.mpd/log"
pid_file "~/.mpd/pid"

View file

@ -1,25 +1,26 @@
defaults
auth on
tls on
tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.log/msmtp.log
host smtp.migadu.com
port 465
# functionalhacker@korhonen.cc
account functionalhacker@korhonen.cc
from functionalhacker@korhonen.cc
user functionalhacker@korhonen.cc
password "{{@@ env['PASS_EMAIL_HACKER'] @@}}"
# marko@korhonen.cc
account marko@korhonen.cc
from marko@korhonen.cc
user marko@korhonen.cc
password "{{@@ env['PASS_EMAIL_MARKO'] @@}}"
auth on
tls on
tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.log/msmtp/marko@korhonen.cc.log
host smtp.migadu.com
port 465
# admin@korhonen.cc
account admin@korhonen.cc
from admin@korhonen.cc
user admin@korhonen.cc
password "{{@@ env['PASS_EMAIL_ADMIN'] @@}}"
auth on
tls on
tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.log/msmtp/admin@korhonen.cc.log
host smtp.migadu.com
port 465

View file

@ -1,14 +0,0 @@
# vim: filetype=neomuttrc
set my_email = "admin@korhonen.cc"
set from = $my_email
set sendmail = "/usr/bin/msmtp -a $my_email"
set realname = "Marko Korhonen"
set status_format = "-%r-Mutt: $my_email %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---"
set mbox_type = Maildir
set folder = "~/.mail/$my_email"
set mbox = "+INBOX"
set record = "+INBOX"
set postponed = "+Drafts"
set spoolfile = "+INBOX"
mailboxes = +INBOX

View file

@ -1,14 +0,0 @@
# vim: filetype=neomuttrc
set my_email = "marko@korhonen.cc"
set from = $my_email
set sendmail = "/usr/bin/msmtp -a $my_email"
set realname = "Marko Korhonen"
set status_format = "-%r-Mutt: $my_email %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---"
set mbox_type = Maildir
set folder = "~/.mail/$my_email"
set mbox = "+INBOX"
set record = "+INBOX"
set postponed = "+Drafts"
set spoolfile = "+INBOX"
mailboxes = +INBOX

View file

@ -1 +0,0 @@
color normal default default

View file

@ -1,13 +0,0 @@
# vim: filetype=neomuttrc
set sendmail = "/usr/bin/msmtp"
set mbox_type = Maildir
set folder = ~/.mail
set spoolfile = +Personal/INBOX
source ~/.config/neomutt/appearance
source ~/.config/neomutt/sidebar
source ~/.config/neomutt/accounts/marko@korhonen.cc
macro index <f2> '<sync-mailbox><enter-command>source ~/.config/neomutt/accounts/marko@korhonen.cc<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.config/neomutt/accounts/admin@korhonen.cc<enter><change-folder>!<enter>'

View file

@ -1,5 +0,0 @@
# vim: filetype=neomuttrc
set sidebar_visible = yes
set sidebar_indent_string = ' '
sidebar_whitelist '~/.mail/<>/INBOX'

View file

@ -3,5 +3,5 @@
set $mod Mod4
set $term alacritty
set $gnome-schema org.gnome.desktop.interface
set $wallpaper ~/Pictures/Wallpapers/random/$(ls ~/Pictures/Wallpapers/random | sort -R | tail -n 1)
set $wallpaper ~/pictures/Wallpapers/random/$(ls ~/Pictures/Wallpapers/random | sort -R | tail -n 1)
set $scripts ~/.config/sway/scripts

View file

@ -1,8 +1,8 @@
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"
XDG_DESKTOP_DIR="$HOME/desktop"
XDG_DOWNLOAD_DIR="$HOME/downloads"
XDG_TEMPLATES_DIR="$HOME/templates"
XDG_PUBLICSHARE_DIR="$HOME/public"
XDG_DOCUMENTS_DIR="$HOME/documents"
XDG_MUSIC_DIR="$HOME/music"
XDG_PICTURES_DIR="$HOME/pictures"
XDG_VIDEOS_DIR="$HOME/videos"

View file

@ -4,8 +4,7 @@ alias gac='ga && gc'
alias gpull='git pull'
alias gpush='git push'
# Access server mariadb
alias moria-mariadb='ssh -tt moria docker exec -it mariadb mysql -p'
alias mutt='neomutt'
# Syntax highlighting cat if output is a terminal
cat() {

View file

@ -1,3 +1,28 @@
### functionalhacker@korhonen.cc #####################################
IMAPAccount functionalhacker@korhonen.cc
Host imap.migadu.com
User functionalhacker@korhonen.cc
Pass "{{@@ env['PASS_EMAIL_HACKER'] @@}}"
SSLType IMAPS
Port 993
CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore functionalhacker@korhonen.cc-remote
Account functionalhacker@korhonen.cc
MaildirStore functionalhacker@korhonen.cc-local
Subfolders Verbatim
Path ~/.mail/functionalhacker@korhonen.cc/
Inbox ~/.mail/functionalhacker@korhonen.cc/INBOX
Channel functionalhacker@korhonen.cc
Master :functionalhacker@korhonen.cc-remote:
Slave :functionalhacker@korhonen.cc-local:
Create Both
Patterns *
SyncState *
#################################################################
### marko@korhonen.cc #####################################
IMAPAccount marko@korhonen.cc
Host imap.migadu.com

View file

@ -1,38 +0,0 @@
defaults
auth on
logfile ~/.msmtp.log
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# reekymarko@reekynet.com
account reekymarko@reekynet.com
host smtp.migadu.com
port 587
from reekymarko@reekynet.com
user reekymarko@reekynet.com
passwordeval "pass email/reekymarko@reekynet.com | head -n 1"
# marko.korhonen@reekynet.com
account marko.korhonen@reekynet.com
host smtp.migadu.com
port 587
from marko.korhonen@reekynet.com
user marko.korhonen@reekynet.com
passwordeval "pass email/marko.korhonen@reekynet.com | head -n 1"
# admin@reekynet.com
account admin@reekynet.com
host smtp.migadu.com
port 587
from admin@reekynet.com
user admin@reekynet.com
passwordeval "pass email/admin@reekynet.com | head -n 1"
# marko.korhonen@metropolia.fi
account marko.korhonen@metropolia.fi
host smtp.metropolia.fi
port 587
from marko.korhonen@metropolia.fi
user markoak
passwordeval "pass email/marko.korhonen@metropolia.fi | head -n 1"

View file

@ -1,22 +0,0 @@
#!/bin/bash
function rotate_ms {
case $1 in
"normal")
swaymsg output eDP-1 transform 0
;;
"right-up")
swaymsg output eDP-1 transform 90
;;
"bottom-up")
swaymsg output eDP-1 transform 180
;;
"left-up")
swaymsg output eDP-1 transform 270
;;
esac
}
while IFS='$\n' read -r line; do
rotation="$(echo $line | sed -En "s/^.*orientation changed: (.*)/\1/p")"
[[ ! -z $rotation ]] && rotate_ms $rotation
done < <(stdbuf -oL monitor-sensor)

View file

@ -1,26 +0,0 @@
#!/usr/bin/env bash
source ~/.cache/wal/colors.sh
echo "[colors]
foreground = $foreground
background = $background
color0 = $color0
color1 = $color1
color2 = $color2
color3 = $color3
color4 = $color4
color5 = $color5
color6 = $color6
color7 = $color7
color8 = $color8
color9 = $color9
color10 = $color10
color11 = $color11
color12 = $color12
color13 = $color13
color14 = $color14
color15 = $color15
[options]
font = Noto Color Emoji 12
font = Material Design Icons 12
font = Hack Nerd Font 12" > ~/.config/termite/config

View file

@ -1,40 +0,0 @@
#!/bin/sh
# Generates zathura configuration file with pywal colors
. $HOME/.cache/wal/colors.sh
cat <<CONF > ~/.config/zathura/zathurarc
set completion-bg "$background"
set recolor-darkcolor "$foreground"
set recolor-lightcolor "$background"
set completion-fg "$foreground"
set completion-group-bg "$background"
set completion-group-fg "$color2"
set completion-highlight-bg "$foreground"
set completion-highlight-fg "$background"
set default-bg "$background"
set default-fg "$foreground"
set inputbar-bg "$background"
set inputbar-fg "$foreground"
set notification-bg "$background"
set notification-fg "$foreground"
set notification-error-bg "$color1"
set notification-error-fg "$foreground"
set notification-warning-bg "$color1"
set notification-warning-fg "$foreground"
set statusbar-bg "$background"
set statusbar-fg "$foreground"
set index-bg "$background"
set index-fg "$foreground"
set index-active-bg "$foreground"
set index-active-fg "$background"
set render-loading-bg "$background"
set render-loading-fg "$foreground"
set smooth-scroll true
set window-title-home-tilde true
set statusbar-basename true
set selection-clipboard clipboard
set recolor false
CONF

View file

@ -1,9 +0,0 @@
#!/bin/sh
acpi -b | awk -F'[,:%]' '{print $2, $3}' | {
read -r status capacity
if [ "$status" = Discharging -a "$capacity" -lt 5 ]; then
logger "Critical battery threshold"
systemctl hibernate
fi
}

View file

@ -1,9 +0,0 @@
#!/bin/bash
IPMIHOST=10.0.0.82
IPMIUSER=ReekyMarko
IPMIPW={{@@ env['PASS_IPMI'] @@}}
IPMIEK=0000000000000000000000000000000000000000
printf "Activating dynamic fan control."
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x01

View file

@ -1,17 +0,0 @@
#!/bin/bash
IPMIHOST=10.0.0.82
IPMIUSER=ReekyMarko
IPMIPW={{@@ env['PASS_IPMI'] @@}}
IPMIEK=0000000000000000000000000000000000000000
DATA=`ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK sdr get "FAN 1 RPM" "FAN 2 RPM" "FAN 3 RPM" "FAN 4 RPM" "FAN 5 RPM" "FAN 6 RPM" | grep "Sensor Reading" | awk '{ print $4 }'`
echo "$DATA"
mosquitto_pub -u reekynet -P {{@@ env['PASS_MQTT'] @@}} -t "ipmi/fan1" -m "$(echo "$DATA" | head -1 | tail -1)"
mosquitto_pub -u reekynet -P {{@@ env['PASS_MQTT'] @@}} -t "ipmi/fan2" -m "$(echo "$DATA" | head -2 | tail -1)"
mosquitto_pub -u reekynet -P {{@@ env['PASS_MQTT'] @@}} -t "ipmi/fan3" -m "$(echo "$DATA" | head -3 | tail -1)"
mosquitto_pub -u reekynet -P {{@@ env['PASS_MQTT'] @@}} -t "ipmi/fan4" -m "$(echo "$DATA" | head -4 | tail -1)"
mosquitto_pub -u reekynet -P {{@@ env['PASS_MQTT'] @@}} -t "ipmi/fan5" -m "$(echo "$DATA" | head -5 | tail -1)"
mosquitto_pub -u reekynet -P {{@@ env['PASS_MQTT'] @@}} -t "ipmi/fan6" -m "$(echo "$DATA" | head -6 | tail -1)"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
IPMIHOST=10.0.0.82
IPMIUSER=ReekyMarko
IPMIPW={{@@ env['PASS_IPMI'] @@}}
IPMIEK=0000000000000000000000000000000000000000
printf "speeeed!"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x64

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
IPMIHOST=10.0.0.82
IPMIUSER=ReekyMarko
IPMIPW={{@@ env['PASS_IPMI'] @@}}
IPMIEK=0000000000000000000000000000000000000000
printf "Activating manual fan speeds! (2160 RPM)"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x10

View file

@ -1,19 +0,0 @@
#!/bin/bash
IPMIHOST=10.0.0.82
IPMIUSER=ReekyMarko
IPMIPW={{@@ env['PASS_IPMI'] @@}}
IPMIEK=0000000000000000000000000000000000000000
MAXTEMP=27
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK sdr type temperature |grep Ambient |grep degrees |grep -Po '\d{2}' | tail -1)
mosquitto_pub -u reekynet -P {{@@ env['PASS_MQTT'] @@}} -t "ipmi/temp" -m "$TEMP"
if [[ $TEMP > $MAXTEMP ]];
then
printf "Warning: Temperature is too high! Activating dynamic fan control! ($TEMP C)"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x01
else
printf "Temperature is OK ($TEMP C)"
fi

View file

@ -1,29 +0,0 @@
#!/bin/bash
if [ $# -eq 1 ]; then
DIR=/tmp/images
IMGNAME=$(basename $1)
if [ ! -d $DIR ]; then
mkdir $DIR
fi
if [ ! -f $DIR/$IMGNAME ]; then
wget $1 -O $DIR/$IMGNAME
fi
mimeo $DIR/$IMGNAME
else
DIR=/tmp/images/$(basename $1)
if [ ! -d $]; then
mkdir -p $DIR
fi
if [ ! -f $DIR/$IMGNAME ]; then
wget -P $DIR $@
fi
mimeo $DIR/*
fi

View file

@ -1,11 +0,0 @@
#!/bin/bash
ALBUMNAME=$(basename $1)
ALBUMDIR=/tmp/imgur/$ALBUMNAME
if [ ! -d $ALBUMDIR ]; then
mkdir -p $ALBUMDIR
imgur-album-downloader $1 $ALBUMDIR
fi
mimeo $ALBUMDIR

View file

@ -1,30 +0,0 @@
#!/usr/bin/env bash
MPVPIPE=/tmp/mpvqueue.playlist
notify="notify-send -i mpv -a mpv"
url="$1"
# See if MPV is already running
if [ -z "$(pidof mpv)" ]; then
# mpv is not running
# remove fifo
rm -f $MPVPIPE && mkfifo $MPVPIPE
# pause other players
playerctl pause
# start mpv
/usr/bin/mpv --no-terminal --input-file="${MPVPIPE}" "$url" & disown
# Wait for mpv to be up before moving on to adding anything else to playlist
while [ -z "$(pidof mpv)" ]; do
sleep 1
done
$notify "Playing $url"
else
# mpv is running, so add stuff to playlist
$notify "Adding $url"
echo "loadfile \"$url\" append-play" >> "${MPVPIPE}"
fi

View file

@ -1,186 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import json
import struct
import subprocess
VERSION = '7.2.2'
try:
sys.stdin.buffer
# Python 3.x version
# Read a message from stdin and decode it.
def getMessage():
rawLength = sys.stdin.buffer.read(4)
if len(rawLength) == 0:
sys.exit(0)
messageLength = struct.unpack('@I', rawLength)[0]
message = sys.stdin.buffer.read(messageLength).decode('utf-8')
return json.loads(message)
# Send an encoded message to stdout
def sendMessage(messageContent):
encodedContent = json.dumps(messageContent).encode('utf-8')
encodedLength = struct.pack('@I', len(encodedContent))
sys.stdout.buffer.write(encodedLength)
sys.stdout.buffer.write(encodedContent)
sys.stdout.buffer.flush()
except AttributeError:
# Python 2.x version (if sys.stdin.buffer is not defined)
# Read a message from stdin and decode it.
def getMessage():
rawLength = sys.stdin.read(4)
if len(rawLength) == 0:
sys.exit(0)
messageLength = struct.unpack('@I', rawLength)[0]
message = sys.stdin.read(messageLength)
return json.loads(message)
# Send an encoded message to stdout
def sendMessage(messageContent):
encodedContent = json.dumps(messageContent)
encodedLength = struct.pack('@I', len(encodedContent))
sys.stdout.write(encodedLength)
sys.stdout.write(encodedContent)
sys.stdout.flush()
def install():
home_path = os.getenv('HOME')
manifest = {
'name': 'open_with',
'description': 'Open With native host',
'path': os.path.realpath(__file__),
'type': 'stdio',
}
locations = {
'chrome': os.path.join(home_path, '.config', 'google-chrome', 'NativeMessagingHosts'),
'chrome-beta': os.path.join(home_path, '.config', 'google-chrome-beta', 'NativeMessagingHosts'),
'chrome-unstable': os.path.join(home_path, '.config', 'google-chrome-unstable', 'NativeMessagingHosts'),
'chromium': os.path.join(home_path, '.config', 'chromium', 'NativeMessagingHosts'),
'firefox': os.path.join(home_path, '.mozilla', 'native-messaging-hosts'),
}
filename = 'open_with.json'
for browser, location in locations.items():
if os.path.exists(os.path.dirname(location)):
if not os.path.exists(location):
os.mkdir(location)
browser_manifest = manifest.copy()
if browser == 'firefox':
browser_manifest['allowed_extensions'] = ['openwith@darktrojan.net']
else:
browser_manifest['allowed_origins'] = [
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/', # Chrome
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/', # Opera
]
with open(os.path.join(location, filename), 'w') as file:
file.write(
json.dumps(browser_manifest, indent=2, separators=(',', ': '), sort_keys=True).replace(' ', '\t') + '\n'
)
def _read_desktop_file(path):
with open(path, 'r') as desktop_file:
current_section = None
name = None
command = None
for line in desktop_file:
if line[0] == '[':
current_section = line[1:-2]
if current_section != 'Desktop Entry':
continue
if line.startswith('Name='):
name = line[5:].strip()
elif line.startswith('Exec='):
command = line[5:].strip()
return {
'name': name,
'command': command
}
def find_browsers():
apps = [
'Chrome',
'Chromium',
'chromium-browser',
'firefox',
'Firefox',
'Google Chrome',
'google-chrome',
'opera',
'Opera',
'SeaMonkey',
'seamonkey',
]
paths = [
os.path.join(os.getenv('HOME'), '.local/share/applications'),
'/usr/local/share/applications',
'/usr/share/applications'
]
suffix = '.desktop'
results = []
for p in paths:
for a in apps:
fp = os.path.join(p, a) + suffix
if os.path.exists(fp):
results.append(_read_desktop_file(fp))
return results
def listen():
receivedMessage = getMessage()
if receivedMessage == 'ping':
sendMessage({
'version': VERSION,
'file': os.path.realpath(__file__)
})
elif receivedMessage == 'find':
sendMessage(find_browsers())
else:
for k, v in os.environ.items():
if k.startswith('MOZ_'):
try:
os.unsetenv(k)
except:
os.environ[k] = ''
devnull = open(os.devnull, 'w')
subprocess.Popen(receivedMessage, stdout=devnull, stderr=devnull)
sendMessage(None)
if __name__ == '__main__':
if len(sys.argv) == 2:
if sys.argv[1] == 'install':
install()
sys.exit(0)
elif sys.argv[1] == 'find_browsers':
print(find_browsers())
sys.exit(0)
allowed_extensions = [
'openwith@darktrojan.net',
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/',
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/',
]
for ae in allowed_extensions:
if ae in sys.argv:
listen()
sys.exit(0)
print('Open With native helper, version %s.' % VERSION)