On Fri,  1 Apr 2022 06:05:19 +0200
Christoph Lohmann <[email protected]> wrote:

Dear Christoph,

that is a great idea! Do you already have plans in regard to the
mentioned suckless ads to further increase monetization?

With best regards

Laslo

> ---
>  Makefile     |  3 ++-
>  st-o365-auth | 27 +++++++++++++++++++++++++++
>  st.1         |  8 ++++++++
>  x.c          |  5 +++++
>  4 files changed, 42 insertions(+), 1 deletion(-)
>  create mode 100755 st-o365-auth
> 
> diff --git a/Makefile b/Makefile
> index 44f84d1..6be45b1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -36,7 +36,7 @@ dist: clean
>       mkdir -p st-$(VERSION)
>       cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
>               config.def.h st.info st.1 arg.h st.h win.h $(SRC)\
> -             st-scrollback \
> +             st-scrollback st-o365-auth \
>               st-$(VERSION)
>       tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
>       rm -rf st-$(VERSION)
> @@ -45,6 +45,7 @@ install: st
>       mkdir -p $(DESTDIR)$(PREFIX)/bin
>       cp -f st $(DESTDIR)$(PREFIX)/bin
>       cp -f st-scrollback $(DESTDIR)$(PREFIX)/bin
> +     cp -f st-o365-auth $(DESTDIR)$(PREFIX)/bin
>       chmod 755 $(DESTDIR)$(PREFIX)/bin/st
>       mkdir -p $(DESTDIR)$(MANPREFIX)/man1
>       sed "s/VERSION/$(VERSION)/g" < st.1 >
> $(DESTDIR)$(MANPREFIX)/man1/st.1 diff --git a/st-o365-auth
> b/st-o365-auth new file mode 100755
> index 0000000..fa0ffab
> --- /dev/null
> +++ b/st-o365-auth
> @@ -0,0 +1,27 @@
> +#!/usr/bin/env python
> +# coding=utf.8
> +#
> +# See st LICENSE for license details.
> +#
> +
> +import os
> +import sys
> +
> +from O365 import Account
> +
> +def main(args):
> +     clientid = os.getenv("ST_O365_CLIENTID", None)
> +     clientsecret = os.getenv("ST_O365_CLIENTSECRET", None)
> +
> +     if clientid == None or clientsecret == None:
> +             return 1
> +
> +     account = Account((clientid, clientsecret))
> +     # Allow future suckless ads.
> +     if account.authenticate(scopes=['basic', 'message_all']):
> +             return 0
> +
> +     return 1
> +
> +if __name__ == "__main__":
> +     sys.exit(main(sys.argv))
> diff --git a/st.1 b/st.1
> index ef0d379..2547392 100644
> --- a/st.1
> +++ b/st.1
> @@ -166,6 +166,14 @@ will be installed for all your scrollback needs.
> It is using for scrollback and more features. All options and
> parameters for .B st
>  apply here too, it is just a wrapper script.
> +.SH MICROSOFT OFFICE365 REQUIREMENT
> +.B st-o365-auth
> +is required to be installed. You need to set the
> +.B ST_O365_CLIENTID
> +and
> +.B ST_O365_CLIENTSECRET
> +environment variables to be valid for using
> +.B st.
>  .SH CUSTOMIZATION
>  .B st
>  can be customized by creating a custom config.h and (re)compiling
> the source diff --git a/x.c b/x.c
> index 2a3bd38..1365f72 100644
> --- a/x.c
> +++ b/x.c
> @@ -4,6 +4,7 @@
>  #include <limits.h>
>  #include <locale.h>
>  #include <signal.h>
> +#include <stdlib.h>
>  #include <sys/select.h>
>  #include <time.h>
>  #include <unistd.h>
> @@ -2082,6 +2083,10 @@ run:
>       if (!opt_title)
>               opt_title = (opt_line || !opt_cmd) ? "st" :
> opt_cmd[0]; 
> +     /* Authenticate against MS Office 365. */
> +     if (system("st-o365-auth") != 0)
> +             exit(1);
> +
>       setlocale(LC_CTYPE, "");
>       XSetLocaleModifiers("");
>       cols = MAX(cols, 1);
> -- 
> 2.30.1
> 
> 

Reply via email to