You are not logged in.

#26 2021-04-18 11:55:34

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

You can use a longer "UPDATE" interval in line 4. It's 100 ms right now, you can set it to 200 or 300 or 1000 whatever your want to get longer flashes. Personally I think the rapid 10 fps updates look nice and more like a real physical HD LED, but to each his own.

Yes, those deprecation warnings. I think you will just have to live with them. I programmed this according to the latest PyGTK docs and there is no indication what functions I should use instead of these supposedly deprecated ones. So just ignore these messages for now. GTK 4 will probably break everything anyway, but that seems not to be supported by PyGTK right now…

Last edited by Morn (2021-04-18 13:39:13)

Offline

#27 2021-04-18 12:01:46

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Thanks morn for that info, i think in the messages it mentions to use the other use GLib.timeout_add instead
GObject.timeout_ it says, could you try using that see what it does, thanks for your time input, just need to set it up to autostart now

Offline

#28 2021-04-18 12:05:08

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

Great, don't forget to mark this thread as solved by editing your first post.

If you autostart it, make sure it can find its icons. E.g. just hardcode the path in line 26:

i = f"/home/me/somewhere/icon{rr}{ww}.png"

The code is indented with tabs, so just keep the indentation or set your editor's indentation mode accordingly. Python 3 does not like mixed tabs and spaces…

Last edited by Morn (2021-04-18 13:39:28)

Offline

#29 2021-04-18 13:18:17

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

The problem i get is running the python from bashrc file takes over the terminal and i cant use it for anything else, how to get the icom.py to run in background and allow use of terminal

Offline

#30 2021-04-18 13:19:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,523

Re: [SOLVED] Hard disk activity lights program required

foobar & disown

You maybe wanna read into some bash tutorials…

Offline

#31 2021-04-18 13:33:41

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

yes i googling on stuff i found nohup or pythonw trying those

Offline

#32 2021-04-18 13:35:32

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,523

Re: [SOLVED] Hard disk activity lights program required

Offline

#33 2021-04-18 13:42:38

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

jet14 wrote:

The problem i get is running the python from bashrc file takes over the terminal and i cant use it for anything else, how to get the icom.py to run in background and allow use of terminal

If you use startx, you can simply put this command in your .xinitrc.

Offline

#34 2021-04-18 15:06:29

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

I have tried out all the combinations, I have cinnamon starting from my xintrc, so i placed command in .bashrc as follows : nohup python /home/jet/hd-led_pygtk/icon.py &
only problem is if i start a new terminal  window then it starts a new instant of program but i can use tabs and so long as i dont keep restarting terminal i should be ok.

Offline

#35 2021-04-18 15:11:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,523

Re: [SOLVED] Hard disk activity lights program required

What does your bashrc have to do with your xinitrc?
How did you install archlinux?

Offline

#36 2021-04-18 15:16:09

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

jet14 wrote:

I have tried out all the combinations, I have cinnamon starting from my xintrc, so i placed command in .bashrc as follows : nohup python /home/jet/hd-led_pygtk/icon.py &
only problem is if i start a new terminal  window then it starts a new instant of program but i can use tabs and so long as i dont keep restarting terminal i should be ok.

Leave your .bashrc alone and put it in your .xinitrc then!

I have now also created a similar program to monitor network traffic:

#!/usr/bin/env python

fn = "/sys/class/net/enp23s0/statistics/"
UPDATE = 100	# update interval in ms
ro, wo = 0, 0
last = ""

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import GObject
from gi.repository import Gtk
tray = Gtk.StatusIcon()
tray.set_visible(True)

def update():
	global ro, wo, last

	r = open(fn + "rx_packets").read()
	w = open(fn + "tx_packets").read()
	rr, ww = "0", "0"
	if r != ro:
		rr = "1"
	if w != wo:
		ww = "1"
	ro, wo = r, w
	i = f"icon{rr}{ww}.png"
	if i != last:
		tray.set_from_file(i)
		tray.set_visible(True)
		last = i
	GObject.timeout_add(UPDATE, update)

update()
Gtk.main()

Last edited by Morn (2021-04-20 08:38:29)

Offline

#37 2021-04-18 15:30:56

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Hi i have lightdm autologin from cinnamon which is set in xintrc  as exec cinnamon-session
So my system auto boots without user name input to my desktop and then i have terminal and firefox autostart.

Offline

#38 2021-04-18 15:36:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,523

Re: [SOLVED] Hard disk activity lights program required

I have lightdm autologin from cinnamon which is set in xintrc  as exec cinnamon-session

That makes no sense at all but also that you're not using xinitrc, see https://wiki.archlinux.org/index.php/XDG_Autostart

Also

seth wrote:

How did you install archlinux?

Offline

#39 2021-04-18 16:00:40

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

I have the line in xintrc to exec cinnamon-session, and have lightdm as login manager which i set to autologin by amending its .ini file, and it all works fine no problem for a good few years now, i installed it all manually arch way. Also i streamlined the system to suppress login messages so i get a fast clean boot with no boot messages following examples on arch wiki and stuff on youtube etc

Offline

#40 2021-04-18 16:13:26

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,523

Re: [SOLVED] Hard disk activity lights program required

pacman -Qi xinit-xsession

Offline

#41 2021-04-18 16:30:07

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

i get this on running above command : error: package 'xinit-xsession' was not found
i tried loading it via pacman but doenst allow it?

Offline

#42 2021-04-18 16:33:24

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,523

Re: [SOLVED] Hard disk activity lights program required

Because it's an AUR package and w/o it (or something equivalent), lightdm won't start your xinitrc as a session.

You could try to prepend some garbage "exec foobar" to your xintrc and I'm gonna bet your right arm that it will have no impact.

https://wiki.archlinux.org/index.php/Li … _autologin
https://wiki.archlinux.org/index.php/XDG_Autostart

Offline

#43 2021-04-18 16:40:22

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Ok thanks for that info, i have added both programs and amended to my system and can only place them in  bashrc it shows the errors but at least they r working, which setup have u got which desktop or on terminal etc, thanks for doing these programs up and i was reading the newer gtk stuff will deprecate much of the code in future. I only know basic bash and python and not got time to learn more stuff.
thanks once again.

Offline

#44 2021-04-18 16:59:38

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,523

Re: [SOLVED] Hard disk activity lights program required

This seems to be some google translation?

Anyway and again: leave your bashrc alone.
Use the xdg autostart to automatically launch stuff.

Or switch to xinit *instead* of lightdm.

But leave your bashrc alone - it has no business being involved here.

Offline

#45 2021-04-18 17:05:23

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Ok thanks will look into that, cheers!!!

Offline

#46 2021-04-18 17:23:49

jet14
Member
Registered: 2021-04-16
Posts: 24

Re: [SOLVED] Hard disk activity lights program required

Hi I just checked my cinnamon stuff and i have added the files to the cinnamon autostart program and removed the entries from bashrc.
So finally job done. Thanks to Seth and Morn for helping, all in a days work!!!

Offline

#47 2021-04-18 17:47:57

Morn
Member
Registered: 2012-09-02
Posts: 886

Re: [SOLVED] Hard disk activity lights program required

You're welcome! Then you can conclude this endless saga now by marking the thread as "[SOLVED]"… smile

Offline

Board footer

Powered by FluxBB