
自从我使用Ubuntu创建自己的办公环境以来,已经快三年了. 最近我更改了新的MBP,系统非常舒适.
但是,在我的TP W540上部署了Ubuntu,并且W540 +电源适配器太重(我的电池是9芯电池)
您将使用多少Mac?带来了一些Ubuntu使用习惯.

一种习惯是,在Ubuntu的右上角有一个日历(一个月中的那一天的日历),但是没有mac,然后我认为应该有一个自定义在Mac上的实现方法.
我进行了一些搜索,找到了GeekTool工具. 真的很棒桌面的美观程度取决于您的想象力.
我主要想在此处实现一个需要外壳的自定义日历.

下载地址:
对于文档,您需要自己阅读英文文档. 使用难度: 简单.
我想在桌面上显示上个月mac桌面日历软件,当前月份和下个月三个月的日历,并应突出显示当前月份的当前日期.

需求非常简单,并且这样做有点麻烦. 问题主要是OSX中的命令与Ubuntu中的cal命令不同.
OSX中的cal不具有此功能,因为它没有,请自己编写,python是一种功能强大的语言mac桌面日历软件,我选择使用python实现此功能.
代码如下:

#!/usr/bin/env python import calendar import datetime import re def get_year_month(d): """ :param datetime_obj: a datetime object ; for example : datetime.datetime.now() :return: a datetime object """ return d.year, d.month def get_pre_datetime(datetime_obj): """ :param datetime_obj: a datetime object ; for example : datetime.datetime.now() :return: a datetime object """ days_count = datetime.timedelta(days=datetime_obj.day) pre_month_last_day_datetime_obj = datetime_obj - days_count return pre_month_last_day_datetime_obj def get_next_datetime(datetime_obj): """ :param datetime_obj: a datetime object ; for example : datetime.datetime.now() :return: a datetime object """ days_count = calendar.monthrange(datetime_obj.year, datetime_obj.month)[1] next_month_datetime = datetime_obj + datetime.timedelta(days=days_count+1) - datetime.timedelta(datetime.datetime.now().day) return next_month_datetime def day_format(datetime_obj, cal_str): """ :param datetime_obj: a datetime object ; for example : datetime.datetime.now() :param d: a datetime object ; for example : datetime.datetime.now() :return: a datetime object """ day = datetime_obj.day reg_num = "\D{}\D".format(day) reg = re.search(reg_num, cal_str).group() ret = re.sub('\d+', "\033[31m{}\033[0m".format(day), reg) return re.sub(reg, ret, cal_str) if __name__ == '__main__': currnet_time = datetime.datetime.now() pre_year_month = get_year_month(get_pre_datetime(currnet_time)) currnet_year_month = get_year_month(currnet_time) next_year_month = get_year_month(get_next_datetime(currnet_time)) # with open('/var/tmp/cal.log', 'w') as f: # f.write(calendar.month(*pre_year_month, w=3, l=1)) # f.write(day_format(currnet_time, calendar.month(*currnet_year_month, w=3, l=1))) # f.write(calendar.month(*next_year_month, w=3, l=1)) print(calendar.month(*pre_year_month, w=3, l=1)) print(day_format(currnet_time, calendar.month(*currnet_year_month, w=3, l=2))) print(calendar.month(*next_year_month, w=3, l=1))
完成的效果图

在使用过程中,新年期间没有问题:

本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-202202-1.html
他马云高互联网也可能的确不需要行贿
理智理智