WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: pcmanfm startup script  (Read 4867 times)

Offline Kingdomcome

  • Sr. Member
  • ****
  • Posts: 286
pcmanfm startup script
« on: November 21, 2009, 10:50:08 AM »
The startup script for pcmanfm is hardcoded with the user tc. It would be nice for it to read the username from /etc/sysconfig/tcuser.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: pcmanfm startup script
« Reply #1 on: November 21, 2009, 11:00:58 AM »
The startup script for pcmanfm is hardcoded with the user tc. It would be nice for it to read the username from /etc/sysconfig/tcuser.

I see your point, however it is not so trivial. Startup script is executed before saved data restored ant it may overwrite /etc/sysconfig/tcuser

Also if there is a different user specified it is required to check /etc/passwd to check user exists, its home directory setting, etc. I would postpone it for a later time.

What is more trivial to add it to /root

To be honest it is not a pcmanfm business, more it is up to the gtk+ environment. It is done by pcmanfm and wicd only to fix its lack and to make them working  >:( as a victim. Possibly other applications are missing it also.
« Last Edit: November 21, 2009, 11:09:02 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Kingdomcome

  • Sr. Member
  • ****
  • Posts: 286
Re: pcmanfm startup script
« Reply #2 on: November 21, 2009, 01:43:49 PM »
What I do in any script that reads or writes to home, or needs to run an app as the default user is:
Code: [Select]
#!/bin/sh
tcuser=$(cat /etc/sysconfig/tcuser)
cp -p /some/file /home/${tcuser}/file
sudo -u ${tcuser} somecommand
I see this in other extensions and believe this is somewhat of a TC standard, it allows people to use the "user=" bootcode.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: pcmanfm startup script
« Reply #3 on: November 21, 2009, 01:46:08 PM »
/etc/sysconfig/tcuser should never be overwritten by a startup script or a backup.  It is there to be referred to to find the current user.  The bootcode should be used to specify user and not by backing up /etc/sysconfig/tcuser.  This approach should be used when copying files to the home directory:

Code: [Select]
#!/bin/sh

MYUSER=`cat /etc/sysconfig/tcuser

cp file /home/"$MYUSER"/



And not using /home/tc as the home directory.

EDIT:  I see Kingdomcome has just posted the same, and it is the right approach.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: pcmanfm startup script
« Reply #4 on: November 21, 2009, 01:53:31 PM »
The probmlem with your script that it expets to have user's home directory in /home which is not necessarily true, as user's home can be anywhere. Exact location is stored normally in /etc/passwd and this is used by other utilities.

Well, you can establish a rule for TC that a user home dir must be in /home, but this would be an unnecsary restriction.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: pcmanfm startup script
« Reply #5 on: November 21, 2009, 05:36:44 PM »
Tce-setup expects and makes the user's home directory in /home/`cat /etc/sysconfig/tcuser`.  So unless that is changed, /home is always where the user home directory is.

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: pcmanfm startup script
« Reply #6 on: November 24, 2009, 02:09:21 AM »
The probmlem with your script that it expets to have user's home directory in /home which is not necessarily true, as user's home can be anywhere. Exact location is stored normally in /etc/passwd and this is used by other utilities.

Well, you can establish a rule for TC that a user home dir must be in /home, but this would be an unnecsary restriction.
Sure, but on the other hand having just this extra "feature" could be considered excessive.  As already pointed out, TC already uses /home... it's a standard anyways, and it could be said that probably all user home directories will be in /home.

But if this realllly bothering you, you could do something like
Code: [Select]
su -c 'echo $HOME' `cat /etc/sysconfig/tcuser`

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: pcmanfm startup script
« Reply #7 on: November 24, 2009, 02:38:37 AM »
I'm fine with this limitation or call it rule :) on TC. I asked it because in general under LINUX you can put user's home anywhere, using /home is not a technical requirement but simplyfies administration and offers some standard compatibility.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: pcmanfm startup script
« Reply #8 on: November 24, 2009, 03:12:34 AM »
convention seems to fit the bill

I'd say it's similar to any other path.  In a Linux based distro, you could change anything.  Why /etc/passwd?  Or /usr/bin? /root? etc...

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: pcmanfm startup script
« Reply #9 on: November 24, 2009, 03:32:04 AM »
convention seems to fit the bill
 Why /etc/passwd?  Or /usr/bin? /root? etc...

Linux Standard Base (LSB) ? http://www.linuxfoundation.org/collaborate/workgroups/lsb
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: pcmanfm startup script
« Reply #10 on: November 24, 2009, 04:32:17 AM »
Sure, and those are conventions :)

(side note: I seem to recall FHS saying /home was optional)

... and this is getting OT heh.  Need a split?
« Last Edit: November 24, 2009, 04:34:09 AM by ^thehatsrule^ »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: pcmanfm startup script
« Reply #11 on: November 24, 2009, 04:40:06 AM »
... and this is getting OT heh.  Need a split?

Do not split, I do not want to deal with this topic now  :D
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."