sway: add mail
This commit is contained in:
parent
cf70307a1f
commit
83ea379bbc
|
@ -1,4 +1,7 @@
|
||||||
# LEL
|
# LEL
|
||||||
|
#
|
||||||
|
# SWAY
|
||||||
|
#
|
||||||
|
|
||||||
# Variables {{{
|
# Variables {{{
|
||||||
#
|
#
|
||||||
|
@ -11,20 +14,22 @@
|
||||||
set $right l
|
set $right l
|
||||||
|
|
||||||
set $term kitty
|
set $term kitty
|
||||||
set $menu swaymsg exec 'rofi -show drun -display-drun Iniciar:'
|
set $menu swaymsg exec 'wofi --show drun -i -p Iniciar:'
|
||||||
font pango:Hack 14px
|
font pango:Hack 14px
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
# Output configuration {{{
|
# Output configuration {{{
|
||||||
#
|
#
|
||||||
output * bg ~/.config/sway/minimalistic_interjection.jpg fill
|
output * bg '#303030' solid_color
|
||||||
|
|
||||||
# output HDMI-A-1 resolution 720x576
|
# output HDMI-A-1 resolution 720x576
|
||||||
|
|
||||||
#Disable laptop screen if closed, --reload is important
|
#Disable laptop screen if closed, --reload is important
|
||||||
set $laptop eDP-1
|
set $laptop eDP-1
|
||||||
bindswitch --reload lid:on output $laptop disable; reload
|
bindswitch --reload lid:on output $laptop disable
|
||||||
bindswitch --reload lid:off output $laptop enable; reload
|
bindswitch --reload lid:off output $laptop enable
|
||||||
|
# output $laptop disable
|
||||||
|
# bindsym $mod+o output eDP-1 toggle
|
||||||
|
|
||||||
# Backlight settings for laptops
|
# Backlight settings for laptops
|
||||||
exec sudo light -N 1
|
exec sudo light -N 1
|
||||||
|
@ -127,8 +132,8 @@
|
||||||
bindsym $mod+Shift+0 move container to workspace 10
|
bindsym $mod+Shift+0 move container to workspace 10
|
||||||
|
|
||||||
# Assign programs to their workspace
|
# Assign programs to their workspace
|
||||||
assign [class=qutebrowser] workspace 2
|
assign [app_id=org.qutebrowser.qutebrowser] workspace 2
|
||||||
assign [class=TelegramDesktop] workspace 10
|
assign [app_id=telegramdesktop] workspace 10
|
||||||
assign [class=discord] workspace 10
|
assign [class=discord] workspace 10
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -227,14 +232,16 @@
|
||||||
exec udiskie
|
exec udiskie
|
||||||
# Blue light filter
|
# Blue light filter
|
||||||
exec redshift
|
exec redshift
|
||||||
|
# Bluetooth Daemon
|
||||||
|
exec blueberry-tray
|
||||||
# lock screen after a period of inactivity execp for fullscreen
|
# lock screen after a period of inactivity execp for fullscreen
|
||||||
for_window [class=.*] inhibit_idle fullscreen
|
for_window [class=.*] inhibit_idle fullscreen
|
||||||
exec swayidle -w \
|
exec swayidle -w \
|
||||||
before-sleep 'swaylock -f' \
|
before-sleep 'swaylock -f' \
|
||||||
lock swaylock \
|
lock swaylock \
|
||||||
timeout 900 'swaylock -f' \
|
timeout 900 'swaylock -f' \
|
||||||
timeout 1800 'swaymsg "output * dpms off"' \
|
# timeout 1800 'swaymsg "output * dpms off"' \
|
||||||
resume 'swaymsg "output * dpms on;reload"' \
|
# resume 'swaymsg "output * dpms on;reload"' \
|
||||||
#}}}
|
#}}}
|
||||||
|
|
||||||
include /etc/sway/config.d/*
|
include /etc/sway/config.d/*
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// Choose the order of the modules
|
// Choose the order of the modules
|
||||||
"modules-left": ["sway/workspaces", "sway/mode", "sway/window"],
|
"modules-left": ["sway/workspaces", "sway/mode", "sway/window"],
|
||||||
"modules-center": ["clock"],
|
"modules-center": ["clock"],
|
||||||
"modules-right": ["mpd", "pulseaudio", "network", "battery","custom/weather", "tray"],
|
"modules-right": ["mpd", "pulseaudio", "network", "battery","custom/weather","custom/mail", "tray"],
|
||||||
//Modules configuration
|
//Modules configuration
|
||||||
"sway/workspaces": {
|
"sway/workspaces": {
|
||||||
// "disable-scroll": true,
|
// "disable-scroll": true,
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
},
|
},
|
||||||
"battery": {
|
"battery": {
|
||||||
"states": {
|
"states": {
|
||||||
// "good": 95,
|
"good": 95,
|
||||||
"warning": 30,
|
"warning": 30,
|
||||||
"critical": 15
|
"critical": 15
|
||||||
},
|
},
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
"format-charging": "{capacity}% ",
|
"format-charging": "{capacity}% ",
|
||||||
"format-plugged": "{capacity}% ",
|
"format-plugged": "{capacity}% ",
|
||||||
"format-alt": "{time} {icon}",
|
"format-alt": "{time} {icon}",
|
||||||
// "format-good": "", // An empty format will hide the module
|
"format-good": "",
|
||||||
"format-full": "",
|
"format-full": "",
|
||||||
"format-icons": ["", "", "", "", ""]
|
"format-icons": ["", "", "", "", ""]
|
||||||
},
|
},
|
||||||
|
@ -127,6 +127,13 @@
|
||||||
"tooltip":false,
|
"tooltip":false,
|
||||||
"exec": "$HOME/.config/waybar/custom/weather",
|
"exec": "$HOME/.config/waybar/custom/weather",
|
||||||
"interval": 1800
|
"interval": 1800
|
||||||
|
},
|
||||||
|
"custom/mail": {
|
||||||
|
"format":"{} ",
|
||||||
|
"tooltip":false,
|
||||||
|
"exec": "$HOME/.config/waybar/custom/mail",
|
||||||
|
"interval": 1800
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
# vim:ft=json
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright © 2016 Anton Karmanov <bergentroll@openmailbox.org>
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
import imaplib
|
||||||
|
from getpass import getpass
|
||||||
|
import os
|
||||||
|
try:
|
||||||
|
import keyring
|
||||||
|
keyring_loaded = True
|
||||||
|
except ImportError:
|
||||||
|
keyring_loaded = False
|
||||||
|
|
||||||
|
# _Settings____________________________________________________________________
|
||||||
|
|
||||||
|
config = {
|
||||||
|
'HOST': 'disroot.org',
|
||||||
|
'PORT': 993,
|
||||||
|
'USER': 'lelgenio@disroot.org',
|
||||||
|
'PASS': '',
|
||||||
|
'URL': 'https://mail.disroot.org'
|
||||||
|
}
|
||||||
|
# _____________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
def get_args():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='In interactive mode you able to manage your keys.'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-a', '--add', type=str, help='add key to keyring'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-r', '--remove', type=str, help='remove key from keyring'
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.add:
|
||||||
|
match = False
|
||||||
|
while not match:
|
||||||
|
pass_1 = getpass('Type password : ')
|
||||||
|
pass_2 = getpass('Type password again: ')
|
||||||
|
if pass_1 == pass_2:
|
||||||
|
match = True
|
||||||
|
keyring.set_password('tray-email', args.add, pass_1)
|
||||||
|
else:
|
||||||
|
print('\nPasswords do not match!\n')
|
||||||
|
return(True)
|
||||||
|
elif args.remove:
|
||||||
|
ack = input(
|
||||||
|
'Are you sure want to delete key for {}? '.format(args.remove)
|
||||||
|
)
|
||||||
|
if ack.lower() in ('y', 'yes'):
|
||||||
|
keyring.delete_password('tray-email', args.remove)
|
||||||
|
else:
|
||||||
|
print('Cancel.')
|
||||||
|
return(True)
|
||||||
|
return(False)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_instance():
|
||||||
|
INSTANCE = ''
|
||||||
|
try:
|
||||||
|
INSTANCE = os.environ['BLOCK_INSTANCE']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
if len(INSTANCE):
|
||||||
|
parse_config(INSTANCE)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_config(INSTANCE):
|
||||||
|
global config
|
||||||
|
HOME = os.environ['HOME']
|
||||||
|
config_file = configparser.ConfigParser()
|
||||||
|
CONFIG_PATH = HOME + '/.config/tray-email/' + INSTANCE
|
||||||
|
config_file.read(CONFIG_PATH)
|
||||||
|
for ITEM in config_file['MAIL']:
|
||||||
|
ITEM = ITEM.upper()
|
||||||
|
config[ITEM] = config_file['MAIL'][ITEM]
|
||||||
|
|
||||||
|
|
||||||
|
def get_PASS():
|
||||||
|
return(keyring.get_password('tray-email', config['USER']))
|
||||||
|
|
||||||
|
|
||||||
|
def serf():
|
||||||
|
box = imaplib.IMAP4_SSL(host=config['HOST'], port=config['PORT'])
|
||||||
|
box.login(config['USER'], config['PASS'])
|
||||||
|
box.select()
|
||||||
|
result, ids = box.search(None, 'UNSEEN')
|
||||||
|
box.logout()
|
||||||
|
return(len(ids[0].split()))
|
||||||
|
|
||||||
|
|
||||||
|
if (keyring_loaded and not get_args()) or not keyring_loaded:
|
||||||
|
parse_instance()
|
||||||
|
if not config['PASS']:
|
||||||
|
config['PASS'] = get_PASS()
|
||||||
|
amt = serf()
|
||||||
|
if amt == 0: exit()
|
||||||
|
print(amt)
|
|
@ -80,6 +80,7 @@ window#waybar.termite {
|
||||||
#pulseaudio,
|
#pulseaudio,
|
||||||
#custom-media,
|
#custom-media,
|
||||||
#custom-weather,
|
#custom-weather,
|
||||||
|
#custom-mail,
|
||||||
#tray,
|
#tray,
|
||||||
#mode,
|
#mode,
|
||||||
#idle_inhibitor {
|
#idle_inhibitor {
|
||||||
|
@ -155,6 +156,11 @@ label:focus {
|
||||||
/*background-color: #2980b9;*/
|
/*background-color: #2980b9;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#custom-mail {
|
||||||
|
border-top: 2px solid #67334d;
|
||||||
|
/*background-color: #2980b9;*/
|
||||||
|
}
|
||||||
|
|
||||||
#tray {
|
#tray {
|
||||||
border-top: 2px solid #2980b9;
|
border-top: 2px solid #2980b9;
|
||||||
/*background-color: #2980b9;*/
|
/*background-color: #2980b9;*/
|
||||||
|
|
Reference in New Issue