This repository was archived by the owner on Mar 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathContext.ps1
More file actions
99 lines (79 loc) · 2.47 KB
/
Context.ps1
File metadata and controls
99 lines (79 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Skin information
$SkinName = "Jiffy"
$ROOTCONFIG = $SkinName
$editVariablesFile = "#@#variables.inc"
# Script settings
# Output file
$out = "@Resources\ContextMenu.inc"
# Are you using a language file?
# If true, context menu titles will use __language variables
$useLanguage = $False
# Common context menu items
$spacer = @{
Title = '-'
Action = ''
}
$current = @{
Title = '#CURRENTCONFIG#'
Action = '["#CURRENTPATH#"]'
}
$editVariables = @{
Title = if ($useLanguage) { '#__EditVariables#' } else { 'Edit variables' }
Action = "[`"#CONFIGEDITOR#`" `"$editVariablesFile`"]"
}
$refreshGroup = @{
Title = if ($useLanguage) { '#__RefreshGroup#' } else { "Refresh $SkinName" }
Action = "[!RefreshGroup $ROOTCONFIG]"
}
$skinmenu = @{
Title = if ($useLanguage) { '#__SkinMenu#' } else { 'Open skin menu' }
Action = '[!SkinMenu]'
}
$centerHorizontal = @{
Title = if ($useLanguage) { '#__CenterHorizontal#' } else { 'Center horizontally' }
Action = '[!SetWindowPosition "50%" "[#CURRENTCONFIGY]" "50%" "0%"]'
}
$centerVertical = @{
Title = if ($useLanguage) { '#__CenterVertical#' } else { 'Center vertically' }
Action = '[!SetWindowPosition "([#CURRENTCONFIGX] + ([#CURRENTCONFIGWIDTH] / 2))" "50%" "50%" "50%"]'
}
function ToggleVariable {
[CmdletBinding()]
param (
[Parameter(Mandatory, Position, ValueFromPipeline)]
[string]
$VariableName
)
return @{
Title = if ($useLanguage) { "#__Toggle$VariableName#" } else { "Toggle $VariableName" }
Action = "[!SetVariable `"$VariableName`" `"([#$VariableName] = 1 ? 0 : 1)`"][!WriteKeyValue Variables `"$VariableName`" [#$VariableName] `"$editVariablesFile`"][!Refresh]"
}
}
$speedUp = @{
Title = "Animate faster"
Action = '[!WriteKeyValue Variables Update "([#Update] <= 16 ? 16 : ([#Update] - 8))"][!Refresh]'
}
$speedDown = @{
Title = "Animate slower"
Action = '[!WriteKeyValue Variables Update "([#Update] + 8)"][!Refresh]'
}
$menu = @(
$current, $spacer,
$centerHorizontal, $centerVertical, $spacer,
$speedUp, $speedDown, $spacer,
$skinmenu
)
function Write-Menu {
$output = "[Rainmeter]`nRightMouseUpAction=[!SkinCustomMenu]`nGroup=$SkinName`n"
$count = ""
$menu | % {
$output += @"
ContextTitle$($count)=$($_.Title)
ContextAction$($count)=$($_.Action)
"@
$count = 1 + $count
if ($count -eq 1) { $count++ }
}
$output | Out-File -FilePath $out
}
Write-Menu