gpt4 book ai didi

linux - NASM 通知发送?

转载 作者:太空宇宙 更新时间:2023-11-04 04:08:10 25 4
gpt4 key购买 nike

有没有办法在Linux终端中显示类似notify-send命令的消息,用NASM编码?

我在 Ubuntu 中使用这个命令:

notify-send "Test"

是否可以使用 NASM 显示类似的内容?

最佳答案

您想将文本发送到桌面并显示在弹出窗口中吗?好吧,我对通知发送一无所知,所以我进行了搜索,发现您可以使用通知库编写一些东西。总而言之,我花了 10 分钟阅读一些文档、示例代码并编写此内容...

bits 64 
extern notify_init, notify_notification_new, notify_notification_show, notify_uninit

extern exit

section .data
name db "Sample Notification", 0
title db "Just a test", 0

global main
section .text
main:
mov rdi, name
call notify_init

mov rdx, 0
mov rsi, title
mov rdi, name
call notify_notification_new

mov rsi, 0
mov rdi, rax
call notify_notification_show

call notify_uninit

call exit

生成文件:

APP = notify
$(APP): $(APP).o
gcc -o $(APP) $(APP).o -lnotify

$(APP).o: $(APP).asm
nasm -f elf64 $(APP).asm

您需要使用 apt-get 或包管理器安装 libnotify-dev

32 位系统应该类似。

Gnome Notify Docs

关于linux - NASM 通知发送?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20317417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com