working on meli, bunch of stuff
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
./system-modules/ollama.nix
|
||||
|
||||
./system-modules/hsmw.nix
|
||||
./system-modules/health_reminder.nix
|
||||
|
||||
];
|
||||
|
||||
@@ -63,6 +64,7 @@
|
||||
services.openssh.enable = false;
|
||||
|
||||
|
||||
|
||||
# List packages installed in system profile. To search, run:
|
||||
# $ nix search wget
|
||||
environment.systemPackages = with pkgs; [
|
||||
@@ -110,4 +112,4 @@
|
||||
programs.bash.shellInit = ''
|
||||
source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
|
||||
'';
|
||||
}
|
||||
}
|
||||
|
||||
18
flake.lock
generated
18
flake.lock
generated
@@ -36,10 +36,26 @@
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1710272261,
|
||||
"narHash": "sha256-g0bDwXFmTE7uGDOs9HcJsfLFhH7fOsASbAuOzDC+fhQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0ad13a6833440b8e238947e47bea7f11071dc2b2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"home-manager": "home-manager",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,18 +3,21 @@
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-23.11";
|
||||
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
|
||||
home-manager.url = "github:nix-community/home-manager/release-23.11";
|
||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, home-manager, ... }:
|
||||
outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
user = "nx2";
|
||||
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
|
||||
allowed = {
|
||||
unfree-packages = [
|
||||
"spotify"
|
||||
"discord"
|
||||
"obsidian"
|
||||
"zoom-us"
|
||||
];
|
||||
@@ -39,9 +42,9 @@
|
||||
nx2 = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [ ./home.nix ];
|
||||
extraSpecialArgs = {inherit system user allowed secrets;};
|
||||
extraSpecialArgs = {inherit system user allowed secrets pkgs-unstable;};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
491
home-modules/discord.nix
Normal file
491
home-modules/discord.nix
Normal file
@@ -0,0 +1,491 @@
|
||||
{ config, pkgs, pkgs-unstable, allowed, ... }:
|
||||
{
|
||||
home.packages = [
|
||||
pkgs-unstable.vesktop
|
||||
];
|
||||
|
||||
home.file.".config/vesktop/settings/settings.json".text = ''
|
||||
{
|
||||
"notifyAboutUpdates": true,
|
||||
"autoUpdate": false,
|
||||
"autoUpdateNotification": true,
|
||||
"useQuickCss": true,
|
||||
"themeLinks": [
|
||||
"https://luckfire.github.io/amoled-cord/src/amoled-cord.css"
|
||||
],
|
||||
"enabledThemes": [],
|
||||
"enableReactDevtools": false,
|
||||
"frameless": false,
|
||||
"transparent": true,
|
||||
"winCtrlQ": false,
|
||||
"macosTranslucency": false,
|
||||
"disableMinSize": false,
|
||||
"winNativeTitleBar": false,
|
||||
"plugins": {
|
||||
"BadgeAPI": {
|
||||
"enabled": true
|
||||
},
|
||||
"CommandsAPI": {
|
||||
"enabled": true
|
||||
},
|
||||
"ContextMenuAPI": {
|
||||
"enabled": true
|
||||
},
|
||||
"MemberListDecoratorsAPI": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessageAccessoriesAPI": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessageDecorationsAPI": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessageEventsAPI": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessagePopoverAPI": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoticesAPI": {
|
||||
"enabled": true
|
||||
},
|
||||
"ServerListAPI": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoTrack": {
|
||||
"enabled": true
|
||||
},
|
||||
"Settings": {
|
||||
"enabled": true,
|
||||
"settingsLocation": "aboveActivity"
|
||||
},
|
||||
"SupportHelper": {
|
||||
"enabled": true
|
||||
},
|
||||
"ChatInputButtonAPI": {
|
||||
"enabled": false
|
||||
},
|
||||
"AlwaysAnimate": {
|
||||
"enabled": true
|
||||
},
|
||||
"AlwaysTrust": {
|
||||
"enabled": true
|
||||
},
|
||||
"AnonymiseFileNames": {
|
||||
"enabled": false
|
||||
},
|
||||
"WebRichPresence (arRPC)": {
|
||||
"enabled": false
|
||||
},
|
||||
"BANger": {
|
||||
"enabled": false
|
||||
},
|
||||
"BetterFolders": {
|
||||
"enabled": false
|
||||
},
|
||||
"BetterGifAltText": {
|
||||
"enabled": false
|
||||
},
|
||||
"BetterGifPicker": {
|
||||
"enabled": false
|
||||
},
|
||||
"BetterNotesBox": {
|
||||
"enabled": false
|
||||
},
|
||||
"BetterRoleDot": {
|
||||
"enabled": false
|
||||
},
|
||||
"BetterUploadButton": {
|
||||
"enabled": false
|
||||
},
|
||||
"BiggerStreamPreview": {
|
||||
"enabled": false
|
||||
},
|
||||
"BlurNSFW": {
|
||||
"enabled": false
|
||||
},
|
||||
"CallTimer": {
|
||||
"enabled": false
|
||||
},
|
||||
"ClearURLs": {
|
||||
"enabled": false
|
||||
},
|
||||
"ClientTheme": {
|
||||
"enabled": false
|
||||
},
|
||||
"ColorSighted": {
|
||||
"enabled": false
|
||||
},
|
||||
"ConsoleShortcuts": {
|
||||
"enabled": false
|
||||
},
|
||||
"CopyUserURLs": {
|
||||
"enabled": false
|
||||
},
|
||||
"CrashHandler": {
|
||||
"enabled": true
|
||||
},
|
||||
"CustomRPC": {
|
||||
"enabled": false
|
||||
},
|
||||
"Dearrow": {
|
||||
"enabled": false
|
||||
},
|
||||
"Decor": {
|
||||
"enabled": false
|
||||
},
|
||||
"DisableCallIdle": {
|
||||
"enabled": false
|
||||
},
|
||||
"EmoteCloner": {
|
||||
"enabled": false
|
||||
},
|
||||
"Experiments": {
|
||||
"enabled": false
|
||||
},
|
||||
"F8Break": {
|
||||
"enabled": false
|
||||
},
|
||||
"FakeNitro": {
|
||||
"enabled": false
|
||||
},
|
||||
"FakeProfileThemes": {
|
||||
"enabled": true
|
||||
},
|
||||
"FavoriteEmojiFirst": {
|
||||
"enabled": false
|
||||
},
|
||||
"FavoriteGifSearch": {
|
||||
"enabled": false
|
||||
},
|
||||
"FixCodeblockGap": {
|
||||
"enabled": false
|
||||
},
|
||||
"FixSpotifyEmbeds": {
|
||||
"enabled": false
|
||||
},
|
||||
"FixYoutubeEmbeds": {
|
||||
"enabled": false
|
||||
},
|
||||
"ForceOwnerCrown": {
|
||||
"enabled": false
|
||||
},
|
||||
"FriendInvites": {
|
||||
"enabled": false
|
||||
},
|
||||
"GameActivityToggle": {
|
||||
"enabled": false
|
||||
},
|
||||
"GifPaste": {
|
||||
"enabled": false
|
||||
},
|
||||
"GreetStickerPicker": {
|
||||
"enabled": false
|
||||
},
|
||||
"HideAttachments": {
|
||||
"enabled": false
|
||||
},
|
||||
"iLoveSpam": {
|
||||
"enabled": false
|
||||
},
|
||||
"IgnoreActivities": {
|
||||
"enabled": false
|
||||
},
|
||||
"ImageZoom": {
|
||||
"enabled": false
|
||||
},
|
||||
"InvisibleChat": {
|
||||
"enabled": false
|
||||
},
|
||||
"KeepCurrentChannel": {
|
||||
"enabled": false
|
||||
},
|
||||
"LastFMRichPresence": {
|
||||
"enabled": false
|
||||
},
|
||||
"LoadingQuotes": {
|
||||
"enabled": false
|
||||
},
|
||||
"MemberCount": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessageClickActions": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessageLinkEmbeds": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessageLogger": {
|
||||
"enabled": false
|
||||
},
|
||||
"MessageTags": {
|
||||
"enabled": false
|
||||
},
|
||||
"MoreCommands": {
|
||||
"enabled": false
|
||||
},
|
||||
"MoreKaomoji": {
|
||||
"enabled": false
|
||||
},
|
||||
"MoreUserTags": {
|
||||
"enabled": false
|
||||
},
|
||||
"Moyai": {
|
||||
"enabled": false
|
||||
},
|
||||
"MutualGroupDMs": {
|
||||
"enabled": false
|
||||
},
|
||||
"NewGuildSettings": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoBlockedMessages": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoDevtoolsWarning": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoF1": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoMosaic": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoPendingCount": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoProfileThemes": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoReplyMention": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoScreensharePreview": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoTypingAnimation": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoUnblockToJump": {
|
||||
"enabled": false
|
||||
},
|
||||
"NormalizeMessageLinks": {
|
||||
"enabled": false
|
||||
},
|
||||
"NotificationVolume": {
|
||||
"enabled": false
|
||||
},
|
||||
"NSFWGateBypass": {
|
||||
"enabled": false
|
||||
},
|
||||
"OnePingPerDM": {
|
||||
"enabled": false
|
||||
},
|
||||
"oneko": {
|
||||
"enabled": false
|
||||
},
|
||||
"OpenInApp": {
|
||||
"enabled": false
|
||||
},
|
||||
"Party mode 🎉": {
|
||||
"enabled": false
|
||||
},
|
||||
"PermissionFreeWill": {
|
||||
"enabled": false
|
||||
},
|
||||
"PermissionsViewer": {
|
||||
"enabled": false
|
||||
},
|
||||
"petpet": {
|
||||
"enabled": false
|
||||
},
|
||||
"PictureInPicture": {
|
||||
"enabled": false
|
||||
},
|
||||
"PinDMs": {
|
||||
"enabled": false
|
||||
},
|
||||
"PlainFolderIcon": {
|
||||
"enabled": false
|
||||
},
|
||||
"PlatformIndicators": {
|
||||
"enabled": false
|
||||
},
|
||||
"PreviewMessage": {
|
||||
"enabled": false
|
||||
},
|
||||
"PronounDB": {
|
||||
"enabled": false
|
||||
},
|
||||
"QuickMention": {
|
||||
"enabled": false
|
||||
},
|
||||
"QuickReply": {
|
||||
"enabled": false
|
||||
},
|
||||
"ReactErrorDecoder": {
|
||||
"enabled": false
|
||||
},
|
||||
"ReadAllNotificationsButton": {
|
||||
"enabled": false
|
||||
},
|
||||
"RelationshipNotifier": {
|
||||
"enabled": false
|
||||
},
|
||||
"RevealAllSpoilers": {
|
||||
"enabled": false
|
||||
},
|
||||
"ReverseImageSearch": {
|
||||
"enabled": false
|
||||
},
|
||||
"ReviewDB": {
|
||||
"enabled": false
|
||||
},
|
||||
"RoleColorEverywhere": {
|
||||
"enabled": true
|
||||
},
|
||||
"SearchReply": {
|
||||
"enabled": false
|
||||
},
|
||||
"SecretRingToneEnabler": {
|
||||
"enabled": false
|
||||
},
|
||||
"SendTimestamps": {
|
||||
"enabled": false
|
||||
},
|
||||
"ServerListIndicators": {
|
||||
"enabled": false
|
||||
},
|
||||
"ServerProfile": {
|
||||
"enabled": false
|
||||
},
|
||||
"ShikiCodeblocks": {
|
||||
"enabled": false
|
||||
},
|
||||
"ShowAllMessageButtons": {
|
||||
"enabled": false
|
||||
},
|
||||
"ShowConnections": {
|
||||
"enabled": false
|
||||
},
|
||||
"ShowHiddenChannels": {
|
||||
"enabled": false
|
||||
},
|
||||
"ShowMeYourName": {
|
||||
"enabled": false
|
||||
},
|
||||
"ShowTimeouts": {
|
||||
"enabled": false
|
||||
},
|
||||
"SilentMessageToggle": {
|
||||
"enabled": false
|
||||
},
|
||||
"SilentTyping": {
|
||||
"enabled": false
|
||||
},
|
||||
"SortFriendRequests": {
|
||||
"enabled": false
|
||||
},
|
||||
"SpotifyControls": {
|
||||
"enabled": false
|
||||
},
|
||||
"SpotifyCrack": {
|
||||
"enabled": false
|
||||
},
|
||||
"SpotifyShareCommands": {
|
||||
"enabled": false
|
||||
},
|
||||
"StartupTimings": {
|
||||
"enabled": false
|
||||
},
|
||||
"SuperReactionTweaks": {
|
||||
"enabled": false
|
||||
},
|
||||
"TextReplace": {
|
||||
"enabled": false
|
||||
},
|
||||
"ThemeAttributes": {
|
||||
"enabled": false
|
||||
},
|
||||
"TimeBarAllActivities": {
|
||||
"enabled": false
|
||||
},
|
||||
"Translate": {
|
||||
"enabled": false
|
||||
},
|
||||
"TypingIndicator": {
|
||||
"enabled": false
|
||||
},
|
||||
"TypingTweaks": {
|
||||
"enabled": false
|
||||
},
|
||||
"Unindent": {
|
||||
"enabled": false
|
||||
},
|
||||
"UnsuppressEmbeds": {
|
||||
"enabled": false
|
||||
},
|
||||
"UrbanDictionary": {
|
||||
"enabled": false
|
||||
},
|
||||
"UserVoiceShow": {
|
||||
"enabled": false
|
||||
},
|
||||
"USRBG": {
|
||||
"enabled": false
|
||||
},
|
||||
"ValidUser": {
|
||||
"enabled": false
|
||||
},
|
||||
"VoiceChatDoubleClick": {
|
||||
"enabled": false
|
||||
},
|
||||
"VcNarrator": {
|
||||
"enabled": false
|
||||
},
|
||||
"VencordToolbox": {
|
||||
"enabled": false
|
||||
},
|
||||
"ViewIcons": {
|
||||
"enabled": false
|
||||
},
|
||||
"ViewRaw": {
|
||||
"enabled": false
|
||||
},
|
||||
"VoiceMessages": {
|
||||
"enabled": false
|
||||
},
|
||||
"WebContextMenus": {
|
||||
"enabled": true,
|
||||
"addBack": true
|
||||
},
|
||||
"WebKeybinds": {
|
||||
"enabled": true
|
||||
},
|
||||
"WhoReacted": {
|
||||
"enabled": false
|
||||
},
|
||||
"Wikisearch": {
|
||||
"enabled": false
|
||||
},
|
||||
"XSOverlay": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
"notifications": {
|
||||
"timeout": 5000,
|
||||
"position": "bottom-right",
|
||||
"useNative": "not-focused",
|
||||
"logLimit": 50
|
||||
},
|
||||
"cloud": {
|
||||
"authenticated": false,
|
||||
"url": "https://api.vencord.dev/",
|
||||
"settingsSync": false,
|
||||
"settingsSyncVersion": 1710459223618
|
||||
}
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
||||
|
||||
@@ -13,5 +13,20 @@
|
||||
# Gestures
|
||||
gesture swipe left 3 echo key k:276 | dotool
|
||||
gesture swipe right 3 echo key k:275 | dotool
|
||||
'';
|
||||
'';
|
||||
# systemd.user.services = {
|
||||
# ydotoold = {
|
||||
# Unit = {
|
||||
# Description = "An auto-input utility for wayland";
|
||||
# Documentation = [ "man:ydotool(1)" "man:ydotoold(8)" ];
|
||||
# };
|
||||
|
||||
# Service = {
|
||||
# ExecStart = "/run/current-system/sw/bin/ydotoold --socket-path /tmp/ydotool_socket ";
|
||||
# };
|
||||
# Install = {
|
||||
# WantedBy = ["default.target"];
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{ config, pkgs, lib, system, user, allowed, secrets, ... }:
|
||||
|
||||
{
|
||||
programs.git = {
|
||||
enable = true;
|
||||
userName = "nx2";
|
||||
userEmail = "nx2@nx2.site";
|
||||
delta = {
|
||||
enable = true;
|
||||
options = {
|
||||
line-numbers = true;
|
||||
side-by-side = false;
|
||||
features = "unobtrusive-line-numbers decorations";
|
||||
whitespace-error-style = "22 reverse";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
12
home-modules/mako.nix
Normal file
12
home-modules/mako.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.mako
|
||||
pkgs.libnotify
|
||||
];
|
||||
services.mako = {
|
||||
enable = true;
|
||||
defaultTimeout = 60000;
|
||||
};
|
||||
}
|
||||
22
home-modules/meli/meli.nix
Normal file
22
home-modules/meli/meli.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{ config, pkgs, lib, system, user, allowed, secrets, ... }:
|
||||
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.meli
|
||||
pkgs.msmtp
|
||||
pkgs.w3m
|
||||
|
||||
# (pkgs.writeScriptBin "mutt_oauth" (builtins.readFile ./mutt_oauth2.py))
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
home.file.".config/meli.config" = {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
370
home-modules/meli/oauth2.py
Normal file
370
home-modules/meli/oauth2.py
Normal file
@@ -0,0 +1,370 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright 2012 Google Inc.
|
||||
# Copyright 2020 Manos Pitsidianakis
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Performs client tasks for testing IMAP OAuth2 authentication.
|
||||
|
||||
To use this script, you'll need to have registered with Google as an OAuth
|
||||
application and obtained an OAuth client ID and client secret.
|
||||
See https://developers.google.com/identity/protocols/OAuth2 for instructions on
|
||||
registering and for documentation of the APIs invoked by this code.
|
||||
|
||||
This script has 3 modes of operation.
|
||||
|
||||
1. The first mode is used to generate and authorize an OAuth2 token, the
|
||||
first step in logging in via OAuth2.
|
||||
|
||||
oauth2 --user=xxx@gmail.com \
|
||||
--client_id=1038[...].apps.googleusercontent.com \
|
||||
--client_secret=VWFn8LIKAMC-MsjBMhJeOplZ \
|
||||
--generate_oauth2_token
|
||||
|
||||
The script will converse with Google and generate an oauth request
|
||||
token, then present you with a URL you should visit in your browser to
|
||||
authorize the token. Once you get the verification code from the Google
|
||||
website, enter it into the script to get your OAuth access token. The output
|
||||
from this command will contain the access token, a refresh token, and some
|
||||
metadata about the tokens. The access token can be used until it expires, and
|
||||
the refresh token lasts indefinitely, so you should record these values for
|
||||
reuse.
|
||||
|
||||
2. The script will generate new access tokens using a refresh token.
|
||||
|
||||
oauth2 --user=xxx@gmail.com \
|
||||
--client_id=1038[...].apps.googleusercontent.com \
|
||||
--client_secret=VWFn8LIKAMC-MsjBMhJeOplZ \
|
||||
--refresh_token=1/Yzm6MRy4q1xi7Dx2DuWXNgT6s37OrP_DW_IoyTum4YA
|
||||
|
||||
3. The script will generate an OAuth2 string that can be fed
|
||||
directly to IMAP or SMTP. This is triggered with the --generate_oauth2_string
|
||||
option.
|
||||
|
||||
oauth2 --generate_oauth2_string --user=xxx@gmail.com \
|
||||
--access_token=ya29.AGy[...]ezLg
|
||||
|
||||
The output of this mode will be a base64-encoded string. To use it, connect to a
|
||||
IMAPFE and pass it as the second argument to the AUTHENTICATE command.
|
||||
|
||||
a AUTHENTICATE XOAUTH2 a9sha9sfs[...]9dfja929dk==
|
||||
"""
|
||||
|
||||
import base64
|
||||
import imaplib
|
||||
import json
|
||||
from optparse import OptionParser
|
||||
import smtplib
|
||||
import sys
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def SetupOptionParser():
|
||||
# Usage message is the module's docstring.
|
||||
parser = OptionParser(usage=__doc__)
|
||||
parser.add_option(
|
||||
"--generate_oauth2_token",
|
||||
action="store_true",
|
||||
dest="generate_oauth2_token",
|
||||
help="generates an OAuth2 token for testing",
|
||||
)
|
||||
parser.add_option(
|
||||
"--generate_oauth2_string",
|
||||
action="store_true",
|
||||
dest="generate_oauth2_string",
|
||||
help="generates an initial client response string for " "OAuth2",
|
||||
)
|
||||
parser.add_option(
|
||||
"--client_id",
|
||||
default=None,
|
||||
help="Client ID of the application that is authenticating. "
|
||||
"See OAuth2 documentation for details.",
|
||||
)
|
||||
parser.add_option(
|
||||
"--client_secret",
|
||||
default=None,
|
||||
help="Client secret of the application that is "
|
||||
"authenticating. See OAuth2 documentation for "
|
||||
"details.",
|
||||
)
|
||||
parser.add_option("--access_token", default=None, help="OAuth2 access token")
|
||||
parser.add_option("--refresh_token", default=None, help="OAuth2 refresh token")
|
||||
parser.add_option(
|
||||
"--scope",
|
||||
default="https://mail.google.com/",
|
||||
help="scope for the access token. Multiple scopes can be "
|
||||
"listed separated by spaces with the whole argument "
|
||||
"quoted.",
|
||||
)
|
||||
parser.add_option(
|
||||
"--test_imap_authentication",
|
||||
action="store_true",
|
||||
dest="test_imap_authentication",
|
||||
help="attempts to authenticate to IMAP",
|
||||
)
|
||||
parser.add_option(
|
||||
"--test_smtp_authentication",
|
||||
action="store_true",
|
||||
dest="test_smtp_authentication",
|
||||
help="attempts to authenticate to SMTP",
|
||||
)
|
||||
parser.add_option(
|
||||
"--user",
|
||||
default=None,
|
||||
help="email address of user whose account is being " "accessed",
|
||||
)
|
||||
parser.add_option(
|
||||
"--quiet",
|
||||
action="store_true",
|
||||
default=False,
|
||||
dest="quiet",
|
||||
help="Omit verbose descriptions and only print " "machine-readable outputs.",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
# The URL root for accessing Google Accounts.
|
||||
GOOGLE_ACCOUNTS_BASE_URL = "https://accounts.google.com"
|
||||
|
||||
|
||||
# Hardcoded dummy redirect URI for non-web apps.
|
||||
REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob"
|
||||
|
||||
|
||||
def AccountsUrl(command):
|
||||
"""Generates the Google Accounts URL.
|
||||
|
||||
Args:
|
||||
command: The command to execute.
|
||||
|
||||
Returns:
|
||||
A URL for the given command.
|
||||
"""
|
||||
return "%s/%s" % (GOOGLE_ACCOUNTS_BASE_URL, command)
|
||||
|
||||
|
||||
def UrlEscape(text):
|
||||
# See OAUTH 5.1 for a definition of which characters need to be escaped.
|
||||
return urllib.parse.quote(text, safe="~-._")
|
||||
|
||||
|
||||
def UrlUnescape(text):
|
||||
# See OAUTH 5.1 for a definition of which characters need to be escaped.
|
||||
return urllib.parse.unquote(text)
|
||||
|
||||
|
||||
def FormatUrlParams(params):
|
||||
"""Formats parameters into a URL query string.
|
||||
|
||||
Args:
|
||||
params: A key-value map.
|
||||
|
||||
Returns:
|
||||
A URL query string version of the given parameters.
|
||||
"""
|
||||
param_fragments = []
|
||||
for param in sorted(iter(params.items()), key=lambda x: x[0]):
|
||||
param_fragments.append("%s=%s" % (param[0], UrlEscape(param[1])))
|
||||
return "&".join(param_fragments)
|
||||
|
||||
|
||||
def GeneratePermissionUrl(client_id, scope="https://mail.google.com/"):
|
||||
"""Generates the URL for authorizing access.
|
||||
|
||||
This uses the "OAuth2 for Installed Applications" flow described at
|
||||
https://developers.google.com/accounts/docs/OAuth2InstalledApp
|
||||
|
||||
Args:
|
||||
client_id: Client ID obtained by registering your app.
|
||||
scope: scope for access token, e.g. 'https://mail.google.com'
|
||||
Returns:
|
||||
A URL that the user should visit in their browser.
|
||||
"""
|
||||
params = {}
|
||||
params["client_id"] = client_id
|
||||
params["redirect_uri"] = REDIRECT_URI
|
||||
params["scope"] = scope
|
||||
params["response_type"] = "code"
|
||||
return "%s?%s" % (AccountsUrl("o/oauth2/auth"), FormatUrlParams(params))
|
||||
|
||||
|
||||
def AuthorizeTokens(client_id, client_secret, authorization_code):
|
||||
"""Obtains OAuth access token and refresh token.
|
||||
|
||||
This uses the application portion of the "OAuth2 for Installed Applications"
|
||||
flow at https://developers.google.com/accounts/docs/OAuth2InstalledApp#handlingtheresponse
|
||||
|
||||
Args:
|
||||
client_id: Client ID obtained by registering your app.
|
||||
client_secret: Client secret obtained by registering your app.
|
||||
authorization_code: code generated by Google Accounts after user grants
|
||||
permission.
|
||||
Returns:
|
||||
The decoded response from the Google Accounts server, as a dict. Expected
|
||||
fields include 'access_token', 'expires_in', and 'refresh_token'.
|
||||
"""
|
||||
params = {}
|
||||
params["client_id"] = client_id
|
||||
params["client_secret"] = client_secret
|
||||
params["code"] = authorization_code
|
||||
params["redirect_uri"] = REDIRECT_URI
|
||||
params["grant_type"] = "authorization_code"
|
||||
request_url = AccountsUrl("o/oauth2/token")
|
||||
|
||||
response = urllib.request.urlopen(
|
||||
request_url, urllib.parse.urlencode(params).encode()
|
||||
).read()
|
||||
return json.loads(response)
|
||||
|
||||
|
||||
def RefreshToken(client_id, client_secret, refresh_token):
|
||||
"""Obtains a new token given a refresh token.
|
||||
|
||||
See https://developers.google.com/accounts/docs/OAuth2InstalledApp#refresh
|
||||
|
||||
Args:
|
||||
client_id: Client ID obtained by registering your app.
|
||||
client_secret: Client secret obtained by registering your app.
|
||||
refresh_token: A previously-obtained refresh token.
|
||||
Returns:
|
||||
The decoded response from the Google Accounts server, as a dict. Expected
|
||||
fields include 'access_token', 'expires_in', and 'refresh_token'.
|
||||
"""
|
||||
params = {}
|
||||
params["client_id"] = client_id
|
||||
params["client_secret"] = client_secret
|
||||
params["refresh_token"] = refresh_token
|
||||
params["grant_type"] = "refresh_token"
|
||||
request_url = AccountsUrl("o/oauth2/token")
|
||||
|
||||
response = urllib.request.urlopen(
|
||||
request_url, urllib.parse.urlencode(params).encode()
|
||||
).read()
|
||||
return json.loads(response)
|
||||
|
||||
|
||||
def GenerateOAuth2String(username, access_token, base64_encode=True):
|
||||
"""Generates an IMAP OAuth2 authentication string.
|
||||
|
||||
See https://developers.google.com/google-apps/gmail/oauth2_overview
|
||||
|
||||
Args:
|
||||
username: the username (email address) of the account to authenticate
|
||||
access_token: An OAuth2 access token.
|
||||
base64_encode: Whether to base64-encode the output.
|
||||
|
||||
Returns:
|
||||
The SASL argument for the OAuth2 mechanism.
|
||||
"""
|
||||
auth_string = "user=%s\1auth=Bearer %s\1\1" % (username, access_token)
|
||||
if base64_encode:
|
||||
auth_string = base64.b64encode(bytes(auth_string, "utf-8"))
|
||||
return auth_string
|
||||
|
||||
|
||||
def TestImapAuthentication(user, auth_string):
|
||||
"""Authenticates to IMAP with the given auth_string.
|
||||
|
||||
Prints a debug trace of the attempted IMAP connection.
|
||||
|
||||
Args:
|
||||
user: The Gmail username (full email address)
|
||||
auth_string: A valid OAuth2 string, as returned by GenerateOAuth2String.
|
||||
Must not be base64-encoded, since imaplib does its own base64-encoding.
|
||||
"""
|
||||
print()
|
||||
imap_conn = imaplib.IMAP4_SSL("imap.gmail.com")
|
||||
imap_conn.debug = 4
|
||||
imap_conn.authenticate("XOAUTH2", lambda x: auth_string)
|
||||
imap_conn.select("INBOX")
|
||||
|
||||
|
||||
def TestSmtpAuthentication(user, auth_string):
|
||||
"""Authenticates to SMTP with the given auth_string.
|
||||
|
||||
Args:
|
||||
user: The Gmail username (full email address)
|
||||
auth_string: A valid OAuth2 string, not base64-encoded, as returned by
|
||||
GenerateOAuth2String.
|
||||
"""
|
||||
print()
|
||||
smtp_conn = smtplib.SMTP("smtp.gmail.com", 587)
|
||||
smtp_conn.set_debuglevel(True)
|
||||
smtp_conn.ehlo("test")
|
||||
smtp_conn.starttls()
|
||||
smtp_conn.docmd("AUTH", "XOAUTH2 " + base64.b64encode(auth_string))
|
||||
|
||||
|
||||
def RequireOptions(options, *args):
|
||||
missing = [arg for arg in args if getattr(options, arg) is None]
|
||||
if missing:
|
||||
print("Missing options: %s" % " ".join(missing), file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
def main(argv):
|
||||
options_parser = SetupOptionParser()
|
||||
(options, args) = options_parser.parse_args()
|
||||
if options.refresh_token:
|
||||
RequireOptions(options, "client_id", "client_secret")
|
||||
response = RefreshToken(
|
||||
options.client_id, options.client_secret, options.refresh_token
|
||||
)
|
||||
if options.quiet:
|
||||
print(response["access_token"])
|
||||
else:
|
||||
print("Access Token: %s" % response["access_token"])
|
||||
print("Access Token Expiration Seconds: %s" % response["expires_in"])
|
||||
elif options.generate_oauth2_string:
|
||||
RequireOptions(options, "user", "access_token")
|
||||
oauth2_string = GenerateOAuth2String(options.user, options.access_token)
|
||||
if options.quiet:
|
||||
print(oauth2_string.decode("utf-8"))
|
||||
else:
|
||||
print("OAuth2 argument:\n" + oauth2_string.decode("utf-8"))
|
||||
elif options.generate_oauth2_token:
|
||||
RequireOptions(options, "client_id", "client_secret")
|
||||
print("To authorize token, visit this url and follow the directions:")
|
||||
print(" %s" % GeneratePermissionUrl(options.client_id, options.scope))
|
||||
authorization_code = input("Enter verification code: ")
|
||||
response = AuthorizeTokens(
|
||||
options.client_id, options.client_secret, authorization_code
|
||||
)
|
||||
print("Refresh Token: %s" % response["refresh_token"])
|
||||
print("Access Token: %s" % response["access_token"])
|
||||
print("Access Token Expiration Seconds: %s" % response["expires_in"])
|
||||
elif options.test_imap_authentication:
|
||||
RequireOptions(options, "user", "access_token")
|
||||
TestImapAuthentication(
|
||||
options.user,
|
||||
GenerateOAuth2String(
|
||||
options.user, options.access_token, base64_encode=False
|
||||
),
|
||||
)
|
||||
elif options.test_smtp_authentication:
|
||||
RequireOptions(options, "user", "access_token")
|
||||
TestSmtpAuthentication(
|
||||
options.user,
|
||||
GenerateOAuth2String(
|
||||
options.user, options.access_token, base64_encode=False
|
||||
),
|
||||
)
|
||||
else:
|
||||
options_parser.print_help()
|
||||
print("Nothing to do, exiting.")
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
@@ -16,7 +16,7 @@
|
||||
programs.neomutt = {
|
||||
enable = true;
|
||||
package = pkgs.neomutt;
|
||||
editor = "micro";
|
||||
editor = "$EDITOR";
|
||||
sort = "date";
|
||||
sidebar = {
|
||||
enable = true;
|
||||
@@ -43,7 +43,6 @@
|
||||
imapPass = "";
|
||||
imapAuthenticators = "oauthbearer:xoauth2";
|
||||
imapOAuthRefreshCommand = "mutt_oauth ~/.config/mutt/${imapUser}.tokens";
|
||||
smtpUrl = "smtp://lennart.kurzweg.lk@smtp.gmail.com:587/";
|
||||
smtpPass = "";
|
||||
sslForceTls = true;
|
||||
realname = "Lennart J. Kurzweg";
|
||||
@@ -81,4 +80,22 @@
|
||||
# ];
|
||||
# };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
accounts.email.accounts = {
|
||||
secrets.email.gmail.mail1 = {
|
||||
primary = true;
|
||||
smtp = "";
|
||||
smtpUrl = "smtp://lennart.kurzweg.lk@smtp.gmail.com:587/";
|
||||
realName = "Lennart J. Kurzweg";
|
||||
address = secrets.email.gmail.mail1;
|
||||
aliases = [ ];
|
||||
userName = "nx2";
|
||||
passwordCommand = "op read op://Personal/iCloud/himalaya";
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
{ config, pkgs, lib, system, user, allowed, secrets, ... }:
|
||||
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.neomutt
|
||||
pkgs.isync
|
||||
pkgs.msmtp
|
||||
pkgs.notmuch
|
||||
pkgs.abook
|
||||
pkgs.urlview
|
||||
|
||||
(pkgs.writeScriptBin "mutt_oauth" (builtins.readFile ./scripts/mutt_oauth2.py))
|
||||
|
||||
];
|
||||
|
||||
programs.neomutt = {
|
||||
enable = true;
|
||||
package = pkgs.neomutt;
|
||||
editor = "micro";
|
||||
sort = "date";
|
||||
sidebar = {
|
||||
enable = true;
|
||||
};
|
||||
binds = [
|
||||
{ map = [ "index" ]; key = "<F4>"; action = "sidebar-toggle-visible"; }
|
||||
{ map = [ "pager" ]; key = "<F4>"; action = "sidebar-toggle-visible"; }
|
||||
{ map = [ "index" ]; key = "\\Cp"; action = "sidebar-prev"; }
|
||||
{ map = [ "pager" ]; key = "\\Cp"; action = "sidebar-prev"; }
|
||||
{ map = [ "index" ]; key = "\\Cn"; action = "sidebar-next"; }
|
||||
{ map = [ "pager" ]; key = "\\Cn"; action = "sidebar-next"; }
|
||||
{ map = [ "index" ]; key = "\\Co"; action = "sidebar-open"; }
|
||||
{ map = [ "pager" ]; key = "\\Co"; action = "sidebar-open"; }
|
||||
{ map = [ "pager" ]; key = "<up>"; action = "previous-line"; }
|
||||
{ map = [ "pager" ]; key = "<down>"; action = "next-line"; }
|
||||
];
|
||||
|
||||
settings = let imapUser = "lennart.kurzweg.lk@gmail.com"; in {
|
||||
cryptReplysign = true;
|
||||
cryptVerifySig = true;
|
||||
editHeaders = true;
|
||||
from = imapUser;
|
||||
inherit imapUser;
|
||||
imapPass = "";
|
||||
imapAuthenticators = "oauthbearer:xoauth2";
|
||||
imapOAuthRefreshCommand = "mutt_oauth ~/.config/mutt/${imapUser}.tokens";
|
||||
smtpUrl = "smtp://lennart.kurzweg.lk@smtp.gmail.com:587/";
|
||||
smtpPass = "";
|
||||
sslForceTls = true;
|
||||
realname = "Lennart J. Kurzweg";
|
||||
useFrom = true;
|
||||
timeout = 10;
|
||||
};
|
||||
|
||||
# Color Settings
|
||||
# colors = {
|
||||
# normal = "white default";
|
||||
# attachment = "brightyellow default";
|
||||
# hdrdefault = "cyan default";
|
||||
# indicator = "black cyan";
|
||||
# markers = "brightred default";
|
||||
# quoted = "green default";
|
||||
# signature = "cyan default";
|
||||
# status = "brightgreen blue";
|
||||
# tilde = "blue default";
|
||||
# tree = "red default";
|
||||
# index = [
|
||||
# "red default ~P"
|
||||
# "red default ~D"
|
||||
# "magenta default ~T"
|
||||
# ];
|
||||
# header = [
|
||||
# "brightgreen default ^From:"
|
||||
# "brightcyan default ^To:"
|
||||
# "brightcyan default ^Reply-To:"
|
||||
# "brightcyan default ^Cc:"
|
||||
# "brightblue default ^Subject:"
|
||||
# ];
|
||||
# body = [
|
||||
# "brightred default [\\-\\.+_a-zA-Z0-9]+@[\\-\\.a-zA-Z0-9]+"
|
||||
# "brightblue default (https?|ftp)://[\\-\\.,/%~_:?&=\\#a-zA-Z0-9]+"
|
||||
# ];
|
||||
# };
|
||||
};
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
{ config, pkgs, lib, system, user, allowed, secrets, ... }:
|
||||
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.remmina
|
||||
pkgs.openvpn
|
||||
|
||||
(pkgs.writeShellScriptBin "connect_to_pnx" ''
|
||||
pushd ~/.ssl/
|
||||
sudo openvpn --config /home/nx2/.vpn/ljk-pnx.ovpn --auth-user-pass ~/.vpn/ljk-pnx-pass.txt #gets put there by home-manager
|
||||
popd
|
||||
'')
|
||||
|
||||
];
|
||||
|
||||
home.file = {
|
||||
|
||||
".vpn/ljk-pnx-cert.pem".text = secrets.pnxVpn.cert;
|
||||
".vpn/ljk-pnx-cert.key".text = secrets.pnxVpn.certKey;
|
||||
".vpn/ljk-pnx-ca.pem".text = secrets.pnxVpn.ca;
|
||||
".vpn/ljk-pnx.ovpn".text = secrets.pnxVpn.ovpn;
|
||||
".vpn/ljk-pnx-pass.txt".text = secrets.pnxVpn.pass;
|
||||
|
||||
# Remmina
|
||||
".local/share/remmina/pnx_rdp_srv-phoe3-vmdms_192-168-1-104.remmina".source = ./secrets/pnx-vpn/pnx_rdp_srv-phoe3-vmdms_192-168-1-104.remmina;
|
||||
".local/share/remmina/pnx_rdp_srv-phoenix-3_192-168-1-108.remmina".source = ./secrets/pnx-vpn/pnx_rdp_srv-phoenix-3_192-168-1-108.remmina;
|
||||
".local/share/remmina/pnx_rdp_srv-phoenix2_192-168-1-101.remmina".source = ./secrets/pnx-vpn/pnx_rdp_srv-phoenix2_192-168-1-101.remmina;
|
||||
".local/share/remmina/pnx_rdp_srv-remote_192-168-1-21.remmina".source = ./secrets/pnx-vpn/pnx_rdp_srv-remote_192-168-1-21.remmina;
|
||||
};
|
||||
}
|
||||
11
home-modules/shell/zoxide.nix
Normal file
11
home-modules/shell/zoxide.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.zoxide
|
||||
];
|
||||
programs.zoxide = {
|
||||
enable = true;
|
||||
enableFishIntegration = true;
|
||||
};
|
||||
}
|
||||
@@ -36,6 +36,7 @@
|
||||
gencer.html-slim-scss-css-class-completion
|
||||
donjayamanne.githistory
|
||||
mads-hartmann.bash-ide-vscode
|
||||
bungcip.better-toml
|
||||
|
||||
#jeanp413.open-remote-ssh
|
||||
# ms-vscode-remote.remote-ssh
|
||||
|
||||
57
home.nix
57
home.nix
@@ -2,10 +2,12 @@
|
||||
{
|
||||
imports = [
|
||||
./home-modules/vscode.nix
|
||||
./home-modules/mutt/neomutt.nix
|
||||
./home-modules/discord.nix
|
||||
./home-modules/meli.nix
|
||||
# ./home-modules/mutt/neomutt.nix
|
||||
./home-modules/gestures.nix
|
||||
|
||||
./home-modules/pnx.nix
|
||||
./home-modules/pnx/pnx.nix
|
||||
# ./home-modules/hsmw.nix
|
||||
|
||||
./home-modules/hyprland/hyprland.nix
|
||||
@@ -14,9 +16,11 @@
|
||||
./home-modules/shell/fish.nix
|
||||
./home-modules/shell/starship.nix
|
||||
./home-modules/shell/yazi.nix
|
||||
./home-modules/shell/zoxide.nix
|
||||
|
||||
./home-modules/ssh.nix
|
||||
./home-modules/git.nix
|
||||
./home-modules/mako.nix
|
||||
|
||||
./home-modules/theme/gtk.nix
|
||||
./home-modules/theme/qt.nix
|
||||
@@ -34,7 +38,11 @@
|
||||
kitty
|
||||
zathura
|
||||
#vesktop
|
||||
thunderbird element-desktop # zoom-us
|
||||
thunderbird element-desktop
|
||||
# zoom-us
|
||||
# vesktop
|
||||
discord
|
||||
signal-desktop
|
||||
|
||||
obsidian
|
||||
spotify spicetify-cli
|
||||
@@ -44,9 +52,12 @@
|
||||
|
||||
imv mpv mediainfo exiftool ffmpeg
|
||||
pavucontrol fontpreview gtk2fontsel
|
||||
lynx bat du-dust eza neofetch zoxide tldr fzf figlet delta ripgrep lolcat
|
||||
lynx bat du-dust eza neofetch tldr fzf figlet delta ripgrep lolcat jq
|
||||
brightnessctl wev
|
||||
element sssnake pipes
|
||||
|
||||
nodejs
|
||||
|
||||
(pkgs.python3.withPackages (python-pkgs: [
|
||||
python-pkgs.pandas
|
||||
python-pkgs.requests
|
||||
@@ -74,21 +85,7 @@
|
||||
'';
|
||||
})
|
||||
];
|
||||
# systemd.user.services = {
|
||||
# ydotoold = {
|
||||
# Unit = {
|
||||
# Description = "An auto-input utility for wayland";
|
||||
# Documentation = [ "man:ydotool(1)" "man:ydotoold(8)" ];
|
||||
# };
|
||||
|
||||
# Service = {
|
||||
# ExecStart = "/run/current-system/sw/bin/ydotoold --socket-path /tmp/ydotool_socket ";
|
||||
# };
|
||||
# Install = {
|
||||
# WantedBy = ["default.target"];
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
|
||||
home.file = {
|
||||
};
|
||||
# Home Manager can also manage your environment variables through
|
||||
@@ -102,31 +99,13 @@
|
||||
#
|
||||
# /etc/profiles/per-user/nx2/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
home.sessionVariables = {
|
||||
XDG_CONFIG_HOME = "$HOME/.config";
|
||||
XDG_DATA_HOME = "$HOME/.local/share";
|
||||
XDG_CACHE_HOME = "$HOME/.";
|
||||
XDG_STATE_HOME = "$HOME/.local/state";
|
||||
};
|
||||
programs.git = {
|
||||
enable = true;
|
||||
userName = "nx2";
|
||||
userEmail = "nx2@local";
|
||||
delta = {
|
||||
enable = true;
|
||||
options = {
|
||||
line-numbers = true;
|
||||
side-by-side = false;
|
||||
features = "unobtrusive-line-numbers decorations";
|
||||
whitespace-error-style = "22 reverse";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
xdg = {
|
||||
enable = true;
|
||||
configHome = /home/${user}/.config;
|
||||
cacheHome = /home/${user}/.cache;
|
||||
dataHome = /home/${user}/.local/share;
|
||||
stateHome = /home/${user}/.local/state;
|
||||
mimeApps = {
|
||||
enable = true;
|
||||
defaultApplications = {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
61
system-modules/health_reminder.nix
Normal file
61
system-modules/health_reminder.nix
Normal file
@@ -0,0 +1,61 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
systemd.timers."health_reminder" = {
|
||||
enable = true;
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = "5m";
|
||||
OnUnitActiveSec = "5m";
|
||||
Unit = "health_reminder.service";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."health_reminder" =
|
||||
let hm = pkgs.writeScriptBin "health_reminder" ''
|
||||
#!${pkgs.python3}/bin/python3
|
||||
import random
|
||||
|
||||
class Action:
|
||||
def __init__(self, actionA: str, actionB: str, likelihood: int, options: str):
|
||||
self.actionA = actionA
|
||||
self.actionB = actionB
|
||||
self.likelihood = likelihood
|
||||
self.options = options
|
||||
|
||||
def __str__(self):
|
||||
if self.options:
|
||||
return f"{self.actionA}{random.choice(self.options)}{self.actionB}"
|
||||
else:
|
||||
return self.actionA
|
||||
|
||||
|
||||
actions = [
|
||||
Action("look away for 20 Seconds!", "", 300, ""),
|
||||
Action("Shrimp 3000!", "", 90, ""),
|
||||
Action("Do ", " Biceps curls with each Arm! ", 5, ["50", "10", "20"]),
|
||||
Action("Do ", " Shourlder thingees", 5, ["30", "50", "20"]),
|
||||
Action("Plank for ", " senonds!", 5, ["60", "60", "70"]),
|
||||
Action("Strech your upper body!", "", 10, ""),
|
||||
Action("Strech your core!", "", 5, ""),
|
||||
Action("Strech your legs!", "", 5, ""),
|
||||
Action("Make Tea!", "", 5, ""),
|
||||
]
|
||||
|
||||
total_likelihood = sum(a.likelihood for a in actions)
|
||||
random_action = random.choices(actions, [a.likelihood for a in actions], k=1)[0]
|
||||
print(random_action)
|
||||
'';
|
||||
in
|
||||
{
|
||||
script = ''
|
||||
set -eu
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus"
|
||||
${pkgs.libnotify}/bin/notify-send "$(${hm}/bin/health_reminder)"
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "nx2";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user