如何在每次系统启动时以 CLI 方式自动启动 mate-terminal?

如何在每次系统启动时以 CLI 方式自动启动 mate-terminal?

更新2

目前最好的方法:

GUI方式的镜像。

问题:一路启动的 emacs 受到绑定到终端会话的限制:

当你说“好吧,emacs 已经用完了,现在想输入一些 bash 命令”时,你会怎么做? ?您可以通过输入 Ctrl+z 来暂停 emacs。这使得 emacs 进入后台并停止,直到您再次从那里恢复它。但不是,如果你像这里描述的那样启动 mate-terminal 和 emacs!更重要的是:为了应对这种不想要的结果,如果您随后通过使用 Ctrl-x Ctrl-c 结束 emacs 来选择替代路线,则不仅 emacs 会结束,而且 mate-terminal-session 也会结束!不需要的#2。有一个解决方案,但它有点老套 - 必须有比执行以下操作更好的方法来处理这个问题:

Ctrl-alt-t (another mate-terminal-tab opens)
Ctrl-x Ctrl-c (end emacs and in the course of that weirdly also the 1st mate-terminal-tab)
emacs -nw (start emacs again, this time explicitely, manually causing it to be invoked as a "real, usual" session, also capable of responding to stop signals like typing in Ctrl+z)

您知道如何解决最后两个问题吗?我们将不胜感激。


更新 - 回复评论部分 - 之后的基本发布:

我真的很想用 CLI 方式来做这件事 - 减少我作为用户对 GUI 的依赖。那么,您认为我最好朝着使用 rc.local 的方向前进?还没有尝试过,只是将其作为 B 计划列入我的 TODO 列表中,以防 crontab 方法无法工作 - 到目前为止假设它可以与 crontab 一起使用。如果 crontab 有针对我的用例的专用元素(例如“@reboot”),并且“重新启动 cronjob 日期”测试气球确实有效,为什么不能呢?!顺便说一句,系统用户是否尝试推荐网络视频“Linux 速成课程 - 使用 Cron 调度任务” -https://yewtu.be/watch?v=7cbP7fzn0D8

基本发帖:

我知道!这听起来很简单,但我就是无法让它发挥作用——尽管我已经尝试了很多东西。

您可能会想,“呃,只需将此行添加到您的登录用户,就这样了!” @reboot mate-terminal 但事情没那么简单。

我究竟做错了什么?完成拼图的最后一部分在哪里?我尝试过并发现了什么:

第一次尝试:GUI 方式

Trisquel-start-button in the left desktop corner at the bottom >
System >
Preferences >
Personal >
Startup Applications >
Tab 'Startup Programs' >
'add' >
Edit Startup Program
Name: Mate Terminal
Command: mate-terminal --full-screen --hide-menubar
Comment: Terminal >
Save >
Ensuring the activation box next to the new entry is checked

你知道吗?有用。有点儿。不太好:

System starts >
Gui with log-in window appears >
logging-in >
Desktop appears, with mate-terminal being right open >
screen blinks 2, 3 times with white screen >
mate-terminal is not the active window,
it's at the top of the desktop, covers everything by full-screen-mode,
but typing doesn't go into the terminal,
so, first I need to select mate-terminal by Alt+TAB,
making it the active window,
and only then what I'm typing goes into mate-terminal as input
and appears on the screen as output

这种次优的结果让我首先更深入地研究这个问题!

第二次尝试:Crontab

这是我多次尝试的一个小汇编,旨在澄清一些事情,这对于 crontab 按预期工作或展示事情实际顺利进行的程度非常重要

已登录用户

user@TechnoethicalX200T:~$ whoami
user

sudo 会员资格

user@TechnoethicalX200T:~$ cat /etc/group | grep sudo
sudo:x:27:user,automat

配对终端的可用性

user@TechnoethicalX200T:~$ which mate-terminal
/usr/bin/mate-terminal

执行 mate-terminal - 它有效

user@TechnoethicalX200T:~$ mate-terminal
(> new mate-terminal window popping up)

日期的可用性 - 为了进行比较,我们会做到这一点

user@TechnoethicalX200T:~$ which date
/bin/date

登录用户“user”的 crontab

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

# @reboot date >> /tmp/test-file-date-collection
# Before un-commenting:
# - (File not existing)
# After un-commenting: Works!
# user@TechnoethicalX200T:~$ cat /tmp/test-file-date-collection
# Thu 23 Nov 08:54:30 CET 2023
# user@TechnoethicalX200T:~$ who -b
#          system boot  2023-11-23 08:54
# Conclusion:
# The logged-in user 'user' is capable of setting up a working reboot cronjob,
# with just specifying command name - not explicitely [full path]/[command name]

# Failed - syslog
# user@TechnoethicalX200T:~$ grep -C5 "mate-terminal" /var/log/syslog
# Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Starting Permit User Sessions...
# Nov 24 18:25:06 TechnoethicalX200T cron[878]: (CRON) INFO (Running @reboot jobs)
# Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Starting LSB: MD monitoring daemon...
# Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Started D-Bus System Message Bus.
# Nov 24 18:25:06 TechnoethicalX200T dbus-daemon[888]: Unknown username "whoopsie" in message bus configuration file
# Nov 24 18:25:06 TechnoethicalX200T CRON[891]: (user) CMD (mate-terminal)
# Nov 24 18:25:06 TechnoethicalX200T dbus[888]: [system] AppArmor D-Bus mediation is enabled
# Nov 24 18:25:06 TechnoethicalX200T avahi-daemon[876]: Successfully called chroot().
# Nov 24 18:25:06 TechnoethicalX200T avahi-daemon[876]: Successfully dropped remaining capabilities.
# Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Started Avahi mDNS/DNS-SD Stack.
# Nov 24 18:25:06 TechnoethicalX200T avahi-daemon[876]: No service file found in /etc/avahi/services.
@reboot mate-terminal
(<<< newline character behind last line - both, of the whole crontab and of each active cronjob in it
That detail turned out to be important for crontab to work properly, and not on all systems that automatically gets added,
I had to input it manually)

长话短说,这也可以从测试气球“重新启动 cronjob 日期”起作用的事实推断出来:是的,我的系统上的 cron.service 已启用并激活(当前正在运行,一如既往)

我还创建了一个系统用户,赋予它 sudo 权限并让它执行 cronjob -

automat:x:1001:1001::/home/automat:/usr/sbin/nologin

在静脉中。

user@TechnoethicalX200T:~$ grep -C5 "mate-terminal" /var/log/syslog
Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Starting Permit User Sessions...
Nov 24 18:25:06 TechnoethicalX200T cron[878]: (CRON) INFO (Running @reboot jobs)
Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Starting LSB: MD monitoring daemon...
Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Started D-Bus System Message Bus.
Nov 24 18:25:06 TechnoethicalX200T dbus-daemon[888]: Unknown username "whoopsie" in message bus configuration file
Nov 24 18:25:06 TechnoethicalX200T CRON[891]: (user) CMD (mate-terminal)
Nov 24 18:25:06 TechnoethicalX200T dbus[888]: [system] AppArmor D-Bus mediation is enabled
Nov 24 18:25:06 TechnoethicalX200T avahi-daemon[876]: Successfully called chroot().
Nov 24 18:25:06 TechnoethicalX200T avahi-daemon[876]: Successfully dropped remaining capabilities.
Nov 24 18:25:06 TechnoethicalX200T systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Nov 24 18:25:06 TechnoethicalX200T avahi-daemon[876]: No service file found in /etc/avahi/services.
--
Nov 24 18:38:47 TechnoethicalX200T systemd[1]: Started inputattach for Wacom ISDv4-compatible serial devices.
Nov 24 18:38:47 TechnoethicalX200T systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
Nov 24 18:38:47 TechnoethicalX200T systemd[1]: Starting LSB: daemon to balance interrupts for SMP systems...
Nov 24 18:38:47 TechnoethicalX200T avahi-daemon[899]: Found user 'avahi' (UID 109) and group 'avahi' (GID 118).
Nov 24 18:38:47 TechnoethicalX200T systemd[1]: Starting Login Service...
Nov 24 18:38:47 TechnoethicalX200T CRON[912]: (automat) CMD (mate-terminal)
Nov 24 18:38:47 TechnoethicalX200T systemd[1]: Starting Console System Startup Logging...
Nov 24 18:38:47 TechnoethicalX200T avahi-daemon[899]: Successfully dropped root privileges.
Nov 24 18:38:47 TechnoethicalX200T avahi-daemon[899]: avahi-daemon 0.6.32-rc starting up.
Nov 24 18:38:47 TechnoethicalX200T avahi-daemon[899]: Successfully called chroot().
Nov 24 18:38:47 TechnoethicalX200T systemd[1]: Starting LSB: Start the GNUstep distributed object mapper...

那么,问题出在哪里呢?说真的,为什么不起作用?为什么重新启动后只出现桌面 - 没有伴侣终端窗口?对我来说没有意义。

相关内容