Use Python and netcore, Shell to develop an Ubuntu version of the timing reminders (with Netcore cross-platform two publishing methods)

Source: Internet
Author: User
Tags dotnet

Python3 vs. C # basic syntax: https://www.cnblogs.com/dotnetcrazy/p/9102030.html

Usually use timing reminders to improve work efficiency, to the Linux .... Mongolian Circle, the previous C # can't cross the platform ah, so there is this article ~ (some people like to work with tomatoes, this is a welfare)

Jump to Python:https://www.cnblogs.com/dotnetcrazy/p/9111200.html#python

Netcore First: (Old Code:me)

Core code:Process.Start ("Notify-send", "friendship reminder 10 minutes passed");

Principle: Call the Ubuntu notify-send Pop-up window reminders, control the loop and timing

Supplementary knowledge:Runtimeinformation.isosplatform (osplatform.xxx) this to judge what the system is, OSPlatform is a structural body

Timing Reminder:thread.sleep (New TimeSpan (0, 0));

The code is relatively simple to say, the main talk about environment deployment + Release

Using system;using system.threading;using system.diagnostics;using system.runtime.interopservices;//old:https://  Github.com/dunitian/dntlive/blob/master/software/lottimer/program.csnamespace netcore{class Program {static                    void Main (string[] args) {while (true) {try {                    Console.WriteLine (DateTime.Now.ToString ());                    Thread.Sleep (New TimeSpan (0, 10, 0));                Mybeep ();                    } catch {//exception not finished yet?                Break }}} private static void Mybeep () {if (Runtimeinformation.isosplatform (Osplat Form.                Linux) {Console.WriteLine ("Current system is Linux");                Process.Start ("Notify-send", "friendship reminder 10 minutes passed"); Start the specified program with Shell + command//process.start (new ProcessStartInfo ("Notify-send", "friendly reminder 10 minutes passed") {RedirectStandardOutput = true}); } else if (Runtimeinformation.isosplatform (Osplatform.windows)) {Console.WriteLine ("                The current system is Windows "); Frequency: The frequency of the beep, between 37 and 32767 Hz.                Duration: The duration, in milliseconds, of the beep.            Console.beep (500, 1500);            } else {Console.WriteLine ("limited effort, temporary not supported"); }        }    }}

to walk a process : (basically with the official website to go again, I post a few links and pictures)

I used to write: https://www.cnblogs.com/dunitian/p/6745562.html#netcore2.1

Official documents (Read more official documents): Https://www.microsoft.com/net/download/linux-package-manager/ubuntu18-04/sdk-current

2. Create a netcore console application:dotnet new Console

3. Install Vscode(directly download and install the Deb package): http://www.cnblogs.com/dunitian/p/6661644.html

4. Installing the vscode C # extension

5. Open the folder just now,F5 try to run , the new version of the seemingly do not have to configure their own running path or something

6. The code has just been pasted, coding a bit. Debug run what and win under no big difference

7.1 release, talk about the official recommended release method (suitable for developers), to the project directory, ctrl+alt+t call up terminal = = " dotnet publish–c release

Reference: HTTPS://DOCS.MICROSOFT.COM/ZH-CN/DOTNET/CORE/DEPLOYING/DEPLOY-WITH-CLI

It's a lightweight way to publish, get these two files out.

Operation effect:dotnet Xxx.dll, if you change the program name, the corresponding configuration name also remember to change Oh ~

7.2 released the second way " many people are not developers and don't want to installruntime" (Specify the Application Runtime (self-hosted app), which will package the core CLR of the specified platform):

Do one thing before you publish, add the systems you need to support, my side win10 and Ubuntu18 just fine (don't forget)

Add <RuntimeIdentifiers>win10-x64;ubuntu.18.04-x64 to <PropertyGroup> tags; </RuntimeIdentifiers>

System naming and System support reference: (seemingly android is also supported)

Https://docs.microsoft.com/zh-cn/dotnet/core/rid-catalog
Https://github.com/dotnet/corefx/blob/master/pkg/Microsoft.NETCore.Platforms/runtime.json

fix dependency + release runtime for specified system: dotnet publish-c release-r ubuntu.18.04-x64

In fact, the netcore2.x series does not need to enter restore again, it will automatically perform the restore

The self-hosted package is pretty big.

Found automatically generated a netcore suffix file, and is executable file "for the weak-based comrades popularized: 1. Look at the color 2.ll see if you have Execute permission", run it right now.

To try and publish a win10:dotnet publish-c release-r win10-x64

Drag to Win10 to test ~ok, cross-platform (same as other platforms, release when the operating system can be replaced)

This time it's Python's turn.

In fact, the core code is similar, a few words to solve

Import OS Import  Time  while True:     Print (Time.strftime ("%y-%m-%d%h:%m:%s", Time.localtime ()))    Time.sleep (     os.system ("notify-send Friendship Reminder 10 minutes passed ")

Run (you can actually set him up as an executable program "chmod +x./task.py" so that it is directly in the terminal ./task.py Run, Inverse day not recommended)

Shell:

 while  :  Do Sleep  - Echo  Time past Notify-echo'\a' done

I said a little bit about the daily use of Linux experience, you can skip this paragraph: (This paragraph in the end, or think I was advertising is not very good O (>ω<)) O)

Before the development environment are WIN10 or win series, and later net cross-platform, and slowly developed a dedicated notebook also replaced with Ubuntu, about the Linux Foundation and the environment and so on do not say, you can see my previous written articles (https://www.cnblogs.com/ Dunitian/p/4822808.html#linux)

Linux is basically used, before the development tool suddenly from vs into the JetBrains Rider (Netcore console program in Linux sometimes some inexplicable error, so just hooked up Rider) and vscode, abrupt slightly uncomfortable, It took me a few days to get acquainted. So development-related Linux is basically the same as win .

The key is the daily comparison of egg pain, affixed to a common Deb installation package, Https://pan.baidu.com/s/1kVI8eft this will not elaborate on the Ubuntu16.04 I used to send the article (http://www.cnblogs.com/ dunitian/p/6670560.html), with a barely able to use ALT+PRTSCR, can not be used in domestic deepin-screenshot or with Hotshots also line. The player can install it yourself: sudo apt-get install SMPlayer

Other in fact there is no more, the document has WPS, music has netease cloud , Input method has Sogou , dictionary can choose Youdao , browser anyway Google . Temporarily do not need the Linux version of the recording screen software (there is a good can recommend Oh ~) "Remember when I spoke in front of the dock mentioned a (http://www.cnblogs.com/dunitian/p/6681832.html)"

Use Python and netcore, Shell to develop an Ubuntu version of the timing reminder (with Netcore cross-platform two publishing methods)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.