xsession skeleton
This commit is contained in:
17
fimplate.py
17
fimplate.py
@@ -1,11 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
import sys,re,os
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from argparse import RawTextHelpFormatter
|
from argparse import RawTextHelpFormatter
|
||||||
|
|
||||||
def setup_options():
|
def setup_options():
|
||||||
parser=ArgumentParser(description="""Template Filler
|
parser=ArgumentParser(description="""Template Filler
|
||||||
|
|
||||||
@@ -16,6 +12,8 @@ def setup_options():
|
|||||||
== Value file/Value pair example: ==
|
== Value file/Value pair example: ==
|
||||||
[[name]]=John
|
[[name]]=John
|
||||||
""",formatter_class=RawTextHelpFormatter)
|
""",formatter_class=RawTextHelpFormatter)
|
||||||
|
parser.add_argument("-e",action="store_true",dest="env",default=False,
|
||||||
|
help="Use the environment to replace ${env} style variables.")
|
||||||
parser.add_argument("-f",action="store",dest="file",
|
parser.add_argument("-f",action="store",dest="file",
|
||||||
help="File name to read keys/values.")
|
help="File name to read keys/values.")
|
||||||
parser.add_argument("-p",action="append",dest="values",default=[],
|
parser.add_argument("-p",action="append",dest="values",default=[],
|
||||||
@@ -49,7 +47,6 @@ def parse_arguments(args):
|
|||||||
pairs.append( (tokens[0], tokens[1].decode('string_escape')) )
|
pairs.append( (tokens[0], tokens[1].decode('string_escape')) )
|
||||||
return pairs
|
return pairs
|
||||||
|
|
||||||
def main():
|
|
||||||
options=setup_options();
|
options=setup_options();
|
||||||
pairs=[]
|
pairs=[]
|
||||||
if options.file!=None:
|
if options.file!=None:
|
||||||
@@ -62,8 +59,8 @@ def main():
|
|||||||
for l in in_reader:
|
for l in in_reader:
|
||||||
for p in pairs:
|
for p in pairs:
|
||||||
l=l.replace(p[0],p[1])
|
l=l.replace(p[0],p[1])
|
||||||
|
if options.env:
|
||||||
|
var_list=[m.group(0) for m in re.finditer('\${[^ ]+}', l)]
|
||||||
|
for v in var_list:
|
||||||
|
l=l.replace(v,os.environ.get(v[:-1][2:],""))
|
||||||
sys.stdout.write(l)
|
sys.stdout.write(l)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
|||||||
13
skel/xsessionrc
Executable file
13
skel/xsessionrc
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#sleep 1
|
||||||
|
#$HOME/bin/disp 4
|
||||||
|
|
||||||
|
# Do something if at Univ network
|
||||||
|
#if ping ad.helsinki.fi -c 2; then
|
||||||
|
# true
|
||||||
|
#fi
|
||||||
|
|
||||||
|
true
|
||||||
|
|
||||||
|
|
||||||
9
skel/xsessionrc.desktop
Normal file
9
skel/xsessionrc.desktop
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Session startup script
|
||||||
|
Comment=Edit to suit your settings
|
||||||
|
Exec=${HOME}/bin/xscreenrc
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Icon=preferences-desktop-theme
|
||||||
|
Categories=Settings
|
||||||
|
StartupNotify=false
|
||||||
Reference in New Issue
Block a user