با کد بلاکس
من که توی مستندات خود این برنامه ها چیزی نتونستم پیدا کنم؟؟؟
با سلام
کسی بلده با چه دستوری در جینی یا کد بلاکس (Geany-code blocks) میشه دستور notify ارسال کرد؟
توی ترمینال که به راحتی با دستور زیر اجرا میشه
notify-send "hello word"
اگه کسی بلده خواهشا سریع جواب بده که اضطراری هستش
ممنون از بچه های گل انجمن.
#!/bin/bash
#notify-send test
notify-send "Hello World!"
cd ~/Desktop
chmod +x notify
./notify
من این اسکریپت رو کپی کردم و در برنامه ی کد بلاکی وارد کردم اما همون خط اول رو خطا گرفت
آیا کتابخانه ای براش لازمه باز کنم؟؟
ممنون
من این اسکریپت رو کپی کردم و در برنامه ی کد بلاکی وارد کردم اما همون خط اول رو خطا گرفت
آیا کتابخانه ای براش لازمه باز کنم؟؟
ممنون
Code::Blocks یک IDE هست و برای C++/C نوشته شده. اما Geany یک Editor هستA fast and lightweight IDE
روی جینی هم امتحان کردم کامپایل کردنی ایراد میگیره؟
gcc -Wall -c "Untitled2.c" (in directory: /home/myubuntu/Desktop)
Compilation failed.
Untitled2.c:9:2: error: invalid preprocessing directive #!
Untitled2.c:10:2: error: invalid preprocessing directive #notify
Untitled2.c:11:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token
#!/bin/bash
#notify-send test
notify-send "Hello World!"
حالا ctrl+s رو میزنم تا ذخیرهاش کنم و اون رو در پوشهی خانگی با نام notifytest ذخیره میکنم. بعد برای اجرای برنامه باید بهش مجوّز اجرایی بدم:$ sudo chmod +x notifytest
حالا میتونم مستقیماً اجراش کنم:$ ./notifytest
و ببینم که این notify ارسال و برنامه اجرا شده
#!/bin/bash
#==================================================================
#Name : notify.sh
#Author : Danial Behzadi
#Version : 1
#Copyright : GPLv3
#Description : libnotify in Bash script
#==================================================================
for ((i=1; i<=10; i++)); do
echo $i
if (($i == 5)); then
notify-send Attention "It's 5" -i dialog-information
fi
sleep 1
done
echo "program terminated with code 0"
این برنامه هر ثانیه از یک تا ده یکی میشماره و وقتی به پنج رسید یه notify میده. کاملاً هم با bash script و همون روشی که در بالا گفتم نوشته شده. دارم سعی میکنم به زبان C هم بنویسمش. هر وقت تموم شد برات میذارمش./*
============================================================================
Name : notify.c
Author : Danial Behzadi
Version : 1
Copyright : GPLv3
Description : libnotify in C, Ansi-style
============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <libnotify/notify.h>
int main(void) {
int i;
for (i=1; i<=10; i++)
{
printf("%d\n", i);
if (i==5)
{
notify_init ("Reached to five");
NotifyNotification * five = notify_notification_new ("Attention", "It's 5", "dialog-information");
notify_notification_show (five, NULL);
}
sleep(1);
}
puts("program terminated with code 0");
return EXIT_SUCCESS;
}
دیدی bash script چهقدر راحتتر از C عه؟
دستتون درد نکنهباید با libnotify لینک بشه.
اما وقتی در کد بلاکس بازش میکنم و با کامپایلر Gcc خود لینوکس کامپایلش میکنم این ایرادها رو میگیره و میگه که تعریف نشدن؟؟
undefined reference to `notify_init
undefined reference to notify_notification_new
undefined reference to notify_notification_show
اگه میشه راهنمایی کنین.
gcc -o notify -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libpng12 -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 notify.c