librelist archives

« back to archive

Getting curent directory from a .shy file

Getting curent directory from a .shy file

From:
Luka Povreslo
Date:
2015-01-29 @ 17:49
I know how .shy works(or at least what it does), it creates a temporary
file and executes there, is there a way to change its directory to the one
from where it was ran without asking for it? The thing is that I want to
automatically create a subdirectory when the app is executed for the first
time and that directory's value to be saved to a yaml file.

-- 
*Cheers!*

Re: [shoes] Getting curent directory from a .shy file

From:
Cecil Coupe
Date:
2015-01-29 @ 21:57
Luka,

    There are several bits of info you can use to build a path for your 
settings file.

    Dir.getwd() will return the directory that the running script is in. 
In a shy file,  that will be a temp dir somewhere. ENV['HOME'] is the 
users directory. On OSX and Linux you'd create the directory path like 
File.join(ENV['HOME'],'.my-hidden-dir','my-settings.yaml')

   Windows is a little different. It has a hidden directory too, several 
of them. ENV[APPDATA] although the recommend place is 
File.join(ENV['LOCALAPPDATA'],'mydir','my-settings.yaml')  On Windows 
you'll want to tell it to show the hidden directory so you can see 
what's there.  You'll see some shoes stuff in there, too.

   I've got a new feature for Shoes 3.2 that would do a lot of what you 
want but I need to fix some bugs first, so you shouldn't wait for that.

--Cecil

On 01/29/2015 10:49 AM, Luka Povreslo wrote:
> I know how .shy works(or at least what it does), it creates a 
> temporary file and executes there, is there a way to change its 
> directory to the one from where it was ran without asking for it? The 
> thing is that I want to automatically create a subdirectory when the 
> app is executed for the first time and that directory's value to be 
> saved to a yaml file.
>
> -- 
> /Cheers!/

Re: [shoes] Getting curent directory from a .shy file

From:
Luka Povreslo
Date:
2015-01-29 @ 22:30
Yeah, I know about that, for windows and linux as well, what I need is that
script just somehow give me the name of a directory where the file is, not
necessary to change its working status to that place.

I usually got my directory simply by using Dir.pwd, which is the same
thing, and changed it by Dir.chdir(new_directory). Basically, I want to
share one application that I made for school with my friends so that he
only needs to install shoes, start .shy file and get an app running.

Cecil, I'm very excited about new releases, I really admire you, however, I
must say that I feel content with current versions since you fixed a
:resizable => false issue since other issues don't really bother me that
much.



2015-01-29 22:57 GMT+01:00 Cecil Coupe <ccoupe@cableone.net>:

>  Luka,
>
>    There are several bits of info you can use to build a path for your
> settings file.
>
>    Dir.getwd() will return the directory that the running script is in. In
> a shy file,  that will be a temp dir somewhere. ENV['HOME'] is the users
> directory. On OSX and Linux you'd create the directory path like
> File.join(ENV['HOME'],'.my-hidden-dir','my-settings.yaml')
>
>   Windows is a little different. It has a hidden directory too, several of
> them. ENV[APPDATA] although the recommend place is
> File.join(ENV['LOCALAPPDATA'],'mydir','my-settings.yaml')  On Windows
> you'll want to tell it to show the hidden directory so you can see what's
> there.  You'll see some shoes stuff in there, too.
>
>   I've got a new feature for Shoes 3.2 that would do a lot of what you
> want but I need to fix some bugs first, so you shouldn't wait for that.
>
> --Cecil
>
>
> On 01/29/2015 10:49 AM, Luka Povreslo wrote:
>
> I know how .shy works(or at least what it does), it creates a temporary
> file and executes there, is there a way to change its directory to the one
> from where it was ran without asking for it? The thing is that I want to
> automatically create a subdirectory when the app is executed for the first
> time and that directory's value to be saved to a yaml file.
>
>  --
>  *Cheers!*
>
>
>


-- 
*Cheers!*

Re: [shoes] Getting curent directory from a .shy file

From:
Cecil Coupe
Date:
2015-01-30 @ 09:18
Maybe I don't understand. You can have ruby code in your script that 
runs before the Shoes gui is started. Just put it before the Shoes.app 
call. Pseudo-code follows

# get path to settings
setting_path = File.join(.....)
if !File.exists(setting_path)
   # make new yaml with defaults
end
$my_config = yaml.load(setting_path)
Shoes.app do
   edit_line $my_config['setting1']
   edit_box $my_config['setting2]
end

Would something like that work?
--Cecil

On 01/29/2015 03:30 PM, Luka Povreslo wrote:
> Yeah, I know about that, for windows and linux as well, what I need is 
> that script just somehow give me the name of a directory where the 
> file is, not necessary to change its working status to that place.
>
> I usually got my directory simply by using Dir.pwd, which is the same 
> thing, and changed it by Dir.chdir(new_directory). Basically, I want 
> to share one application that I made for school with my friends so 
> that he only needs to install shoes, start .shy file and get an app 
> running.
>
> Cecil, I'm very excited about new releases, I really admire you, 
> however, I must say that I feel content with current versions since 
> you fixed a :resizable => false issue since other issues don't really 
> bother me that much.
>
>
>
> 2015-01-29 22:57 GMT+01:00 Cecil Coupe <ccoup e@cableone.net 
> <mailto:ccoupe@cableone.net>>:
>
>     Luka,
>
>        There are several bits of info you can use to build a path for
>     your settings file.
>
>        Dir.getwd() will return the directory that the running script
>     is in. In a shy file,  that will be a temp dir somewhere.
>     ENV['HOME'] is the users directory. On OSX and Linux you'd create
>     the directory path like
>     File.join(ENV['HOME'],'.my-hidden-dir','my-settings.yaml')
>
>       Windows is a little different. It has a hidden directory too,
>     several of them. ENV[APPDATA] although the recommend place is
>     File.join(ENV['LOCALAPPDATA'],'mydir','my-settings.yaml') On
>     Windows you'll want to tell it to show the hidden directory so you
>     can see what's there.  You'll see some shoes stuff in there, too.
>
>       I've got a new feature for Shoes 3.2 that would do a lot of what
>     you want but I need to fix some bugs first, so you shouldn't wait
>     for that.
>
>     --Cecil
>
>
>     On 01/29/2015 10:49 AM, Luka Povreslo wrote:
>>     I know how .shy works(or at least what it does), it creates a
>>     temporary file and executes there, is there a way to change its
>>     directory to the one from where it was ran without asking for it?
>>     The thing is that I want to automatically create a subdirectory
>>     when the app is executed for the first time and that directory's
>>     value to be saved to a yaml file.
>>
>>     -- 
>>     /Cheers!/
>
>
>
>
> -- 
> /Cheers!/

Re: [shoes] Getting curent directory from a .shy file

From:
Luka Povreslo
Date:
2015-01-30 @ 14:15
I just tried it but it doesn't really work as .shy is immediately running
as a temp file and doesn't mind about the directory where it is situated.


2015-01-30 10:18 GMT+01:00 Cecil Coupe <ccoupe@cableone.net>:

>  Maybe I don't understand. You can have ruby code in your script that runs
> before the Shoes gui is started. Just put it before the Shoes.app call.
> Pseudo-code follows
>
> # get path to settings
> setting_path = File.join(.....)
> if !File.exists(setting_path)
>   # make new yaml with defaults
> end
> $my_config = yaml.load(setting_path)
> Shoes.app do
>   edit_line $my_config['setting1']
>   edit_box $my_config['setting2]
> end
>
> Would something like that work?
> --Cecil
>
>
> On 01/29/2015 03:30 PM, Luka Povreslo wrote:
>
> Yeah, I know about that, for windows and linux as well, what I need is
> that script just somehow give me the name of a directory where the file is,
> not necessary to change its working status to that place.
>
>  I usually got my directory simply by using Dir.pwd, which is the same
> thing, and changed it by Dir.chdir(new_directory). Basically, I want to
> share one application that I made for school with my friends so that he
> only needs to install shoes, start .shy file and get an app running.
>
>  Cecil, I'm very excited about new releases, I really admire you,
> however, I must say that I feel content with current versions since you
> fixed a :resizable => false issue since other issues don't really bother me
> that much.
>
>
>
> 2015-01-29 22:57 GMT+01:00 Cecil Coupe <ccoup e@cableone.net
> <ccoupe@cableone.net>>:
>
>>  Luka,
>>
>>    There are several bits of info you can use to build a path for your
>> settings file.
>>
>>    Dir.getwd() will return the directory that the running script is in.
>> In a shy file,  that will be a temp dir somewhere. ENV['HOME'] is the users
>> directory. On OSX and Linux you'd create the directory path like
>> File.join(ENV['HOME'],'.my-hidden-dir','my-settings.yaml')
>>
>>   Windows is a little different. It has a hidden directory too, several
>> of them. ENV[APPDATA] although the recommend place is
>> File.join(ENV['LOCALAPPDATA'],'mydir','my-settings.yaml')  On Windows
>> you'll want to tell it to show the hidden directory so you can see what's
>> there.  You'll see some shoes stuff in there, too.
>>
>>   I've got a new feature for Shoes 3.2 that would do a lot of what you
>> want but I need to fix some bugs first, so you shouldn't wait for that.
>>
>> --Cecil
>>
>>
>> On 01/29/2015 10:49 AM, Luka Povreslo wrote:
>>
>> I know how .shy works(or at least what it does), it creates a temporary
>> file and executes there, is there a way to change its directory to the one
>> from where it was ran without asking for it? The thing is that I want to
>> automatically create a subdirectory when the app is executed for the first
>> time and that directory's value to be saved to a yaml file.
>>
>>  --
>>  *Cheers!*
>>
>>
>>
>
>
>  --
>  *Cheers!*
>
>
>


-- 
*Cheers!*

Re: [shoes] Getting curent directory from a .shy file

From:
Cecil Coupe
Date:
2015-01-31 @ 11:28
Luka,
   Until I can look at your code, I don't know how to help you. Email me 
the .shy

ccoupe@cableone.net


On 01/30/2015 07:15 AM, Luka Povreslo wrote:
> I just tried it but it doesn't really work as .shy is immediately 
> running as a temp file and doesn't mind about the directory where it 
> is situated.
>
>
> 2015-01-30 10:18 GMT+01:00 Cecil Coupe <ccoupe@cableone.net 
> <mailto:ccoupe@cableone.net>>:
>
>     Maybe I don't understand. You can have ruby code in your script
>     that runs before the Shoes gui is started. Just put it before the
>     Shoes.app call. Pseudo-code follows
>
>     # get path to settings
>     setting_path = File.join(.....)
>     if !File.exists(setting_path)
>       # make new yaml with defaults
>     end
>     $my_config = yaml.load(setting_path)
>     Shoes.app do
>       edit_line $my_config['setting1']
>       edit_box $my_config['setting2]
>     end
>
>     Would something like that work?
>     --Cecil
>
>
>     On 01/29/2015 03:30 PM, Luka Povreslo wrote:
>>     Yeah, I know about that, for windows and linux as well, what I
>>     need is that script just somehow give me the name of a directory
>>     where the file is, not necessary to change its working status to
>>     that place.
>>
>>     I usually got my directory simply by using Dir.pwd, which is the
>>     same thing, and changed it by Dir.chdir(new_directory).
>>     Basically, I want to share one application that I made for school
>>     with my friends so that he only needs to install shoes, start
>>     .shy file and get an app running.
>>
>>     Cecil, I'm very excited about new releases, I really admire you,
>>     however, I must say that I feel content with current versions
>>     since you fixed a :resizable => false issue since other issues
>>     don't really bother me that much.
>>
>>
>>
>>     2015-01-29 22:57 GMT+01:00 Cecil Coupe <ccoup e@cableone.net
>>     <mailto:ccoupe@cableone.net>>:
>>
>>         Luka,
>>
>>            There are several bits of info you can use to build a path
>>         for your settings file.
>>
>>            Dir.getwd() will return the directory that the running
>>         script is in. In a shy file,  that will be a temp dir
>>         somewhere. ENV['HOME'] is the users directory. On OSX and
>>         Linux you'd create the directory path like
>>         File.join(ENV['HOME'],'.my-hidden-dir','my-settings.yaml')
>>
>>           Windows is a little different. It has a hidden directory
>>         too, several of them. ENV[APPDATA] although the recommend
>>         place is
>>         File.join(ENV['LOCALAPPDATA'],'mydir','my-settings.yaml') On
>>         Windows you'll want to tell it to show the hidden directory
>>         so you can see what's there.  You'll see some shoes stuff in
>>         there, too.
>>
>>           I've got a new feature for Shoes 3.2 that would do a lot of
>>         what you want but I need to fix some bugs first, so you
>>         shouldn't wait for that.
>>
>>         --Cecil
>>
>>
>>         On 01/29/2015 10:49 AM, Luka Povreslo wrote:
>>>         I know how .shy works(or at least what it does), it creates
>>>         a temporary file and executes there, is there a way to
>>>         change its directory to the one from where it was ran
>>>         without asking for it? The thing is that I want to
>>>         automatically create a subdirectory when the app is executed
>>>         for the first time and that directory's value to be saved to
>>>         a yaml file.
>>>
>>>         -- 
>>>         /Cheers!/
>>
>>
>>
>>
>>     -- 
>>     /Cheers!/
>
>
>
>
> -- 
> /Cheers!/