@wxy
https://linux.cn/article-15995-1.html
This commit is contained in:
Xingyu Wang 2023-07-13 16:26:22 +08:00
parent 3e5da644a9
commit 13adfc8838
2 changed files with 210 additions and 211 deletions

View File

@ -0,0 +1,210 @@
[#]: subject: "Display Animated ASCII Birthday Wish in Linux Terminal 🎂"
[#]: via: "https://itsfoss.com/birthday-wish-linux-terminal/"
[#]: author: "Sreenath https://itsfoss.com/author/sreenath/"
[#]: collector: "lkxed"
[#]: translator: "ChatGPT"
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-15995-1.html"
在 Linux 终端显示动画式 ASCII 生日祝福 🎂
======
![][0]
> 通过在 Linux 终端创建 ASCII 生日动画,让你所爱的人的特殊日子更加特别。
生日是特殊的日子,从亲朋好友那里收到生日祝福是非常令人满足和愉悦的。
作为 Linux 用户,你可以通过终端给朋友和家人带来一些酷炫的生日祝福。
这是我为 Abhishek 先生的生日制作的生日卡片(或者说动画)。
<video src="https://img.linux.net.cn/static/video/birthday-wish-linux-terminal.mp4" autoplay></video>
我们团队的每个人都非常喜欢它,所以我受到请求要按照它做一个教程。我很乐意满足请求,因为这可能对我们的读者有所帮助 :)
> ✋ 这个教程需要在终端中编辑配置文件。熟练使用 Linux 终端和命令会更容易理解和跟随本教程。
### 安装 PyBirthdayWish
PyBirthdayWish 是一个小型的 Python 程序,通过它你可以创建漂亮的终端生日祝福,还可以播放音乐!
这个程序本身在 Ubuntu 的默认软件仓库中不可用,你需要使用 Pip 进行安装。
> **[PyBirthdayWish GitHub][1]**
首先,使用以下命令在 Ubuntu 中 [安装 Pip][2]
```
sudo apt install python3-pip
```
安装完 Pip 后,你可以克隆该存储库并安装该程序:
```
git clone https://github.com/hemantapkh/PyBirthdayWish.git && cd PyBirthdayWish && pip install -r requirements.txt
```
在他们的存储库中,你可以查看 `.requirements.txt` 文件,了解上述命令中所需的依赖项。
安装完成后,在你克隆的 `PyBirthdayWish` 目录中运行以下命令:
```
python3 PyBirthdayWish.py
```
这将要求你按下 `F11` 键,然后按回车键进入全屏模式,然后播放动画。
![][3]
![][4]
这里还有音乐,但这里没有展示。
它非常可定制化。**让我展示一下你可以通过这个工具进行的各种级别的可选定制。**
### 创建默认的生日祝福动画
在上述程序中,有三个用于动画的 Python 文件。它们是 `example`(默认)、`art` 和 `artwithstars`。你可以打开这三个文件来了解其内容。
![arts 目录的内容,其中包含默认和用户创建的 art 文件][5]
现在,如果你想使用 `artwithstars` 文件代替默认的 `example` 文件,在 [任何可用的文本编辑器][6] 中打开 `config.py`,将 `arts` 的条目替换为所需的名称,然后保存,如下面的截图所示:
![在配置文件中将动画设计文件更改为 "art with stars"][7]
之后,在 `PyBirthdayWish` 目录中运行:
```
python3 PyBirthdayWish.py
```
你将得到新的动画效果。
### 创建自定义的生日祝福
如果你想打印你所爱的人的名字,而不是默认的文字,这需要一点耐心,因为你需要在不破坏原文件的情况下编辑 art 文件。
首先,备份你想要的设计 art 文件。即在同一个 `arts` 目录中将文件复制一份,并给它一个不同的名称,比如 `friend.py`
现在,用你选择的文本编辑器打开设计 art 文件。将文件中的文字替换为你需要的内容。最好使用符号 `| _ \ /` 等来创建文本和设计。你可以使用一个 [在线工具将文字转换为 ASCII 艺术][8]。
![复制了一个现有的设计文件,并添加了一个新的文字 "Friend"][9]
> 💡 输入一个字符将使动画的其余部分向前移动一个字符。同样,删除一个字符会使设计的其余部分向后移动一个字符。因此,如果删除一个字符,请添加一个空格。同样地,如果在某一行上添加了一个新字符,请删除一个空格。这应该实时进行,这样你就可以查看更改。这样,你就可以使剩余的设计匹配,并在完成时保持外观不变。
编辑完成后保存文件。现在,打开 `config.py` 并将 art 文件更改为你的文件,以显示你所做的更改。
![在配置文件中更改设计文件以反映我们所做的更改][10]
现在你可以运行程序,以获得你所需的文字出现在动画中:
```
python3 PyBirthdayWish.py
```
### 使用自己的音乐文件
你可以使用自己的音乐文件作为这个动画的一部分。
> 🚧 如果你计划在 YouTube 或其他网站上上传视频,请使用无版权的音乐以避免问题。
将你的音乐文件复制到克隆的目录中。
![自定义的音乐文件被复制到克隆的目录中][11]
编辑 `config.py` 文件以添加新的音乐,如下面的截图所示:
![在配置文件中添加自定义音乐文件以在动画中播放][12]
完成!现在,如果执行运行命令 `python3 PyBirthdayWish.py`,自定义音乐将与动画一起播放。
![自定义音乐文件在动画中播放][13]
### 创建一个可执行文件
**如果你想将上述祝福消息作为可执行文件发送给朋友,这也是可行的。**
关联的 `pyinstaller` 将安装到 `.local/bin` 目录中,它不在你的路径中。
所以使用以下命令将该目录添加到你的路径中,[添加到你的路径中][15]
```
export PATH=$PATH:/home/team/.local/bin
```
要使其永久生效,将其添加到你的 `~/.bashrc` 文件中。
当你完成 art 文件的编辑并更改配置文件以反映更改后,使用以下命令创建一个可执行文件:
```
pyinstaller --noconfirm --onefile --console --icon "icon.ico" --no-embed-manifest --add-data "arts:arts/" --add-data "config.py:." --add-data "HappyBirthday.mp3:." --add-data "PyBirthdayWish.py:." "PyBirthdayWish.py"
```
它将在 `PyBirthdayWish/dist` 目录下创建一个名为 `PyBirthdayWish` 的可执行文件。
![程序创建的自定义可执行文件在文件管理器中显示][16]
将此可执行文件复制并发送给任何想查看它的人。他们可以使用以下命令执行它:
```
./PyBirthdayWish
```
> 🚧 请始终谨慎运行来自未知外部来源的可执行文件。
### 更多终端乐趣
像生日一样,圣诞节也是一个特殊的时刻。如果你愿意,你可以给你的 Linux 桌面增添一些节日气氛。
> **[用 Linux 的方式庆祝圣诞节:为你的 Linux 系统增添圣诞气氛][16a]**
如果你喜欢 ASCII 动画,你可能也会喜欢 ASCII 艺术。
> **[在 Linux 终端将图像转换为 ASCII 艺术图像][16b]**
为什么就止步于此呢?探索更多 ASCII 工具吧。
> **[在 Linux 终端生成 ASCII 艺术并从中获得乐趣的 10 个工具][16c]**
享受以这种有趣的方式使用 Linux :)
🗨 如果你在使用这个工具时遇到任何问题,请告诉我,我会尽力在我所能的范围内提供帮助。
*题图MJ/dfa0185d-e9f9-4c1a-886e-e42c9bb8d687*
--------------------------------------------------------------------------------
via: https://itsfoss.com/birthday-wish-linux-terminal/
作者:[Sreenath][a]
选题:[lkxed][b]
译者ChatGPT
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/sreenath/
[b]: https://github.com/lkxed/
[1]: https://github.com:443/hemantapkh/PyBirthdayWish
[2]: https://itsfoss.com/install-pip-ubuntu/
[3]: https://itsfoss.com/content/images/2023/07/animation-page-1.png
[4]: https://itsfoss.com/content/images/2023/07/animation-page-2.png
[5]: https://itsfoss.com/content/images/2023/07/arts-directory-contents.png
[6]: https://itsfoss.com/command-line-text-editors-linux/
[7]: https://itsfoss.com/content/images/2023/07/add-art-with-stars.png
[8]: https://patorjk.com:443/software/taag/#p=display&f=Big&t=Friend
[9]: https://itsfoss.com/content/images/2023/07/new-text-added-to-art-file-friend.png
[10]: https://itsfoss.com/content/images/2023/07/edit-config-file-to-add-custom-py-file.png
[11]: https://itsfoss.com/content/images/2023/07/showing-mymusic-file-in-directory.png
[12]: https://itsfoss.com/content/images/2023/07/custom-music-file.png
[13]: https://itsfoss.com/content/images/2023/04/efficient-at-linux-command-line-horizontal.png
[14]: https://amzn.to:443/3MPjiHw
[15]: https://itsfoss.com/add-directory-to-path-linux/
[16]: https://itsfoss.com/content/images/2023/07/PyBirthdayWish-executable-location.png
[16a]: https://itsfoss.com/christmas-linux-wallpaper/
[16b]: https://itsfoss.com/ascii-image-converter/
[16c]: https://itsfoss.com/ascii-art-linux-terminal/
[0]: https://img.linux.net.cn/data/attachment/album/202307/13/162413kvclclvgvhj8qqbz.jpg

View File

@ -1,211 +0,0 @@
[#]: subject: "Display Animated ASCII Birthday Wish in Linux Terminal 🎂"
[#]: via: "https://itsfoss.com/birthday-wish-linux-terminal/"
[#]: author: "Sreenath https://itsfoss.com/author/sreenath/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Display Animated ASCII Birthday Wish in Linux Terminal 🎂
======
Birthdays are special occasions, and its very satisfying and a pleasure to get birthday wishes from loved ones.
As a Linux user, you can surprise our friends and family with some cool birthday wishes from the terminal.
Here's a birthday card (or should I say animation) I created for the birthday of Abhishek Sir.
<video src="https://itsfoss.com/content/media/2023/07/birthday-wish-linux-terminal.webm" autoplay>
Everyone in the team liked it so much that I was requested to do a tutorial on it. I am only glad to comply as it may help our readers :)
> ✋ This tutorial requires editing config files in the terminal. Proficiency with Linux terminals and commands make it easier to follow this tutorial.
### Install PyBirthdayWish
PyBirthdayWish is a small Python program through which you can create beautiful terminal birthday wishes. With music too!
The program itself is not available in the default repositories of Ubuntu. You need to install it using Pip.
[PyBirthdayWish GitHub][1]
First, [install pip in Ubuntu][2], using the command below:
```
sudo apt install python3-pip
```
Once Pip is installed, you can clone the repo and install the program:
```
git clone https://github.com/hemantapkh/PyBirthdayWish.git && cd PyBirthdayWish && pip install -r requirements.txt
```
On their repo, you can check the `.requirements.txt` file to know what are the requirements as mentioned in the above command.
After the installation is complete, inside the `PyBirthdayWish` directory, that you have cloned, run the command below:
```
python3 PyBirthdayWish.py
```
This will ask you to press F11 and then enter to go full screen mode and then play the animation.
![][3]
![][4]
There is music too, but not shown here.
It's highly customizable. **Let me show various levels of optional customization you can do with this tool.**
### Sign up for FOSS Weekly
#### Become better at using Linux desktop every week
Subscribe
Email sent! Check your inbox to complete your signup.
Followed by more than 20,000 Linux users worldwide
### Create the default birthday wish
In the above program, there are three wish Python files that can be used for the animation. They are, _`example`_(default), _`art`_ and _`artwithstars`_. You can open these three files in text editor to get an overview.
![Contents of the arts directory, which has the default and user created art files][5]
Now, if you want to use the _`artwithstars`_ file instead of the default example, open the _`config.py`_ in [any available text editor][6], replace the _`arts`_ entry with the required name and save it, as shown in the screenshot below:
![Change the animation design file to "art with stars" on the config file][7]
After that, in the `PyBirthdayWish` directory, run:
```
python3 PyBirthdayWish.py
```
And you will get the new animation.
### Create a custom birthday wish
What if you want to print the name of your loved one, instead of the default text? This needs a little bit of patience because you need to edit the art file without destroying it.
First, make a backup copy of the design art files you want. Which is basically copying the file in the same `arts` directory but with a different name; say `friend.py`.
Now, open the design art file with the text editor of your choice. Replace the text in the art file with the one you need. It will be wise to use the symbols `| _ \ /` for creating the text, design etc. You can use an [online tool to convert text to ASCII][8].
![Copied one of the existing design files and added a new text "Friend"][9]
> 💡 Typing one character moves the rest of the animation one character forward. Similarly, removing a character moves the rest of the design, one character backward. So, you should add a space if you remove a character. Similarly, remove one space if you added a new character on a particular line. This should be done in real-time so that you can view the changes. This way, you can match the rest of the design and not destroy the looks, when completed.
After completing the edit, save it. Now, open _config.py_ and change the art file to show your file.
![Change the design file in the config to reflext the changes we have done][10]
You can now run to get your required text inside the animation:
```
python3 PyBirthdayWish.py
```
### Use your own music file
You can use your own music file as part of this animation.
> 🚧 If you are planning to upload the video on YouTube of other such sites, please use copyright-free music to avoid issues.
Copy your music file inside the cloned directory.
![Custome music file is copied inside the cloned directory][11]
Edit the _config.py_ file to add the new music, as shown in the screenshot below:
![Adding the custom music file to the config file to play it during animation][12]
Done! Now, if you execute the run command, `python3 PyBirthdayWish.py`, the custom music will be played along with the animation.
![][13]
##### New Book: Efficient Linux at the Command Line
Pretty amazing Linux book with lots of practical tips. It fills in the gap, even for experienced Linux users. Must have in your collection.
[Get it from Amazon][14]
### Create an executable
**If you want to send the above wish message as an executable to a friend, there is a way for this too.**
An associated pyinstaller will be installed to the `.local/bin` directory, which will not be on your path.
So [add that directory to your path][15] using:
```
export PATH=$PATH:/home/team/.local/bin
```
To make it permanent, add it to your `~/.bashrc` file.
After you are done with the art file editing and changing the config file to reflect the change, use the command below to create an executable:
```
pyinstaller --noconfirm --onefile --console --icon "icon.ico" --no-embed-manifest --add-data "arts:arts/" --add-data "config.py:." --add-data "HappyBirthday.mp3:." --add-data "PyBirthdayWish.py:." "PyBirthdayWish.py"
```
It will create an executable file named “PyBirthdayWish” to the `PyBirthdayWish/dist` directory.
![The custome executable file created by the program, showed in file manager][16]
Copy this executable and send to anybody who want to view this. They can execute it with:
```
./PyBirthdayWish
```
> 🚧 Always be cautious while running executables from unknown external sources.
### More terminal fun
Like Birthdays, Christmas too is a special occasion. You can give some festive touch to your Linux desktop if you want.
If you liked ASCII animation, you may like ASCII art, too.
And why just stop here? Explore more ASCII tools.
Enjoy using Linux in this fun way :)
_🗨 Let me know if you face any issues with this tool and I'll try to help in my capacity._
--------------------------------------------------------------------------------
via: https://itsfoss.com/birthday-wish-linux-terminal/
作者:[Sreenath][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/sreenath/
[b]: https://github.com/lkxed/
[1]: https://github.com:443/hemantapkh/PyBirthdayWish
[2]: https://itsfoss.com/install-pip-ubuntu/
[3]: https://itsfoss.com/content/images/2023/07/animation-page-1.png
[4]: https://itsfoss.com/content/images/2023/07/animation-page-2.png
[5]: https://itsfoss.com/content/images/2023/07/arts-directory-contents.png
[6]: https://itsfoss.com/command-line-text-editors-linux/
[7]: https://itsfoss.com/content/images/2023/07/add-art-with-stars.png
[8]: https://patorjk.com:443/software/taag/#p=display&f=Big&t=Friend
[9]: https://itsfoss.com/content/images/2023/07/new-text-added-to-art-file-friend.png
[10]: https://itsfoss.com/content/images/2023/07/edit-config-file-to-add-custom-py-file.png
[11]: https://itsfoss.com/content/images/2023/07/showing-mymusic-file-in-directory.png
[12]: https://itsfoss.com/content/images/2023/07/custom-music-file.png
[13]: https://itsfoss.com/content/images/2023/04/efficient-at-linux-command-line-horizontal.png
[14]: https://amzn.to:443/3MPjiHw
[15]: https://itsfoss.com/add-directory-to-path-linux/
[16]: https://itsfoss.com/content/images/2023/07/PyBirthdayWish-executable-location.png